I'm going to zoom to selected element, I used the codes below:
Sub ZoomTo(MyElement As Element) Dim MyView As View Dim TempPnt As Point3d Dim TempDistance As Double Set MyView = CommandState.LastView TempDistance = Point3dDistance(MyElement.Range.Low, MyElement.Range.High) TempPnt = Point3dFromXYZ(5 * TempDistance, 5 * TempDistance, 0) MyView.SetArea Point3dSubtract(MyElement.Range.Low, TempPnt), Point3dSubtract(Point3dAdd(MyElement.Range.High, TempPnt), Point3dSubtract(MyElement.Range.Low, TempPnt)), Matrix3dIdentity(), 0 MyView.Redraw End Sub
It was OK before. The selected element will show in the center of the view. But yesterday it didn't work... After checked, I found the coordinates get from .range are 10 times of the actual value, and it is same dgn file, same unit. Does anyone know what's wrong? For example, .range.low get -44721.72,65617.66, but it is -4472,6561. Thanks a lot.
Note, it is a cell element in ref file. the code works for a new element in active model. But it is wired that it used to work fine for ref file also.