Jump to content

Acad & VB.Net how can I change the 2D plan view to a Iso?


RMS

Recommended Posts

Anyone have the VB.net command to change the current plan view model space to any Isometric one; but still in the model space. I searched all over with no luck, I must not be using the right key words.....thanks for any help!

 

Rob

Link to comment
Share on other sites

And in .NET terms:

 

A ViewportTableRecord object can be acquired from Database.CurrentViewportTableRecordId (via transaction).

 

The view can be modified similar to the vpoint command:

ViewportTableRecord.ViewDirection = New Vector3d(1.0, 1.0, 1.0)

(commit transaction)

 

Regen the view with:

Editor.UpdateTiledViewportsFromDatabase()

Link to comment
Share on other sites

And in .NET terms:

 

A ViewportTableRecord object can be acquired from Database.CurrentViewportTableRecordId (via transaction).

 

The view can be modified similar to the vpoint command:

ViewportTableRecord.ViewDirection = New Vector3d(1.0, 1.0, 1.0)

(commit transaction)

 

Regen the view with:

Editor.UpdateTiledViewportsFromDatabase()

 

Thanks for the tip, so I am getting close BUT I have this error, is it that I am not using AutoCAD 2011 and a newer .net framework? Or am I missing a reference?

 

Thanks!

error.GIF

Link to comment
Share on other sites

The .NET API has changed quite a bit since AutoCAD 2005 (version listed in your profile). Consequently, the sample shown below may not work.

 

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.Geometry

Imports Autodesk.AutoCAD.ApplicationServices

 

 

    <CommandMethod("IV")> _
Public Sub IsoView()
       Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
       Dim db As Database = HostApplicationServices.WorkingDatabase
       If (db.TileMode = True) Then
           Using tran As Transaction = db.TransactionManager.StartTransaction()
               Dim vpr As ViewportTableRecord = DirectCast(tran.GetObject(db.CurrentViewportTableRecordId, OpenMode.ForWrite), ViewportTableRecord)
               If vpr IsNot Nothing Then
                   Dim v3d As Vector3d = New Vector3d(1.0, -1.0, 1.0)
                   vpr.ViewDirection = v3d
               End If
               tran.Commit()
           End Using
           Doc.Editor.UpdateTiledViewportsFromDatabase()
       End If
   End Sub

Link to comment
Share on other sites

Editor.ActiveViewportId property is only available for Acad2009 or later

 

I was kinda thinking that too but was not sure.......

 

plan b

Link to comment
Share on other sites

The .NET API has changed quite a bit since AutoCAD 2005 (version listed in your profile). Consequently, the sample shown below may not work.

 

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.Geometry

Imports Autodesk.AutoCAD.ApplicationServices

 

 

    <CommandMethod("IV")> _
Public Sub IsoView()
       Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
       Dim db As Database = HostApplicationServices.WorkingDatabase
       If (db.TileMode = True) Then
           Using tran As Transaction = db.TransactionManager.StartTransaction()
               Dim vpr As ViewportTableRecord = DirectCast(tran.GetObject(db.CurrentViewportTableRecordId, OpenMode.ForWrite), ViewportTableRecord)
               If vpr IsNot Nothing Then
                   Dim v3d As Vector3d = New Vector3d(1.0, -1.0, 1.0)
                   vpr.ViewDirection = v3d
               End If
               tran.Commit()
           End Using
           Doc.Editor.UpdateTiledViewportsFromDatabase()
       End If
   End Sub

 

OK, I am using acad 2009 now and the above code is working.

 

IF anyone is using acad 2006 - 2008 this will work to change current model view to an Isometric one. Got this from a site in China

 


           ' set iso mode

           Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
           Dim vtr As ViewTableRecord = ed.GetCurrentView()
           Dim newVtr As ViewTableRecord = vtr
           newVtr.ViewDirection = New Vector3d(1, -1, 1)
           ed.SetCurrentView(newVtr)

           ' close Iso mode

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...