Hi All,
I want to zoom the first element which is in the Level Number "3". Below is my code
Private Sub GettingElement()On Error Resume NextDim elem As ElementDim ElemEnum As ElementEnumeratorDim elemScanCriteria As ElementScanCriteriaDim rng As Range3dDim oLevels As LevelsDim oLevel As LevelSet elemScanCriteria = New ElementScanCriteriaelemScanCriteria.IncludeLevel oLevelSet oLevels = ActiveDesignFile.LevelsSet oLevel = oLevels.FindByNumber(3)Set ElemEnum = ActiveModelReference.Scan(elemScanCriteria)ElemEnum.MoveNextSet elem = ElemEnum.CurrentIf elem.Level.Number = 3 ThenCall SelectedElement()End IfSet ElemEnum = NothingMsgBox ("Process Completed")End Sub
Public Sub SelectedElement()Dim oEnumerator As ElementEnumeratorSet oEnumerator = ActiveModelReference.GetSelectedElementsDo While oEnumerator.MoveNextDim oElement As ElementSet oElement = oEnumerator.CurrentConst Zoom As Double = 2Dim range As Range3drange = oElement.rangeDim oView As ViewSet oView = ActiveDesignFile.Views.Item(1)Dim extent As Point3dextent = Point3dScale(Point3dSubtract(range.High, range.Low), Zoom)oView.Origin = Point3dSubtract(range.Low, Point3dScale(extent, 0.5))oView.Extents = extentoView.RedrawLoop
ActiveModelReference.UnselectAllElementsEnd Sub
If I manually select any element in the dgn and runs the above, it works fine.But I want the routine to choose the element in the Level Number 3 and zoom it.
Could you please help me.
Hi,
why do you post the same question twice to different forums and even to not correct one? I am sure VBA development using MicroStation VBA API doesn't relate to Building Analysis and Design area at all.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answered here: communities.bentley.com/.../98393.aspx
Jan is correct though - MicroStation VBA questions are best suited for the programming forum, as you've found.
Answer Verified By: Steve Cocchi