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

Create Named View with specific parameters

1 REPLY 1
Reply
Message 1 of 2
EddieSaez
366 Views, 1 Reply

Create Named View with specific parameters

I've been reading up on creating Named Views in AutoCAD Help facilities and am wanting to know if specific parameters can be set for this named view.
Paramaters such as VisualStyle, Background (set to solid with white 255 as the base color)

This is from the help files...

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
 
<CommandMethod("CreateNamedView")> _
Public Sub CreateNamedView()
  '' Get the current database
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim acCurDb As Database = acDoc.Database
 
  '' Start a transaction
  Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
      '' Open the View table for read
      Dim acViewTbl As ViewTable
      acViewTbl = acTrans.GetObject(acCurDb.ViewTableId, OpenMode.ForRead)
 
      '' Check to see if the named view 'View1' exists
      If (acViewTbl.Has("View1") = False) Then
          '' Open the View Table for write
          acViewTbl.UpgradeOpen()
 
          '' Create a new View table record and name the view "View1"
          Dim acViewTblRec As ViewTableRecord = New ViewTableRecord()
          acViewTblRec.Name = "View1"
 
          '' Add the new View table record to the View table and the transaction
          acViewTbl.Add(acViewTblRec)
          acTrans.AddNewlyCreatedDBObject(acViewTblRec, True)
 
          '' Set 'View1' current
          acDoc.Editor.SetCurrentView(acViewTblRec)
 
          '' Commit the changes
          acTrans.Commit()
      End If
 
      '' Dispose of the transaction
  End Using
End Sub

 Thanks in advance.

Tags (1)
1 REPLY 1
Message 2 of 2
Balaji_Ram
in reply to: EddieSaez

Hi,

 

For the Background, please refer to "CreateBackground" and "RemoveBackground" methods in this blog post :

http://through-the-interface.typepad.com/through_the_interface/2009/02/smoothly-transitioning-betwee...

 

For setting other view parameters including visual style, the following blog post should be of some help :

 

http://adndevblog.typepad.com/autocad/2014/02/3dwalk-through-an-autocad-model.html

http://adndevblog.typepad.com/autocad/2012/09/how-to-mimic-command-vpoint-rotate-with-the-net-api.ht...

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

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