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

Layout settings

3 REPLIES 3
Reply
Message 1 of 4
bala1201
1485 Views, 3 Replies

Layout settings

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

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
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: bala1201

I haven't done much work in the area of Plotting or plot settings, but i
seem to recall that some plot settings are not stored in the layout, and are
set by AutoCAD when the plot command starts. In that case, you would need to
handle plot-related events to change the settings that are passed into the
event handlers.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6285505@discussion.autodesk.com...
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

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
Message 3 of 4
bala1201
in reply to: bala1201

Thanks for your reply.

The code works after doing the following modifications.
- Setting 'Tilemode' to 0, before calling this function.
- Changing the plot device to something other than 'None'. It did not accept 'None'.
- Calling 'RefreshLists'.

The modified code is listed below, so that it can be of useful to somebody

Regards,
Bala

Public Sub SetLayout()
Try
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)
Dim PlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current

PlSetVdr.RefreshLists(PlSet)
PlSetVdr.SetPlotConfigurationName(PlSet, "DWG To PDF.pc3", "ISO_expand_A2_(594.00_x_420.00_MM)")
PlSetVdr.SetPlotType(PlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout)
PlSetVdr.SetPlotPaperUnits(PlSet, PlotPaperUnit.Millimeters)
PlSetVdr.SetUseStandardScale(PlSet, True)
PlSetVdr.SetStdScaleType(PlSet, StdScaleType.StdScale1To1)

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
Message 4 of 4
hanchris
in reply to: bala1201

I have seen the mediaName wirtten in a similar format ("ISO_expand_A2_(594.00_x_420.00_MM)") in a bunch of sample programs, including Kean's (http://through-the-interface.typepad.com/through_the_interface/2007/09/driving-a-basic.html)

I thought at first this was just the old method, for pc3 Medianames (blog from 2007) or a custom method; but when I tried Kean's code it works with 2010, even thorough the Paper Size is displayed in a format similar to: "ANSI full bleed A (8.50 x 11.00 Inches)" and his uses a format similar to the above "ANSI_A_(8.50_x_11.00_Inches)".

My question is if the mediaName is not what is displayed, in the Plot menu or in Plotter Configuration Editor, then how can you find out the proper mediaName?

Thanks.

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