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...
selectSelectionToolchanges to that tool...
No hack... No magic involved...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement