I’m creating a component via Class: Sketchup::DefinitionList — SketchUp Ruby API Documentation (DefinitionList.add). Is there a way to select the created definition and start the component placement tool, so that the user can directly create an instance by clicking the mouse?
Thanks a lot, this is exactly what I was looking for. Works perfectly. I must have searched in the wrong places (ComponentDefinition, DefinitionsList).
But that would bring up the question, what should happen if it were to be called on an non-active entities context ?
Since it IS a user interactive command, it was thought best to just force it to act only within the active entities context, so the method was defined “up one level” as an instance method of the active model object.
Think about it this way, and it makes sense that it is defined where it is.
Since this method activates a tool I think it makes sense to have it on the model class next to select_tool. ComponentDefinition and DefinitionList would also make sense though.
I just said this with another more important reason …
I will agree a Sketchup::ComponentDefintion#place_with_mouse() block form method would be COOL!
Right now it’s a rigmarole dealing with the instance after placement. Usually we have to use a temporary definition observer with an onComponentInstanceAdded callback.
Like in this example… [code] undoable place_component() "MoveTool" clone
It would be nifty to do something like the following but without having to use an observer:
this_defn.place_with_mouse(true) {|i|
# code to perform on instance i
# after each placement if repeat arg is true:
i.add_attribute("MyDictionary","SomeProperty",some_value)
}