How to get current active axis?
-
As the title says. How do I get the current active axis?
-
Tjena.
Let say you get a face normal called new_z.
You could say new_z is the upvector, if I remember correctly.
Anyway. new_z must be a vector. That you use as current Z-axis.x_axez, y_axez, z_axez = new_z.axes
-
Tjena!
[Off Topic Swedish: Har du sett att vi startat ett svensk subforum? Gå in under dina inställningar och lägg till om du vill se det.]
I should have been clearer, I'd like to get the axis of the current component beeng selected.
-
Use
component_instance.transformation.origin
to get its location in its container and then
component_instance.transformation.zaxis
etc for the axes...
See here: http://www.sketchup.com/intl/en/developer/docs/ourdoc/transformation
These API notes are full of typos , BUT you should get the gist... -
OT
@unknownuser said:
[Off Topic Swedish: Har du sett att vi startat ett svensk subforum? Gå in under dina inställningar och lägg till om du vill se det.]
Nej! Ska genast kolla. Tack
@unknownuser said:
I'd like to get the axis of the current component beeng selected.
Do you mean the Transformation.origin ?
I mean it depends on how the component is built ?
It could be a gluing component or face me.You could check out this topic.
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57623%26amp;p=524693%26amp;hilit=get+component#p524693Edit TIG was faster.
-
@tig said:
Use
component_instance.transformation.origin
to get its location in its container and then
component_instance.transformation.zaxis
etc for the axes...
See here: http://www.sketchup.com/intl/en/developer/docs/ourdoc/transformation
These API notes are full of typos , BUT you should get the gist...Oooh, I feel rusty.
And if I want to use this within a selection. Check to see if it's a group or component and get axis and if it's not, use world axis? or parents axis if that is a component.
Am I making sense? -
In general, to get the worldspace axes, you'll need to chase up the hierarchy to the top, applying each parent.
Its kind of a pain.. -
To get the current hierarchy you can use:
path=Sketchup.active_model.active_path
http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#active_path
-
If you are in the root context then you can't. If the user has set a custom axis then there is no Ruby API method to obtain that. We have that logged as a feature request.
Advertisement