I want to get and set viewpoint value using COM API.

Anonymous

I want to get and set viewpoint value using COM API.

Anonymous
Not applicable

I am trying to make an independent programme (NOT PLUG-IN) taking a current viewpoint's xyz coordinates (Position and Look At in NW-Viewpoint Tab-Camera) and applying new-user-defined coordinate values (New Position and New Look At), by using COM API.

 

And I have reached this much as I could get the xyz coordinates of current viewpoint and current target point (Current View X,Y,Z + GetViewDir().data1,2,3 * FocalDistance), and apply new textbox's text value to each CurrnetView.ViewPoint.Camera.Position.data1,2,3 of an InwOpState,

 

BUT COULD NOT TO NEW LOOK AT whose code is like below.

 

using NavisworksAutomationAPI11;

using NavisworksIntegratedAPI11;

 

InwOpState10 NWState;

 

NWState.CurrentView.ViewPoint.Camera.Position.data1 = Convert.ToDouble(textBox1.Text); //Applied
NWState.CurrentView.ViewPoint.Camera.Position.data2 = Convert.ToDouble(textBox2.Text); //Applied
NWState.CurrentView.ViewPoint.Camera.Position.data3 = Convert.ToDouble(textBox3.Text); //Applied

 

NWState.CurrentView.ViewPoint.Camera.GetViewDir().data1 = Convert.ToDouble(textBox4.Text); //NOT Applied
NWState.CurrentView.ViewPoint.Camera.GetViewDir().data2 = Convert.ToDouble(textBox5.Text); //NOT Applied
NWState.CurrentView.ViewPoint.Camera.GetViewDir().data3 = Convert.ToDouble(textBox6.Text); //NOT Applied

 

I am kinda Beginner in Programming and API, so I need helps from GURUs LIKE YOU!!

 

Condition :

Win7 64bit, NW Sim 2014,  

0 Likes
Reply
1,096 Views
2 Replies
Replies (2)

Anonymous
Not applicable

Form1.jpg

0 Likes

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

GetViewDir is a method that returns a value only. Wen you check API document, you can find some declarations. e.g. 

 

To modify a view direction, you could try calling the method PointAt with the new target point. And call AlignUp with the correct up vector you wanted to set.

 

getv.pngpos.png

0 Likes