amazing how easy things are sometimes.
guess i have a long way to go
thanks!
D
amazing how easy things are sometimes.
guess i have a long way to go
thanks!
D
Hey all.
One day, I'll get good enough at this to offer help instead of only asking question.
But for now:
I would like to be able to use variables from one function inside a different function. Please forgive my poor scripting - but as an example...
module Plugin
unless file_loaded?("program.rb")
mymenu = UI.menu('Plugins').add_submenu('test')
mymenu.add_item('Test Program') {self.Box}
mymenu.add_item('Test Program 2') {self.Circle}
file_loaded("program.rb")
end #unless
def self.Box()
a = 5
b = 6
c = a * b
end #Box
def self.Circle()
d = 12
e = d * a ##this won't work of course, because (a) is not defined within this function... how do you pull the value of (a) from Box?
end #failCircle
end #module
Thanks much!
Derek
I moved the vol.erase! line to just after
vol.set_attribute("Volume","Tag",true) ### v1.8
in Volume::process
and it seems to be working.
Is there something between
vol.set_attribute("Volume","Tag",true) ### v1.8
and the end of that defwhich makes volno longer available?
D
I spoke too soon!!!!
I think I followed your instructions well (though, I don't rule out user error) - but when I run the script and actually pay attention I noticed that the volume and text are NOT being deleted.
In the ruby console I get an error that:
Error: #<NameError: undefined local variable or method `vol' for Volume:Class>
Have I put the vol.erase! line in the wrong place? I located it, as you said, just before the Process code ends.
Any ideas?
Thanks
D
Hey folks.
I've been messing around with the VolumeCalculator21 plugin, trying to figure out what controls the addition of the copied volume to a new layer. I'd like to have the plugin NOT create the new layer and copied volume (or, alternatively, delete them after they are created and used).
Is there a way to delete a layer and its contents from within ruby?
Can anyone tell me which lines of this plugin are "copying" the selected volume into the newly created layer within the plugin?
I've attached the plugin for reference.
Thanks!
Derek
Hey folks,
I've searched around, and I'm sure I missed an easy answer - but how can you determine the operating system of a computer within a ruby script? I really just want to know if whoever is using my plugin is on a Mac or PC - is this possible?
Thanks much, as always!
Derek
I've searched the web for quite some time now, stumbling over the various explanations on how to import CSV files into arrays in Sketchup's Ruby.
I think, if it's possible, I just need a dumbed down explanation on how to do it; my Ruby force is very very weak.
Let's say I have the following as a CSV:
1,2,3,4,5
yes,no,2
I would like to then create an array to hold each of the rows of values, such that I end up with:
array_1 = [1, 2, 3, 4, 5]
array_2 = ["yes", "no", 2]
When I follow http://groups.google.com/group/sketchupruby/browse_thread/thread/d25a302dece3b21b/7c11cb4541613773?lnk=gst&q=foltz+csv#7c11cb4541613773
using:
csv_data = []
f = File.open(path,'r')
f.each_line{|line| csv_data.push line.split(",")}
I end up with:
csv_data = [["1.0", "2.0", "3.0", "4.0", "5.0\n"], ["yes", "no", "2.0\n"]]
note the end of line indicators still being present (\n)
Using the next line:
headers = csv_data.shift.map {|i| i.to_s }
returns:
headers = ["1.0", "2.0", "3.0", "4.0", "5.0\n"]
where headers[0] = 1.0, headers[1] = 2.0, etc.
That's pretty good.
The last line:
string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }
returns:
string_data = [["yes", "no", "2.0\n"]]
where string_data[0] = ["yes", "no", "2.0\n"]
Not great.
using a similar line as for "headers":
headers2 = string_data.shift.map {|i| i.to_s }
gets me to:
headers2 = ["yes", "no", "2.0\n"]
Better,
but still with that pesky \n.
Is there a better way to do this? And how do I avoid the \n?
What about if there are more than 2 lines?
I looked over Jim Foltz/Dan Rathbun's method, but I don't understand the code well enough to manipulate the parts that I want to use (it includes an IO schmealy that I'm not familiar with).
Any hints would be greatly appreciated. Thanks much as always!
Derek
Hello!
I have two questions:
Is it possible to have check boxes (instead of fill-in-the-blanks or drop-down lists) in the UI input box in SketchUP?
Is it possible to have two UI input boxes open at one time (as in, clicking on something in one UI box will open another input box, which must be closed before the first UI box can be manipulated again) ?
As always, thanks!!!
Derek