- ''' <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
此方法将对象居中于当前视图(同时可以设置放大倍率) |