Model.edit_transform for parent
-
Is there any way to get the local transformation for a component that is not at the end of the active path?
For example, say I double click a component, and then double click a component inside that one. I want to find the local transformation of the first.
-
model.edit_transform
gives the current edit's transformation
To find the transformation of the 'first' parent you need to iterate down the tree until it's the one before 'model' - so something like...### first you somehow set 'entities' to the current edit's entities set and find the parent e.g. parent=entities[0].parent ### then done=false until done if parent.entities[0].parent == Sketchup.active_model done=true else parent=parent.entities[0].parent end#if end ### parent is now the first container ? ###
-
I can get the instance I'm looking for, but I'm having problems getting the actual transformation, since it is also in edit mode, but not the current edit mode.
I was able to find instance.local_transform, but it is undocumented.
Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.
-
instance.local_transformation
seems to return nothing useful...
Working down towards Model will give you the entity's ultimate container - then you can find its transformation ?
If the final container is a component-definition then you're stuffed as you'll want the actual instances' transformation
You can't easily get the transformation of an entity inside an Instance of a Definition - get the entity's transformation within the Definition and then adjust it by the containing Instance's transformation [and then that's container's transformation etc etc] so you should somehow be able to apply that to the entity's too ? -
I would guess the
local_transformation
method has its origin as part of Dynamic Components. It's not mentioned in the API docs at all. -
It looks like its inherited from drawing element, so you can use it on faces and edges, too.
-
Model.active_path
http://code.google.com/apis/sketchup/docs/ourdoc/model.html#active_pathuse that to traverse the path up to the current
model.edit_transform * model.active_path.last.transform.inverse
-
@cjthompson said:
Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.
Get help from a pickhelper?
http://code.google.com/apis/sketchup/docs/ourdoc/pickhelper.html -
@thomthom said:
@cjthompson said:
Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.
Get help from a pickhelper?
http://code.google.com/apis/sketchup/docs/ourdoc/pickhelper.htmlexcept you can't pick outside of edit mode.
I solved it by just drilling down the model structure, instead of going up it like the original idea.
-
yes you can.
once you do a pick you get an array of various pick solutions.
.all_picked returns a list of all the top level entities for each possible path. .count return the number of possible paths. Use .path_at to get a drill down path for the given index. -
sorry, I must be really tired today. I meant you can't use a pickhelper outside of the current context. so If you you have two instances in the model, and you double click one, you can't use the pickhelper on it's sibling.
Advertisement