View Full Version : Acad & VB.Net how can I change the 2D plan view to a Iso?
RMS
7th Jun 2010, 04:44 am
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
BIGAL
8th Jun 2010, 03:47 am
Vpoint 1,1,1
SEANT
8th Jun 2010, 08:40 am
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()
RMS
9th Jun 2010, 11:49 pm
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!
Kerry Brown
10th Jun 2010, 12:15 am
Editor.ActiveViewportId property is only available for Acad2009 or later
SEANT
10th Jun 2010, 12:36 am
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.CurrentViewportTableR ecordId, 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
RMS
10th Jun 2010, 01:25 am
Editor.ActiveViewportId property is only available for Acad2009 or later
I was kinda thinking that too but was not sure.......
plan b
RMS
12th Jun 2010, 05:11 pm
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.CurrentViewportTableR ecordId, 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.Edit or
Dim vtr As ViewTableRecord = ed.GetCurrentView()
Dim newVtr As ViewTableRecord = vtr
newVtr.ViewDirection = New Vector3d(1, -1, 1)
ed.SetCurrentView(newVtr)
' close Iso mode
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.