Moving entity to particular coordinates

Moving entity to particular coordinates

Anonymous
Not applicable
1,209 Views
6 Replies
Message 1 of 7

Moving entity to particular coordinates

Anonymous
Not applicable

How can we move our entity to particular coordinates.

 

Like I have a 3dSolid with me, and now I want to move it to (20.0,40.0,0.0)

 

I have used transformby, but it moves my entity in relate to my present coordinates. I want my the centre of my to go at (20.0,40.0,0.0)

 

This is what I have tried

AcGeMatrix3d move;
AcGeVector3d vector(0, 0, height);
move.setTranslation(vector);
pSolid->transformBy(move);

I dont want relative movement of my entity but I want absolute movement.

 

Regards, 

0 Likes
Accepted solutions (1)
1,210 Views
6 Replies
Replies (6)
Message 2 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> Like I have a 3dSolid with me, and now I want to move it to (20.0,40.0,0.0)

What point of your 3D-Solid should be at this new coordinate? If your 3D-Solid is e.g. a box, then there are 8 corner points, 6 face-centers, which of them is it?

 

And if you know that point then evaluate it's current position, having that you can create a transfer vector from the current position to the new position.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 7

Matti72
Advocate
Advocate

Didn't you know the actual position?

 

If you have the actual position, than don't use the absolute new position as vector but the new position - the old position

 

(vec = NewPos - OldPos)

 

Than you have the relative Vector to go to the new absolute position... or get I your question wrong?

0 Likes
Message 4 of 7

Anonymous
Not applicable
I have a box whose centroid is placed at origin. Now I want to move the centroid of my box to point (20.0,40.0,20.0).

Can you show me how to do it?
0 Likes
Message 5 of 7

Anonymous
Not applicable
Hi Matti72,

I didnt get your point, how do I do it?

I have a box whose centroid is placed at origin. Now I want to move the centroid of my box to point (20.0,40.0,20.0).

Can you show me how to do it?
0 Likes
Message 6 of 7

Anonymous
Not applicable
Accepted solution

Hi Sandeep,

To move the solid at an absolute position, you first have to know its current position, if it's not the case, you have to "recompute" it. Interrestingly, solids don't have any position information (OCS for instance). So, I think that the best way is to get its centroid is to call AcDb3dSolid::getMassProp (you'll see a "centroid" output parameter).

Since you have this centroid, you'll have to transform you solid like this (pseudo-code):

 

solid->transformBy(-centroid.asVector()+AcGeVector3d(20.0,40.0,0.0));

I think it should do the trick.

 

let me know

 

 

 

 

Message 7 of 7

Anonymous
Not applicable
Thanks so much Loic

It did the trick..
0 Likes