Jump to content

VB.Net question - active viewport in a layout


Tipo166

Recommended Posts

Hello All, couple questions.

1) Am I posting to the correct forum? Is there a .Net forum here? If so, please feel free to point me there.

2) I want to make a specific viewport in a specific layout tab the "active space" and I am writing this in VB.Net. I have done this with VBA but .Net is is a much more complicated ball of wax which I am currently learning. I have been able to actually "get" the viewport I want but can not find the class/method/property to make it the "active space"? Any pointers?

'*************************************** find viewport and activate **************************************
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Try
Dim layoutManager__1 As LayoutManager = LayoutManager.Current
layoutManager__1.CurrentLayout = "Floor Plan 100"
Dim vpXdim As String = ("18") 'viewport desired's CenterPoint X value
Dim layout As Layout = TryCast(myTrans.GetObject(layoutManager__1.GetLayoutId _
("Floor Plan 100"), OpenMode.ForRead), Layout)
Dim objectIdCollection As ObjectIdCollection = layout.GetViewports()
For Each VportObjId As ObjectId In objectIdCollection
Dim Vport As Viewport = DirectCast(myTrans.GetObject(VportObjId, OpenMode.ForWrite), Viewport)
Dim X As String = Vport.CenterPoint.X.ToString
If vpXdim = X Then 'center points are the same > this is desired viewport 
MsgBox("this is the viewport we want.....")
'Vport As AutoDesk.AutoCAD.DataBaseServices.Viewport
'Public Property ActiveViewport()As AutoDesk.AutoCAD.Interop.AcadViewport

Exit For
End If
Next
Catch ex As System.Exception
ed.WriteMessage(vbLf & ex.Message)
ed.WriteMessage(vbLf & ex.StackTrace)
End Try
'*********************************************************************************************************


Have tried AutoDesk discussion group and AUGI and all over google with no real luck. Thoughts?

Thanks,

Trent

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...