Access to the coordinate manager.
-
Hello everyone, I want to make a script that will align an object with wronged axes using the "Align Workplane to Selection" command. But the problem is that I don't understand how to access the coordinate manager so that I can use it to reset all values in world coordinate mode. Tell me, how can I achieve this? Screenshot example:
-
Hello @SmetK,
thank you for reaching out to us. We never expose GUIs (managers) in our APIs but instead the logic behind them. So, for example, we do not expose the Object Manager, but
GeListNode
and with it methods likeGetUp
,InsertAfter
, orRemove
which encapsulate the core functionalities of the Object Manager of arranging objects and tags.The same applies to your question, the Coordinate Manager is simply not exposed as it is just GUI fluff for more fundamental functionalities. There are some convenience methods like
BaseObject.GetAbsPos
,BaseObject.GetAbsScale
, andBaseObject.GetAbsRot
which in a certain sense mimic what the Coordinate Manager does. But under the hood everything is transform (matrix) based and you should operate with transforms too, everything else just tends to be a pain in the ***. You can have a look at our Matrix Manual in case you need an introduction.What comes on to top of that, is the fact that the axis of an object is not the separately manipulate able entity in the API as it is in the app. There is no function to "move" an axis because in the API and object has no axis, it has a global and local transform (matrix) which not only determines the transform of the object but also its points. We have the code example operation_transfer_axis_s26.py which exemplifies this at the example of moving "the axis" from one object to another. There are also countless topics on this subject on the forum here.
Last but not least: Writing a script which does what your screenshot implies, bringing problem into the state of aligned will be very hard without further user inputs. You could compute the bounding box for problem and with that its frame to then compute the delta between that frame and the world frame to "unrotate" the object. But that would just give you an object whose bounding box is somehow aligned with the world frame, your suite case could still be upside down. Also, not all bounding boxes must align with what humans would consider the "natural sides" of a geometry.
Deciding what is up/down, front/back, and left/right in a model, to compute the orientation which humans consider correct, is a very hard if not unsolvable problem without user inputs. Sometimes we can make simplifications (all my inputs are suite cases and I do not care if they are upside down), but in general the problem is very, very, very hard. Since this is a math/algorithmic problem, it is also out of scope of support, so I cannot help you too much here.
When there are questions regrading our API, please feel free to ask
Cheers,
Ferdinand -
@ferdinand Thank you very much for the expanded object.