Select component for placement


I’m creating a component via (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?

Model#place_component does exactly this.


Thanks a lot, this is exactly what I was looking for. Works perfectly. I must have searched in the wrong places (ComponentDefinition, DefinitionsList).

Actually, it would make more sense look for it as an instance method of the Sketchup::Entities class.

IF it were to be defined there, we would then be expected to need to only call it upon the active entities context thus:


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:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.