Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

distance from viewer to that point...

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
bnn987654321
1177 Views, 6 Replies

distance from viewer to that point...

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?

6 REPLIES 6
Message 2 of 7

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.

Message 3 of 7
bnn987654321
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);

 

Message 4 of 7

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.

 

 

 

Message 5 of 7

Get it!

Thank u!

Message 6 of 7
bhanu425
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>>"

 

Message 7 of 7
xiaodong_liang
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report