Message 1 of 5

Not applicable
10-05-2010
08:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I try to write some code to zooom to objects but nothing happen.
Here is my Code
'--Pass array of Object ID Public Function AutoCADZoomByObjectIDs(ByRef objObjectIDs() As ObjectId, _ Optional ByVal dSizeUp As Double = 0) As Boolean Dim adblBottomLeft(2) As Double Dim adblTopRight(2) As Double Dim dblHighestY As Double Dim dblHighestX As Double Dim dblLowestY As Double Dim dblLowestX As Double Dim lngUBound As Long ' If the variant is not an array then exit the function If IsArray(objObjectIDs) = False Then Exit Function Dim objEd As Editor = acApp.DocumentManager.MdiActiveDocument.Editor Dim objEnt As Entity Dim objGExt As Extents3d Try Using objTrans As Transaction = objEd.Document.TransactionManager.StartTransaction objEnt = objTrans.GetObject(objObjectIDs(0), OpenMode.ForRead) objGExt = objEnt.GeometricExtents If dSizeUp = 0 Then dSizeUp = MathDistanceBetweenPoints(objGExt.MinPoint, objGExt.MaxPoint) dblLowestX = objGExt.MinPoint.X - dSizeUp dblLowestY = objGExt.MinPoint.Y - dSizeUp dblHighestX = objGExt.MaxPoint.X + dSizeUp dblHighestY = objGExt.MinPoint.Y + dSizeUp For lngCount As Long = objObjectIDs.GetLowerBound(0) + 1 To objObjectIDs.GetUpperBound(0) objEnt = objTrans.GetObject(objObjectIDs(lngCount), OpenMode.ForRead) objGExt = objEnt.GeometricExtents If objGExt.MinPoint.X - dSizeUp < dblLowestX Then dblLowestX = objGExt.MinPoint.X - dSizeUp If objGExt.MinPoint.Y - dSizeUp < dblLowestY Then dblLowestY = objGExt.MinPoint.Y - dSizeUp If objGExt.MaxPoint.X + dSizeUp > dblHighestX Then dblHighestX = objGExt.MaxPoint.X + dSizeUp If objGExt.MaxPoint.Y + dSizeUp > dblHighestY Then dblHighestY = objGExt.MaxPoint.Y + dSizeUp Next 'Zoom to show this entire rectangle adblBottomLeft(0) = dblHighestX adblBottomLeft(1) = dblLowestY adblTopRight(0) = dblLowestX adblTopRight(1) = dblHighestY '--g_objDrawing defined AcadDocument, it is the current open drawing. I have tested it is correct g_objDrawing.Application.ZoomWindow(adblBottomLeft, adblTopRight) objTrans.Commit() Return True End Using Catch ex As Exception Debug.Assert(False) Finally objEnt = Nothing objGExt = Nothing objEd = Nothing End Try
There is no exception, just nothing happen.
Any ideas?
Thanks very much
Solved! Go to Solution.