Hi,
How can i access Planar Mid Points of an Object Using Code ?
Hi,
How can i access Planar Mid Points of an Object Using Code ?
If you check the helpfile Class reference and look for the getLocation method of the Object class you should be able to figure it out. The example actually shows you how to get the center
Also to allow for hierarchies I would recommend always projecting to the layer for which you want coordinates. For example (model coordinates):
Object targetspace=model(); Object myobject=Model.find("?Combiner1"); Vec3 objloc=myobject.getLocation(0.5,0.5,0.5).project(up(myobject),targetspace); double x=objloc.x; double y=objloc.y; //etc..
Hey, the easiest and fastest way I think is to look into an objects trigger where you want to define the location, take the Pickoption and see what development team does by default.
So I took an Processors On Entry trigger and did:
The default option seems to be what your are looking for:
And if you now open the Script Window of the Trigger you can see
the command you are looking for is
setloc();
and there are Parameters for the Object, the X Y Z Location and than you are allowed to implement Factors. these Factors are in your case xFactor = 0.5, yFactor = 0.5, zFactor = 0!
Hi, Thanks For your Reply
I have the object already in Model. I want to get the Center location using Code.
If you want to access the position/ location there are different ways you can try.
1. Use the Method .location that is implemented for all Objects
2. You can use xloc();yloc();zloc(); to get the same results like the Method of 1
3. Tryout Vec3 to get the location of objects in Containers relative to everything you want
But I assume all of these ways will return the left bottom point of the 3 D Object as it was referenced before we got these nice placement feature.
So what you can do is calculate the position by getting for example:
double d_CenterXloc = Object.location.x + (Object.size.x/2);
Hi, This method will not work in Z Rotated Objects
Use this, which is basically what sebastian was referencing to earlier
Object Obj="Your Object"; Vec3 Center=Obj.location+Obj.size/2*Vec3(1,-1,1); Center.z=Obj.location.z; return Center;
What do you mean it won't work around Z rotated objects, the center is the Z axis about which you are rotating an object, so that wouldn't matter.
10 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved