Importing and placing components
-
I'm writing a Ruby script that (using AppleScript) causes SU to start up, open a file containing a "wall" (10' x 10' x 1' box), and import a component file. This all works, except that I don't know how to place the component against the wall.
Clues?
-r
-
Perhaps get it to set a flag [$xxx] so you know that it's done something.
Then when your model opens it finds the component by its name [defn] and then uses - for example:model=Sketchup.active_model defn=model.definitions[your_components_name] tr=Geom;;Transformation.new(your_required_point_on _the _wall) model.active_entities.add_instance(defn,tr)
-
Thanks, TIG! That almost works.
If I just run the script, the component never shows up. However, if I click on the border of the main SU window (using the mouse), the component appears in the specified location. So, what do I have to do to mechanize the mouse click?
-r
-
Hmmm. I just tried a sleazy hack which seems to work:
model.active_entities.add_instance(defn, tran) Sketchup.send_action('selectSelectionTool;')
Selecting the Selection Tool seems to "wake up" SU, causing it to place and display the component without any user action.
-r
-
Not sure if this would do the same, but you might try view.refresh.
http://code.google.com/apis/sketchup/docs/ourdoc/view.html#refresh
Cheers,
-
@unknownuser said:
Not sure if this would do the same, but you might try view.refresh.
http://code.google.com/apis/sketchup/docs/ourdoc/view.html#refresh
Cheers,
That isn't meant to be used within Tools? Thought most view methods where.
(might also be worth noting that it's 7.1 - so you'd still need another workaround for older versions - if this method if working.) -
You have exited your Tool so the View refreshes...
selectSelectionTool
changes to that tool...
No hack... No magic involved...
Advertisement