Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Enable hidden attribute for SavedViewpoint

T52K-BIB
Enthusiast

Enable hidden attribute for SavedViewpoint

T52K-BIB
Enthusiast
Enthusiast

I have checked some post regarding the enable hidden attribute for the viewpoint which is possible to do in COMAPI  but while i try update DisplayName for the viewpoint is shows error.

 

I would like save the viewpoint and enable the both attribute (hidden and override)

 

0 Likes
Reply
Accepted solutions (1)
185 Views
3 Replies
Replies (3)

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

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

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @T52K-BIB ,


To update display name of saved viewpoint, please take a look at this below code

 

 Document doc;
 doc.SavedViewpoints.EditDisplayName(savedItem, "New Display Name");

 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

T52K-BIB
Enthusiast
Enthusiast

Thanks @naveen.kumar.t  its working.

0 Likes