# 3D rotate a 2D object

## Recommended Posts

What am I not getting here:

2D object:

Oval(u4.x+D1x/2, u4.y+D1x/2,u4.x-D1x/2, u4.y-D1x/2);

I've tried these 4 functions to rotate my circle but no result..

result := SetEntityMatrix(LNewObj,0,0,0,45,-0,0);
Set3DRot(LNewObj,45,45,45,v1.x,v1.y,v1.z);
Rotate3D(0,0,45);
Move3DObj(LNewObj,0,0,-50cm);

Wasn't able to move the object around the Z-axis either.

What I'm trying to achieve is 3D cone see image ( yes I know there is a function for that but I'd like to use LOFTSURFACE instead since it has a straight part. )

the image has the square variant where it's easy for me to calculate the nurbs points with vectors. It has 3 nurbs rectangles I LOFT. Can't do it for circles since I won't ever understand a circle nurbs so sort of hoped creating 3 circles, turn them into nurbs and rotate them prior to lofting.

Edited by hippothamus

2D objects are in the screen plane by default. To answer your question directly, use SetPlanarRef to convert your object to planar and then 3D rotate, or define a rotated working plane, and set the circle to lie on that plane.

However, if you're lofting, first convert the circle to NURBS ( ConvertToNURBS() ) and then rotate. You may need to use SetPlanarRefIDToGround to make sure your rotation is correct if you run your script in a non-top view.

-Josh

Wouter,

???I'm not sure about the Lofting part of your problem, but creating an OVAL on a 3D plane can be done as follows.

Oval(u4.x+D1x/2, u4.y+D1x/2, u4.x-D1x/2, u4.y-D1x/2);

SetObjectVariableBoo(LNewObj, 1160, False);?????????????{ False = LayerPlane }

boo := SetEntityMatrix(LNewObj,???PlaneCenX, PlaneCenY, PlaneCenZ,???PlaneRotX, PlaneRotY, PlaneRotZ);

???SetObjectVariableBoo() will force the Oval to be on the Layer Plane with the center at u4. SetEntityMatrix() will move it to a 3D plane whose center is at PlaneCenXYZ with the plane rotated by PlaneRotXYZ. The oval's center will be at u4 in the relative coordinates of the new plane.

???This doesn't answer your question fully about Lofting, but it does define how to move 2D objects onto an arbitrary 3D plane, except for 2D Symbols. (The NV engineers do not follow the same rules when they create the Entity Matrix for a planar 2D Symbol.)

???I'll leave it to you to try to do the Loft at this point. Please write back and let us know if it works.

???One caveat - if the User Origin is shifted, so will be the 3D plane's origin. It may be easiest to reset the User Origin, create your planar object, then reshift the User Origin.

Raymond

Wouter,

???I'm not sure about the Lofting part of your problem, but creating an OVAL on a 3D plane can be done as follows.

Oval(u4.x+D1x/2, u4.y+D1x/2, u4.x-D1x/2, u4.y-D1x/2);

SetObjectVariableBoo(LNewObj, 1160, False);?????????????{ False = LayerPlane }

boo := SetEntityMatrix(LNewObj,???PlaneCenX, PlaneCenY, PlaneCenZ,???PlaneRotX, PlaneRotY, PlaneRotZ);

I've tried SetObjectVariableBoo(LNewObj, 1160, False); before but for some reason that doesn't work here.

SetPlanarRef(h,-1); Does work which is weird since from what I read both should do the same.

Anyway, I managed to convert it to 3D and rotate it, the weird thing is that when I rotate them on anything besides the X-axis, it will shift away as shown in the following picture:

u2:=UnitVec(u1);
u3:=v1-u2*D1;
u4:=v1-u2*D1*2;
BEGINGROUP;

Oval(v1.x+D1/2, v1.y+D1/2,v1.x-D1/2, v1.y-D1/2);
Convert2Dinto3D(LNewObj);
result := SetEntityMatrix(LNewObj, v1.x,v1.y,v1.z,90,-0,0);
NURBSHd:=ConvertToNURBS(LNewObj,FALSE);

Oval(u3.x+D1/2, u3.y+D1/2,u3.x-D1/2, u3.y-D1/2);
Convert2Dinto3D(LNewObj);
result := SetEntityMatrix(LNewObj, u3.x,u3.y,u3.z,90,-0,0);
NURBSHd:=ConvertToNURBS(LNewObj,FALSE);

Oval(u4.x+D1x/2, u4.y+D1x/2,u4.x-D1x/2, u4.y-D1x/2);
Convert2Dinto3D(LNewObj);
result := SetEntityMatrix(LNewObj, u4.x,u4.y,u4.z,90,-0,0);
NURBSHd:=ConvertToNURBS(LNewObj,FALSE);

Second part of the picture has

result := SetEntityMatrix(....,90,-0,90);

Edited by hippothamus

Why so complicated ? Did you try starting with a sweep?

Peter

Can't imagine this trough a sweep ?

Also, the direction of the incoming and outgoing pipe can be different, so stuff has to be calculated by vectors.

I managed to get rid of the offset by multiplying the Z-factor with the distance to the originpoint.

The 3D Shape posted 10/29/13 8:57am is easily swept ...

Peter

If not a rectangle I have to admit a sweep would be a better solution.

Can you post Convert2Dinto3D()?

I think your issue is that the first step of the procedure should be SetPlanarRefIDToGround, otherwise you are rotating with respect to the current view.

-Josh

Can you post Convert2Dinto3D()?

I think your issue is that the first step of the procedure should be SetPlanarRefIDToGround, otherwise you are rotating with respect to the current view.

-Josh

Convert2Dinto3D just does SetPlanarRef.

I've tested SetPlanarRefIDToGround before but didn't notice any difference.

I've added a sweep now, but only if there is no angle between the 2 pipes, reason shown in picture. It does use a lot of less code so thanks for mentioning it.

How do I reverse the circular cross sections ? Sometimes the loft surface does weird stuff as in this picture. If no solution I'll split it into 2 lofts

Edited by hippothamus

The middle circle appears to have it's radial axis rotated 90? CW about the circle's centre origin. If this is not clear to you take a circle and change the 360? in the OIP to 180. Now do a 2nd circle but rotate it 90? before changing to 180?. The start point of the arc is the circle's radial origin.

The sweep definition is connecting the radial/circumference origins of the three circles then moves onto the next segment in the rotation about the circle's centre origin.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×