Hi,
I am new to .Net Api and I am using VB.Net. I am trying to set some layout properties for my drawing. But most of the properties are not getting updated to the layout.
- Paper units not updated to millimeters.
- Standard scale is not set. It always checks 'scale to fit'.
- Plot type is not set to Layout. It always shows Extents.
- Also how can I change orientation to Landscape or Portrait?
I am not sure what I am doing wrong. The code I am using is listed below. Please give your suggesstions.
Thanks,
Bala
Code:
Public Sub SetLayout()
Try
MyBase.SetScaleFactor()
Dim Doc As Document = Acad.DocumentManager.MdiActiveDocument
Dim DB As Database = Doc.Database
Dim TR As Transaction = Doc.TransactionManager.StartTransaction()
Dim ObjLayoutManager As LayoutManager = LayoutManager.Current
Dim LayoutID As ObjectId = ObjLayoutManager.GetLayoutId("Layout1")
Dim ObjLayout As Layout = CType(TR.GetObject(LayoutID, OpenMode.ForRead), Layout)
Dim PlInfo As PlotInfo = New PlotInfo()
PlInfo.Layout = LayoutID
Dim PlSet As PlotSettings = New PlotSettings(ObjLayout.ModelType)
'PlSet.CopyFrom(ObjLayout)
Dim PlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
'PlSetVdr.RefreshLists(PlSet)
PlSetVdr.SetPlotType(PlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout)
PlSetVdr.SetPlotPaperUnits(PlSet, PlotPaperUnit.Millimeters)
PlSetVdr.SetPlotConfigurationName(PlSet, "None", "ISO_A2_(594.00_x_420.00_MM)")
PlSetVdr.SetUseStandardScale(PlSet, True)
PlSetVdr.SetStdScaleType(PlSet, StdScaleType.StdScale1To1)
'PlSetVdr.SetZoomToPaperOnUpdate(PlSet, True)
'PlSetVdr.RefreshLists(PlSet)
PlInfo.OverrideSettings = PlSet
Dim pInfoValid As New PlotInfoValidator
pInfoValid.Validate(PlInfo)
ObjLayout.UpgradeOpen()
ObjLayout.CopyFrom(PlSet)
TR.Commit()
TR.Dispose()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.Message)
End Try
End Sub