Plugin(export attributes to csv)
-
Why do you distro a copy of sketchup.rb ?
It does not appear to be different from the Google version, and should not be changed anyhow.
-
TIG
Thank you so much for your reply!
I'm a fan of you. So excited to be able to get in touch with you.The Plugin worked flawlessly after the modification.
Dan Rathbun
Thank you for your advice.
It is the same as the Google version.I'll push the changes.
Since using "git" and push it to GITHUB seems to be a very usefull method I think other sketchup user might like using it. -
You shouldn't distribute
sketchup.rb
- all users will already have it in their Tools folder, so giving it to a user who might then put a duplicate [or worse, 'out of date'] version into their Plugins folder could cause all sorts of unexpected complications that can be avoided by NOT supplying it in the zip-file. -
TIG
Thank you for your advise.
I've removed sketchup.rb from GITHUB.Unfortunately, some other people still can't use the plugin.
<Error message>
#<NameError: undefined loca variable or method 'export2csv' for main:Object>do you have any idea what's wrong?
https://github.com/tetsuyahishida/export2csv/blob/version0.8/export2csv.rb
-
The error message is correct - export2csv is not a variable or function - it is never defined. You get the same error if you enter random characters in the Ruby Console.
Enter
Export2cvs.new
to start the plugin from the Ruby Console (the same as how it is executed from the menu and Toolbar.) -
Also, the Array class already has a
.dot
method - no need to add one to the Geom::Point3d class.http://code.google.com/apis/sketchup/docs/ourdoc/array.html#dot
In fact, it is best not to add or change methods of any of the API classes because those changes may cause other plugins to fail, or worse - to have subtle errors which may go undetected.
-
@jim said:
The error message is correct - export2csv is not a variable or function - it is never defined. You get the same error if you enter random characters in the Ruby Console.
Enter
Export2cvs.new
to start the plugin from the Ruby Console (the same as how it is executed from the menu and Toolbar.)...OR alternatively you could make a 'shortcut' method
def export2cvs(); Export2cvs.new(); end
outside of the Export2cvs class and then typingexport2cvs
will also run the tool... -
@unknownuser said:
...outside of the Export2cvs class
You don't want to do that either. Adding a top-level method adds it to the look-up chain for all Ruby objects. So there is a minute chance that if another dev happens to have a export2csv method and makes a mistake (a typo, for example) it is possible that the top-level method gets found and executed instead. This can occur even if the other dev's method is correctly namespaced.
-
@jim said:
@unknownuser said:
...outside of the Export2csv class
You don't want to do that either. Adding a top-level method adds it to the look-up chain for all Ruby objects. So there is a minute chance that if another dev happens to have a export2csv method and makes a mistake (a typo, for example) it is possible that the top-level method gets found and executed instead. This can occur even if the other dev's method is correctly namespaced.
I know it IS inadvisable to add new methods directly to the top-level, BUT even the API Ruby Examples show this way... so IF this guy is making a script for limited use and he has few other scripts loading then he's unlike to have a clash... BUT perhaps a less common name would be safer, AND of course even the class itself
Export2csv
.new() might have been used by someone else too... so then it'd be best to have a module holding that class, as it would then be extra-extra safe ! Then you'd have to typeTetsuyahishidaTools::Export2csv.new()
, BUT then it is very-very unlikely to have been duplicated by anyone else!!
Simply use a module to hold the class like this...module TetsuyahishidaTools class Export2csv def initialize() #... end#methods end#class ### class Export2tsv ### another Tool! #... end#class end#module
This way you can have several tools under the 'TetsuyahishidaTools' module...
PS: Please remove me [(c) TIG] as the 'blame' for this script in the header
-
Thank you for your reply.
jim
The user and he said typing"export2csv.new" solved the problem.
He was typing "export2csv"TIG
I've immedeately modified the authority. Sorry about my insensitiveness.Still I got three questions
First, does "::"of "TetsuyahishidaTools::Export2csv.new()"
stands for scope resolution operator?If not, what does it stand for?Second, Why does the "TetsuyahishidaTools Module" have to be a "Module"?
Is it because in Ruby, a class can only inherit from a single other class?
Or something about nesting rule?Third, are there any way to do the same thing using "include"?
Sorry for my poor English and ruby skill.
Best regards. -
@tetsuyahishida said:
First, does "::"of "TetsuyahishidaTools::Export2csv.new()"
stands for scope resolution operator?YES
-
@tetsuyahishida said:
Second, Why does the "TetsuyahishidaTools Module" have to be a "Module"?
Because an instance of class Module, can only be a singleton instance, meaning only ONE copy of the code it encloses, is needed.
Think about it. Within your outermost namespace (module), which should be your unique namespace (your company, etc.) you will define nested objects, both of class Class and class Module, and each of those only needs to be defined ONCE.@tetsuyahishida said:
Is it because in Ruby, a class can only inherit from a single other class?
No. But for your info... class Class, is actually a direct child subclass of class Module, so objects of class Class, will inherit some methods from their superclass (class Module.)
Also.. what most people do not realize, is that when you define a module, like ...
module SomeCode # method definitions, etc. end
.. that the Ruby parser actually instantiates an instance of class Module like this ...
SomeCode = Module.new do |mod| # method definitions, etc. end
... but it's actually done by C-side function calls.
-
@tetsuyahishida said:
Third, are there any way to do the same thing using "include"?
Only module instances can be mixed-in using the include or extend methods... BUT these 'mixin modules' can be mixed into other modules, classes, or instance objects.
-
Dan Rathbun
Thank you so much for instruction.
I am now studying "Design Patterns in Ruby"
And just learned about Singlton Pattern.Does every one use Design Pattern making sketchup plugin?
Or maybe use UML?
Advertisement