.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do you get the current view Name

5 REPLIES 5
Reply
Message 1 of 6
pfk
Enthusiast
1359 Views, 5 Replies

How do you get the current view Name

Hi - I would like to get the current AutoCAD View name in .NET.

 

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetCurrentView().Name always returns "", even when viewing a View with a name.

 

Thanks

5 REPLIES 5
Message 2 of 6
Ajilal.Vijayan
in reply to: pfk

Named Views are stored in ViewTable

ViewTable

Message 3 of 6
pfk
Enthusiast
in reply to: Ajilal.Vijayan

Thank you for your help.

 

However I need the name of the CURRENT active view.  How is this obtained pls?  Iterating through the ViewTable does not seem to provide this, and there is no link between the ViewTable and dwg.Editor.GetCurrentView();

 

Thanks

 

Paul

Message 4 of 6
Ajilal.Vijayan
in reply to: pfk

Looks like the Current View name stored anywhere.

Current view name changes to *Current* after switching to any view.

Maybe that could be the reason why its showing the blank name.

 

Also I am trying this code to get the CurrentItem Name.

http://through-the-interface.typepad.com/through_the_interface/2012/06/using-autocads-bindable-objec...

 

This line seems interesting

Add reference to WindowsBase.dll

Application.UIBindings.Collections.NamedViews.CurrentItem.GetProperties()

 

 

 

Message 5 of 6
norman.yuan
in reply to: pfk

The current view (ViewTableRecord object obtained from Editor.GetCurrentView()) does not have name.

 

ViewTableRecord is just a object that hold some geometric/dimension information on a view displayed by the editor. It can be saved into ViewTable. However, ViewTableRecord is not a view itself (View class represents a physical view in AutoCAD API), it is just a set of geometric/dimesion data that describes a instant moment of  a view. With saved ViewTableRecord, AutoCAD can create a View based on it.

 

View in AutoCAD is constantly changeing while AutoCAD is used. The ViewTableRecord returned by Editor.GetCurrentView() is just an non-database residing object that describe the current view, it does not have an ObjectId/Handle/name assigned. ViewTableRecord only needs name when it is to be added to ViewTable.

 

When you set a view to a saved view (a ViewTableRecord from ViewTable), AutoCAD simply set the cuurent view/display according to the view information holding by the ViewTableRecord.

 

So, if you need to know if current view returned by GetCurrentView() is the same as any of the saved ViewTableRecord in dimension, you might have to compare them by their geometry/dimesion, not by name, beause current view doe not have name (AutoCAD always give it a name "Current" to user when display it in AutoCAD UI.

Norman Yuan

Drive CAD With Code

EESignature

Message 6 of 6
pfk
Enthusiast
in reply to: norman.yuan

Thank you for the replies.

 

Comparing the GetCurrentView view to the ViewTableRecord is unfortunately not a viable solution.  Once the user has panned the camera, there is no way to match the GetCurrentView view to the Model View returned from the ViewTable iterator (via Target, or ViewDirection), because the GetCurrentView has been updated by the Pan, and the ViewTable record has not.

 

Paul

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost