Navisworks API

Reply
Contributor
bnn987654321
Posts: 20
Registered: ‎10-14-2010
Message 1 of 7 (340 Views)
Accepted Solution

distance from viewer to that point...

340 Views, 6 Replies
05-31-2012 12:01 AM

Hi all,

I was setting a point using InwNvCamera.PointAt()

Now I need to set distance from viewer to that point.

Is there a way to do this?

ADN Support Specialist
xiaodong.liang
Posts: 1,264
Registered: ‎06-12-2011
Message 2 of 7 (334 Views)

Re: distance from viewer to that point...

06-04-2012 08:23 PM in reply to: bnn987654321

The camera provides position and view direction. It does not provide Target( Look At ). While

 

target = position + view direction * focal

 

Camera can set the PointAt, as you are doing.It changes the view direction, based on  the vector from current position to the new PointAt.

 

So, when you set PointAt, the position and focal do not change, while target changes.  So to set the distance, you just need to set InwNvViewPoint.FocalDistance.



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Contributor
bnn987654321
Posts: 20
Registered: ‎10-14-2010
Message 3 of 7 (319 Views)

Re: distance from viewer to that point...

06-10-2012 11:32 PM in reply to: bnn987654321

Thanks for your reply.

But I though that I asked the wrong question.

My question is how to zoom in/out to target after Camera set the PointAt?

 

Here is my program,and I would like to zoom in the column, just like attachments:

ComApi.InwOpState10 myState = ComApiBridge.ComApiBridge.State;

ComApi.InwOpAnonView myview = myState.CurrentView;

ComApi.InwNvViewPoint2 myviewpoint = (ComApi.InwNvViewPoint2)myview.ViewPoint;

ComApi.InwLPos3f mypos = myviewpoint.Camera.Position;

mypos.SetValue(0, 0, 0);

myviewpoint.Camera.PointAt(mypos);

 

ADN Support Specialist
xiaodong.liang
Posts: 1,264
Registered: ‎06-12-2011
Message 4 of 7 (312 Views)

Re: distance from viewer to that point...

06-10-2012 11:49 PM in reply to: bnn987654321

if you just need to zoom to object like the product does, ZoomInCurViewOnCurSel is the easiest way.

 

Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;

oDoc.CurrentSelection.CopyFrom(oColl); 

ComApiBridge.ComApiBridge.State.ZoomInCurViewOnCurSel();

 

 your code looks strange to me, why you get position values, set it to (0,0,0), and PointAt to (0,0,0) ? anyway, if you need to implement zoom yourself, you will need to  calculate the camera yourself. You can zoom to object by the product firstly, make a note of all its properties values and find how it creates a 'zoom to object'. And mimic the properties with your camera.

 

 

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Contributor
bnn987654321
Posts: 20
Registered: ‎10-14-2010
Message 5 of 7 (309 Views)

Re: distance from viewer to that point...

06-10-2012 11:55 PM in reply to: xiaodong.liang

Get it!

Thank u!

New Member
bhanu425
Posts: 1
Registered: ‎09-16-2013
Message 6 of 7 (142 Views)

How to get the focal distance

09-16-2013 07:22 AM in reply to: bnn987654321

I have used   .NET and ComAPI's   to get focal distance. but in both cases i am getting errors. Plz give me solution for finding focal distance.

 

These are my codes

-----> Using .NET API's

 

Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
Viewpoint oCurVP = oDoc.CurrentViewpoint;
 double oFocal = oCurVP.FocalDistance;

// in the above code i getting "FOCAL DISTANCE NOT SET" error.

 

-----> Using COM API's

 

ComApi.InwOpState10 state;
 state = Autodesk.Navisworks.Api.ComApi.ComApiBridge.State;
 Autodesk.Navisworks.Api.Interop.ComApi.InwNvViewPoint NvViewPoint = state.CurrentView.ViewPoint;
 oFocal1 = NvViewPoint.FocalDistance;

 

 //in the above code i getting "<<NAVISWORKS ERRORS - ELEMENT NOT PRESENT>>"

 

ADN Support Specialist
xiaodong.liang
Posts: 1,264
Registered: ‎06-12-2011
Message 7 of 7 (115 Views)

Re: How to get the focal distance

09-22-2013 07:16 PM in reply to: bhanu425
Hi bhanu425,

could you provide a small project which can demo the problem you hit? The code snippet is not helpful for diagnose what happened.


Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community