Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

cast a InwOpAnonView as a InwOpView

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
652 Views, 2 Replies

cast a InwOpAnonView as a InwOpView

I need to know how to cast a InwOpAnonView as a InwOpView so that I can Add a View to SavedViews and use ApplyView.

 

using nw = NavisworksIntegratedAPI9;
...

nw.InwOpState4 _state = axnwControlMDI1.APIState as nw.InwOpState4;
//copy current view
var view= _state.CurrentView.Copy() as nw.InwOpAnonView;

//how then do I add to SavedViews?
//_state.SavedViews().Add(view as nw.InwOpView); //InwOpView cannot be cast from a InwOpAnonView

//How do I apply the View?
//_state.ApplyView(view as nw.InwOpView); //InwOpView cannot be cast from a InwOpAnonView

 

2 REPLIES 2
Message 2 of 3
saikat
in reply to: Anonymous

Hi:

 

Does the following code help?

 

InwSavedViewsColl savviews = oState.SavedViews();
InwOpView sv = (InwOpView)oState.ObjectFactory(nwEObjectType.eObjectType_nwOpView, null, null);
sv.name = "MySavedView";
sv.anonview = (InwOpAnonView)oState.CurrentView;
savviews.Add(sv);

 

 

cheers

Saikat

 



Saikat Bhattacharya
Senior Manager - Technology Consulting
Message 3 of 3
Anonymous
in reply to: saikat

Yes, it does indeed. Thanks Saikat

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report