Jim and Didier,
Thanks for the help.
BR,
Ricardo
Jim and Didier,
Thanks for the help.
BR,
Ricardo
Jim,
Thanks for the fast response. I made the change and it works properly, but I'm still confused because the variable "incl" is displayed properly using the UI.messagebox without using the index of the array. The same happens with the variable "factor". If I make the product of "incl" and "factor" and use the result in the rotattion command it works fine as well (see code). Does this mean that only in certain methods (eg. rotation) the index of the matrix must be used?
def teste
prompts = ["Inclination", "Factor"]
values = [0.0, 0.0]
results = inputbox prompts, values, "Specs"
return if not results
incl, factor = results
UI.messagebox(incl.to_s)
x = incl * 2
UI.messagebox(x.to_s)
model = Sketchup.active_model
model.start_operation "Create Cylinder"
entities = model.active_entities
group = entities.add_group
entities = group.entities
circle = entities.add_circle([0,0,0], Z_AXIS, 2.mm, 24)
cyl_base = entities.add_face(circle)
cyl_base.pushpull -1000.mm
entities.transform_entities(Geom;;Transformation.rotation([0,0,0],[1,0,0],x.degrees),group)
#entities.transform_entities(Geom;;Transformation.rotation([0,0,0],[1,0,0],45.degrees),group)
model.commit_operation
end
if( not file_loaded?("teste.rb") )
add_separator_to_menu("Draw")
draw_menu = UI.menu("Draw")
teste_menu = draw_menu.add_item("teste") { teste }
end
file_loaded("teste.rb")
Thank you,
Ricardo
Hi everybody,
I'm new in Ruby but have some experience in other programming languages. At the moment I'm working in a script to create planar sundials to simulate them in SU before making the final device. To do this I need to rotate the style by a certain angle (geographic latitude) that is passed by the user to the script. If I use the variable "incl" in the script nothing happens, but if the variable is replaced by a number (e.g. 45) it works perfectly.
Does anyone know what can be wrong? I searched in many different sites and foruns, but wasn't able to make it work.
def teste
prompts = ["Inclination"]
values = [0.0]
results = inputbox prompts, values, "Specs"
return if not results
incl = results
model = Sketchup.active_model
model.start_operation "Draw"
entities = model.active_entities
group = entities.add_group
entities = group.entities
circle = entities.add_circle([0,0,0], Z_AXIS, 8.mm, 24)
cyl_base = entities.add_face(circle)
cyl_base.pushpull -100
entities.transform_entities(Geom;;Transformation.rotation([0,0,0],[1,0,0],incl.degrees),group)
#entities.transform_entities(Geom;;Transformation.rotation([0,0,0],[1,0,0],45.degrees),group)
model.commit_operation
end
if( not file_loaded?("teste.rb") )
add_separator_to_menu("Draw")
draw_menu = UI.menu("Draw")
teste_menu = draw_menu.add_item("teste") { teste }
end
file_loaded("teste.rb")
Thanks for any tip.
Best regards,
Ricardo