Continued with last post, the following codes demonstrate how to set align up, set point at and rotate the camera.
// set up vector private void changeUp() { Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; // make a copy of current viewpoint Viewpoint oCurrVCopy = oDoc.CurrentViewpoint.CreateCopy(); // a new up vector. e.g. Y + Vector3D oNewUpVec = new Vector3D(0, 1, 0); oCurrVCopy.AlignUp(oNewUpVec); // update current viewpoint oDoc.CurrentViewpoint.CopyFrom(oCurrVCopy); } private void rotateCamera() { Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; // Make a copy of current viewpoint Viewpoint oCurrVCopy = oDoc.CurrentViewpoint.CreateCopy(); // set the axis we will rotate around (¨Zú:o0°,0°,1±)? UnitVector3D odeltaA = new UnitVector3D(0, 0, 1); // Create delta of Quaternion: axis is Z, // angle is 45 degree Rotation3D delta = new Rotation3D(odeltaA, 3.14 / 4); // multiply the current Quaternion with the delta , // get the new Quaternion oCurrVCopy.Rotation = MultiplyRotation3D(delta,oCurrVCopy.Rotation ); // Update current viewpoint oDoc.CurrentViewpoint.CopyFrom(oCurrVCopy); }

Leave a Reply