As the title says... I want to get the coordinates of all nested components.
I've searched but admittedly I don't really understand how transformations work so I might not be searching correctly.
When iterating a component I can get the origin of each nested component but that only returns the coordinates relative to it's immediate parent but not relative to the whole component tree... if that makes sense.
I'm assuming I would have to add each relative component transformation but I have no idea how to do that.
Get coordinates of nested components
5 posts
• Page 1 of 1
Re: Get coordinates of nested componentsI guess you talk about world coordinates of nested components, that is coordinates at top level of the model (for instance, which you can use with view.draw method).
If so, then just compose the transformation of each nested level. Transformation composition is the * operation. For instance, if you wish the world coordinates of a point at a level-3 nested object, just calculate t = t0 * t1 * t2 * t3, where
This means also that to compute coordinates at level N, you need to know the whole chain of grouponents.
Re: Get coordinates of nested components@fredo thanks for your reply...
So if I understand what you're saying, I need to find all the nested parent components first and there location and from there iterate the nested child components of each nested parent component to get the cumulative location? Sorry I think I even confused myself! ![]() Re: Get coordinates of nested componentsYes. You need to have the list of all components / groups at the top of the nested components.
To find it, it depends on your plugin situation. For instance, if you pick interactively the nested component, the PickHelper will give you the chain of grouponents.
Re: Get coordinates of nested components
Expanding upon this use of the PickHelper class ... This is using the Sketchup::PickHelper#path_at() method. It returns the instance path from the active entities context (for the given index in the list of pick paths.) To get the full path, you will need to add the pick path to the model's active edit path (if it is not nil.)
Then, you can use a little known method in the InstancePath class to get the transformation ...
See: Sketchup::InstancePath#transformation
5 posts
• Page 1 of 1
|
Who is online
Users browsing this forum: No registered users and 10 guests