Using this code snippet I create a viewpoint for the current view.:
internal static Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
internal static void CreateViewpoint()
{
Viewpoint curentVievpoint = doc.CurrentViewpoint.Value;
SavedViewpoint newViewpoint = new SavedViewpoint(curentVievpoint);
newViewpoint.DisplayName = "_View";
doc.SavedViewpoints.AddCopy(newViewpoint);
}
How to pass the last saved viewpoint to "lastViewpoint"?
internal static void GoToLastCreatedViewpoint()
{
Viewpoint lastViewpoint = new Viewpoint();
doc.CurrentViewpoint.CopyFrom(lastViewpoint);
}
I tried to represent "lastViewpoint" as SavedViewpoint but failed.
Also this code adds redlineText to CurentViewpoint
internal static void CreateViewpoint()
{
Viewpoint curentVievpoint = doc.CurrentViewpoint.Value;
SavedViewpoint newViewpoint = new SavedViewpoint(curentVievpoint);
newViewpoint.DisplayName = "_Вид";
doc.SavedViewpoints.AddCopy(newViewpoint);
var viewpoints = doc.SavedViewpoints;
int newIndex = viewpoints.Value.Count - 1;
SavedViewpoint viewpointCopy = viewpoints.Value[newIndex].CreateCopy() as SavedViewpoint;
Point2D point2D = new Point2D(155, 830);
var redlineText = new LcOpRedlineText(textComment, ScreenToCameraSpace(point2D));
redlineText.SetLineThickness(5);
redlineText.SetLineColor(Color.White);
viewpointCopy.Redlines.Add(redlineText);
viewpoints.ReplaceWithCopy(newIndex, viewpointCopy);
SavedItem item = doc.SavedViewpoints.Value[newIndex];
SavedViewpoint savedViewpoint = item as SavedViewpoint;
Viewpoint viewpoint = savedViewpoint.Viewpoint;
doc.SavedViewpoints.CurrentSavedViewpoint = item;
}