Hi all,
I’m trying to adjust the plot size of my layouts using Dynamo + Python. There seems to be lots of different code available for this online but I just can’t get it to work on my file.
This is the current code I’m using
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
pageSize = "ANSI_B_(11.00_x_17.00_Inches)"
styleSheet = "monochrome.ctb"
device = "DWF6 ePlot.pc3"
name = "FinalLayout"
lm = LayoutManager.Current
id = lm.GetLayoutId(name)
lay = t.GetObject(id, OpenMode.ForWrite)
with PlotSettings(lay.ModelType) as ps:
ps.CopyFrom(lay)
psv = PlotSettingsValidator.Current
devs = psv.GetPlotDeviceList()
if (devs.Contains(device)):
psv.SetPlotConfigurationName(ps, device, None)
psv.RefreshLists(ps)
mns = psv.GetCanonicalMediaNameList(ps)
if (mns.Contains(pageSize)):
psv.SetCanonicalMediaName(ps, pageSize)
ssl = psv.GetPlotStyleSheetList()
if (ssl.Contains(styleSheet)):
psv.SetCurrentStyleSheet(ps, styleSheet);
upgraded = False
if (not lay.IsWriteEnabled):
lay.UpgradeOpen()
upgraded = True
lay.CopyFrom(ps)
if (upgraded):
lay.DowngradeOpen()
It runs fine without errors but I’m just not seeing anything happen.
Any advice would be much appreciated!!