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

Switching layouts with .NET

1 REPLY 1
Reply
Message 1 of 2
ti
Participant
222 Views, 1 Reply

Switching layouts with .NET

Hi,

I have a simple form with a combobox that I fill with all layout names ;

_
Public Sub sm()
Dim fmain As New main
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tr As Transaction = db.TransactionManager.StartTransaction()

Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)

fmain.LayoutBox.Items.Clear()
For Each btrid As ObjectId In bt
Dim btr As BlockTableRecord = tr.GetObject(btrid, OpenMode.ForRead)
If btr.IsLayout Then
Dim lo As Layout = tr.GetObject(btr.LayoutId, OpenMode.ForRead)
fmain.LayoutBox.Items.Add(lo.LayoutName)
End If
Next

fmain.Show()
End Sub

I want to switch layouts from my combobox when the selectedtext changes, the following code doesn't seem to work ;
LayoutManager.Current.CurrentLayout = LayoutBox.Text

Can anyone help ?
Thanks
1 REPLY 1
Message 2 of 2
greggr
in reply to: ti

Well, this code has worked for me in the past:




Dim lMan As LayoutManager = LayoutManager.Current



lMan.CurrentLayout = LayoutBox.Text





Is the code you pasted in a button click event on the form? If so, this could be the probem. Try adding a Sub in the main class with a command method. I always do this anyway, and the forms only send strings to execute to the drawing. That way, the user has the option of using the command line instead of the UI you provide - but in your case this may not be a viable solution.

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