Setting the center of rotation of a 3DView through API

Setting the center of rotation of a 3DView through API

carolina.machado
Advocate Advocate
684 Views
1 Reply
Message 1 of 2

Setting the center of rotation of a 3DView through API

carolina.machado
Advocate
Advocate

Hello!

 

I am creating a 3D View with a Section Box through API. But even setting the origin of the section box to the desired point, after the view is created, when I try to rotate it using the View Cube, the origin of rotation is not the point that I have settled as the center of the section box.

Is there any way that I can set the center of rotation?

 

Thanks in advance,

Carolina

0 Likes
685 Views
1 Reply
Reply (1)
Message 2 of 2

buihaviet
Participant
Participant

Hi Carolina,

 

In 3D view object the origin of rotation is stored in ViewOrientation3D.EyePosition Property.
So that what you need to do is set this property to your desired point.

Following is the example code I have made it works.

 

 

//Get the active view
View view = doc.ActiveView;
//Check when active view is 3D view if(view is View3D) { View3D view3d = view as View3D;
//Get the current ViewOrientation3D object ViewOrientation3D currentvo3d = view3d.GetOrientation();
//Create new ViewOrientation3D object with EyePosition is adjusted to XYZ.Zero point (you can change to your desired point) ViewOrientation3D newvo3d = new ViewOrientation3D(XYZ.Zero,currentvo3d.UpDirection,currentvo3d.ForwardDirection);
//set the new ViewOrientation3D object to your 3D view view3d.SetOrientation(newvo3d); }

Hope it help.


Best Regards,

Viet.