.NET

Reply
Active Contributor pfk
Active Contributor
pfk
Posts: 35
Registered: ‎02-11-2013
Message 1 of 6 (229 Views)

How do you get the current view Name

229 Views, 5 Replies
10-19-2013 12:16 AM

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

Valued Mentor
Ajilal.Vijayan
Posts: 447
Registered: ‎01-12-2008
Message 2 of 6 (202 Views)

Re: How do you get the current view Name

10-19-2013 11:17 AM in reply to: pfk

Named Views are stored in ViewTable

ViewTable

Active Contributor pfk
Active Contributor
pfk
Posts: 35
Registered: ‎02-11-2013
Message 3 of 6 (183 Views)

Re: How do you get the current view Name

10-20-2013 03:37 AM 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

Valued Mentor
Ajilal.Vijayan
Posts: 447
Registered: ‎01-12-2008
Message 4 of 6 (169 Views)

Re: How do you get the current view Name

10-20-2013 06:32 AM 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()

 

 

 

*Expert Elite*
norman.yuan
Posts: 1,049
Registered: ‎04-27-2009
Message 5 of 6 (163 Views)

Re: How do you get the current view Name

10-20-2013 07:15 AM 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.

Active Contributor pfk
Active Contributor
pfk
Posts: 35
Registered: ‎02-11-2013
Message 6 of 6 (139 Views)

Re: How do you get the current view Name

10-20-2013 05:46 PM 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!