I am trying to generate some geometry and then place it with model.place_component
.
I would like to mimic the function from Revit when you place a family if you press space, the family rotates and you place it rotated.
Here is the code I am working with:
` #create geometry
def geom(x,y,z,xc=0,yc=0,zc=0)
group = Sketchup.active_model.entities.add_group
face = group.entities.add_face [0,0,0],[x,0,0],[x,y,0],[0,y,0]
face.reverse!
face.pushpull(z)
group.move! Geom::Transformation.new([xc,yc,zc])
return group
end
#inputs
w=500.mm
d=100.mm
h=100.mm
repeat = false
comp_to_place = geom(w,d,h)
def_comp = comp_to_place.definition
#place component
model = Sketchup.active_model
model.place_component(def_comp, repeat)
#if user press space, cancel model place, rotate component, start model place again
#delete place component that sits in 0,0,0`
My idea to approach this challenge is to get the user input and when the user press space to cancel the model place, rotate the geometry and start a new model.place_component with the rotated geometry.
Do you guys think this is the right way? And if yes how can I get the key press from the user? Thank you!