Dan,
thanks for this. It works. I don't know why though!
Best,
Francis
Posts
-
RE: [Code] wrapping operations
-
RE: Get Point3D from place_component
@dan rathbun said:
Now...
model#place_component()
(1) The API dictionary is incorrect, it does NOT return
nil
, it returns a reference to theactive_model
which is basically frivolous, but does allow call chaining.We have logged an API doc typo on this, as well as asking for something more useable to be returned (especially in the case of multiple insertions when the 2nd argument is
true
.)(2) When the 2nd argument is
false
, and only 1 instance is inserted,model#place_component()
works the same as the native tool, ie: the selection is cleared, and the newly placed component instance's reference is pushed into the selection (as it's only member.)So you can get it's insertion point as discussed in the post above.
FYI ... When the 2nd argument to
model#place_component()
istrue
, and multiple instances MIGHT HAVE BEEN inserted, the model's selection object IS NOT CHANGED.
If something was previously selected, it still is. If the selection was empty, it will still be empty.Dan,
thank you for you for your two posts which are very helpful. I would have ticked them both as 'resolve' but I had already done this for a previous post and 'the system' wouldn't allow me to tick more than one post as a 'resolved' post. I will be trying your ideas soon. Thanks again. Francis -
RE: Get Point3D from place_component
@sdmitch said:
Model.place_component seems to be the tool that is used when you select a component for placement from the Components Browswer. I guess the only way to find the insertion points would be to search for all instances of the component to get the .transformation.origin. of each like this
mod = Sketchup.active_model > ent = mod.active_entities > sel = mod.selection > cmp = mod.definitions["Component#1"] > puts "--insertion points of Component#1--" > cmp.instances.each{|ci| puts ci.transformation.origin} > puts "-----------------------------------" > >
Thank you for this it's very helpful. I will try it.
-
Get Point3D from place_component
Is there a Ruby way to get the insertion point of a component. Unfortunately model.place_component does not return a Point3D object, just nil.
Thank you for any help you can offer.
Francis
-
Makes a stair with component steps
I based this Ruby script on the Google Ruby tutorial which draws a stair. This does the same but the steps are components so if you edit one they all get changed. I'm a complete beginner so I'm having trouble making the whole stair a group but otherwise it works in my version of SU 7.