Hi @T52K-BIB ,
Please review the following code.
This code searches for a viewpoint with a specific name. If the viewpoint is found, it creates a copy of the existing viewpoint, updates its attribute values, and replaces the original viewpoint with the modified version. If the viewpoint does not already exist, it creates a new viewpoint and sets the values for "Hide/Required" and "Override Appearance" saved attributes.
var state = ComApiBridge.State;
InwSavedViewsColl savedViews = state.SavedViews();
string viewPointName = "Your View Point Name Here...";
int index = Application.ActiveDocument.SavedViewpoints.Value.IndexOfDisplayName(viewPointName);
if(index<0)
{
//Add New Viewpoint
InwOpView inwOpView = (InwOpView)state.ObjectFactory(nwEObjectType.eObjectType_nwOpView, null, null);
inwOpView.ApplyHideAttribs = false;
inwOpView.ApplyMaterialAttribs = true;
inwOpView.name = viewPointName;
inwOpView.anonview = (InwOpAnonView)state.CurrentView;
savedViews.Add(inwOpView);
}
else
{
//Modify Existing Viewpoint
InwOpView inwOpView = (InwOpView)state.ObjectFactory(nwEObjectType.eObjectType_nwOpView, null, null);
inwOpView.ApplyHideAttribs = true;
inwOpView.ApplyMaterialAttribs = false;
var current_viewpoint = (InwNvViewPoint2)((InwOpAnonView)state.CurrentView).ViewPoint.Copy();
inwOpView.anonview.ViewPoint = current_viewpoint;
inwOpView.name = viewPointName;
index++;
state.SavedViews().Replace(index, inwOpView);
}
Naveen Kumar T
Developer Technical Services
Autodesk Developer Network