Replies: 2 comments 8 replies
-
|
does this work for you? def add_vport(layout_id: Db.ObjectId):
man = Ap.LayoutManager()
man.setCurrentLayoutId(layout_id)
sym = Db.SymUtilServices()
btrid = sym.blockPaperSpaceId(layout_id.database())
btr = Db.BlockTableRecord(btrid, Db.OpenMode.kForWrite)
vport = Db.Viewport()
vport.setWidth(100.0)
vport.setHeight(100.0)
vport.setCenterPoint(Ge.Point3d(50.0, 50.0, 0.0))
btr.appendAcDbEntity(vport) |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
try setting the working database def add_vport(layout_id: Db.ObjectId):
wdb = Db.AutoWorkingDatabase(layout_id.database())
man = Ap.LayoutManager()
man.setCurrentLayoutId(layout_id)
sym = Db.SymUtilServices()
btrid = sym.blockPaperSpaceId(layout_id.database())
btr = Db.BlockTableRecord(btrid, Db.OpenMode.kForWrite)
vport = Db.Viewport()
vport.setWidth(100.0)
vport.setHeight(100.0)
vport.setCenterPoint(Ge.Point3d(50.0, 50.0, 0.0))
btr.appendAcDbEntity(vport) |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How do I correctly add a viewport to a layout?
The code below causes incorrect behavior; it always adds one additional viewport (I open the file without viewports, add one, save, open, and there are two). I noticed that after adding a viewport, the
.getViewportArray()method returns an empty list.Beta Was this translation helpful? Give feedback.
All reactions