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?
Solved! Go to Solution.
Solved by xiaodong_liang. Go to Solution.
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.
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);
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.
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>>"
Can't find what you're looking for? Ask the community or share your knowledge.