Report just one attribute
-
model=Sketchup.active_model ss=model.selection gewicht=0 ss.each{|e| if e.class==Sketchup;;ComponentInstance gewicht=gewicht + e.definition.get_attribute("dynamic_attributes","gewicht",0) end#if # If the component definition has no gewicht then its gewicht = 0 # Wenn die Komponente Definition hat keine gewicht dann seine gewicht = 0 } UI.messagebox("Gesamtgewicht = " + gewicht.to_s + " kg")
This should work?
Diese Arbeit sollte? -
wow thanks for the qucik and helpful reply.
when i select nothing its okay.
iget this error in the console when i have a component selected:
Error: #<TypeError: String can't be coerced into Fixnum>
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/SINUS-gewichte.rb:13:in+' C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/SINUS-gewichte.rb:13:in
gewicht'
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/SINUS-gewichte.rb:11:ineach' C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/SINUS-gewichte.rb:11:in
gewicht'
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/SINUS-gewichte.rb:30
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/SINUS-gewichte.rb:29:in `call'any suggestions?
again, thanks
-
I haven't actually tested this, but I'm guessing this should work
@tig said:
> gewicht=gewicht + e.definition.get_attribute("dynamic_attributes","gewicht",0) >
to:
gewicht=gewicht + e.definition.get_attribute("dynamic_attributes","gewicht",0).to_f -
If 'gewicht' is always a number it should add OK to the earlier version of itself...
Maybe initially set
gewicht=0.0
so it's a float rather than an integer ?
Then use cjt'sgewicht=gewicht + e.definition.get_attribute("dynamic_attributes","gewicht",0.0).to_f
Try
puts e.definition.get_attribute("dynamic_attributes","gewicht",0.0)
inside the{}
so that you see in the ruby console what it's doing... -
@artofseeing said:
i want a messagebox to show me the following:
the single weight of each selected component
the sum of weights of all selected.that's practically it.
do you want one messagebox with each weight and one with the sum, or do you want one with both the sum of the weights and each weight?
-
actually, i need one messagebox with all weiths shown(sum and single),
as a checkup if it got all the data right.then im gonna take what the messagebox has shown and save it first as a simple text file,
in the end even paste the data into cells of a scalc file where i can
estimate the final loads at certain points.
i.e.:
i have 10 lamps and 2 beamers and 4 loudspeakers hanging on a line of truss,
so i get all the weights of each part, and the sum.
this truss is i.e. hanging at 2 points, so i estimate half the final load to each point.so in the end, its a load calculation, which, up to now, i always had to do by hand.
-
got it!
the guess was right.
make all values and variables floats, and it works out.
i selected none> weight=0
i selected one> weight=6
i selected 2> weight=12thanks guys:)
now to get also the single weights...
but i can do that.
-
one more strange happening yet:
ijust found out that
the sum of weights i get is a rounded value.
for example:a lamp has the value "15,4" for the key "gewicht".
if i report on that i get "15.0"cant seem to figure out just why...
-
got it1
it was my error writing "15,4" instead of "15.4" into the value -
@artofseeing said:
got it1
it was my error writing "15,4" instead of "15.4" into the valueGerman decimal points 1,2 == 1.2 !!!
Advertisement