- 积分
- 312
- 明经币
- 个
- 注册时间
- 2008-6-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
如何在不将指定布局设置为当前布局的情况下(布局切换起来速度比较慢),在该布局上新建视口?
通过第一个sub创建布局,然后由第二个sub在该布局上创建视口。可是,可以由第二个sub在第一个过程中生成的布局上画直线等对象,但无法创建创建视口,为何?又试了一下可以通过第二个sub在已经存在的指定布局(非程序生成的)上创建视口,貌似同一个程序运行过程中生成的布局只生成在内存中,而没有生成在记录中。请高人指点。一下是部分代码:
Public Sub CreatLayouts(ByVal VPNo As Double, ByRef acLytBTRId As ObjectId)
Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim layoutId As ObjectId
Dim acLayout As Layout
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acLayoutMgr As LayoutManager
acLayoutMgr = LayoutManager.Current
layoutId = acLayoutMgr.CreateLayout("VP" & VPNo)
acLayout = Trans.GetObject(layoutId, OpenMode.ForWrite)
acLytBTRId = acLayout.BlockTableRecordId()
acTrans.Commit()
End Using
End Sub
Public Sub CreateFloatingViewport(ByVal ViewPortParab As VPpara, ByVal Vwidth As Double, ByVal Vheight As Double, _
ByVal BkTbRdId As ObjectId, ByVal VP_layer As ObjectId)
Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim acLayout As Layout
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(BkTbRdId, OpenMode.ForWrite)
Dim LineEnt As New Line(New Point3d(0, 500 / 2, 0.0), New Point3d(0, -500 / 2, 0.0))
acBlkTblRec.AppendEntity(LineEnt)
acTrans.AddNewlyCreatedDBObject(LineEnt, True)
Dim acVport As Viewport = New Viewport()
acVport.SetDatabaseDefaults()
acVport.CenterPoint = New Point3d(Vwidth / 2, Vheight / 2, 0)
acVport.Width = Vwidth
acVport.Height = Vheight
acVport.TwistAngle = ViewPortParab.Slopeangle
acVport.ViewCenter = New Point2d(ViewPortParab.x_coordinate * Math.Cos(-ViewPortParab.Slopeangle) + ViewPortParab.y_coordinate * Math.Sin(-ViewPortParab.Slopeangle), -ViewPortParab.x_coordinate * Math.Sin(-ViewPortParab.Slopeangle) + ViewPortParab.y_coordinate * Math.Cos(-ViewPortParab.Slopeangle))
acVport.ViewHeight = Vheight * ViewPortParab.Plotscale
acVport.LayerId = VP_layer
acBlkTblRec.AppendEntity(acVport)
acTrans.AddNewlyCreatedDBObject(acVport, True)
acVport.On = True
acTrans.Commit()
End Using
End Sub
|
|