cad.net可以让某个要素居中显示 谁实现过?
cad.net可以让某个要素居中显示,控制显示比例。谁实现过?给段代码 ''' <summary>''' 按对象进行缩放
''' </summary>
''' <param name="ID"></param>
''' <param name="ZoomScale">此数为正数,表示放大倍率(如果此数小于等于 0 则自动调整为1)</param>
''' <remarks></remarks>
Public Sub ZoomO(ByVal ID As ObjectId, Optional ByVal ZoomScale As Double = 1.0)
Dim MinPt As Point3d = Nothing, MaxPt As Point3d = Nothing
Using Trans As Transaction = DB.TransactionManager.StartTransaction
Dim obj As DBObject = ID.GetObject(OpenMode.ForRead)
If TypeOf obj Is Entity = False Then
Trans.Commit()
Exit Sub
End If
Dim Ent As Entity = obj
MinPt = Ent.GeometricExtents.MinPoint : MaxPt = Ent.GeometricExtents.MaxPoint
Trans.Commit()
End Using
Dim Ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim VTabRec As New ViewTableRecord
VTabRec.CenterPoint = New Point2d((MaxPt.X + MinPt.X) / 2.0, (MaxPt.Y + MinPt.Y) / 2.0)
If ZoomScale <= 0 Then
ZoomScale = 1.0
End If
VTabRec.Height = (MaxPt.Y - MinPt.Y) / ZoomScale
Ed.SetCurrentView(VTabRec)
Ed.UpdateScreen()
End Sub
此方法将对象居中于当前视图(同时可以设置放大倍率)
页:
[1]