Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1677

How to make element selection smarter?

$
0
0

I have got a VBA program that is designed for placing element along walls.

If you start the program and move the cursor along the edges of a wall a rectangle is shown. If you click on the left mouse button the element is placed.

I use ILocateCommandEvents to check if AccuSnap has catched a wall or not. If it did not catch a wall then the rectangle is not shown.

Everything is running fine so far - there is just a little unattractive side effect when I come to the corner of 2 walls.

The video below shows what I mean:

(Please visit the site to view this media)

The issue seems to be caused because the snapped point lies on both walls. My code checks the IDs of the located elements and in corners it catches the IDs of both walls which leads to the effect shown in the video.

Below you can find the code:


Private Sub ILocateCommandEvents_Dynamics(Point As Point3d, ByVal view As view, ByVal drawMode As MsdDrawingMode)
        
Dim ele As Element
Dim eleComponent As Element
Dim ele_checkComponent As Element
Dim IDcheck As Long
           
Set ele = CommandState.LocateElement(Point, view, True)

Do While Not ele Is Nothing

  If ele.IsComplexElement Then
 
   Set eleComponent = CommandState.GetLocatedElement(False)

     If eleComponent.IsLineElement = True And (eleComponent.Level.name = "SM2D_WANDINNEN- UND -AUSSENKANTEN" _
     Or eleComponent.Level.name = "SM2D_WÄNDE-BRÜSTUNGEN") Then
     
       dAngle = GetActiveAngleFrom2Points(eleComponent.AsLineElement.StartPoint, eleComponent.AsLineElement.EndPoint, view)
       
     End If
 
  Else
 
    If ele.Level.name = "SM2D_ELEKTRO_PLATZIERUNGSRAHMEN" Then
    
      Set eleComponent = CommandState.GetLocatedElement(True)
      If eleComponent.Type = msdElementTypeShape Then
        dAngle = GetActiveAngleFrom2Points(eleComponent.AsShapeElement.Vertex(1), eleComponent.AsShapeElement.Vertex(2), view)
        If Point3dEqualTolerance(Point, eleComponent.AsShapeElement.Vertex(1), 1) = True Then
          myElement.color = 2
        Else
          myElement.color = 0
        End If
        
      End If
      
    
    End If
    
  End If
 
  IDcheck = eleComponent.ID.Low
 
  Set ele = CommandState.LocateElement(Point, view, False)

  If IDcheck <> IDcheck2 And IDcheck <> 0 And (eleComponent.Level.name = "SM2D_WANDINNEN- UND -AUSSENKANTEN" _
  Or eleComponent.Level.name = "SM2D_WÄNDE-BRÜSTUNGEN" Or eleComponent.Level.name = "SM2D_ELEKTRO_PLATZIERUNGSRAHMEN") Then
    
    If dAngle <> rotate_angle Then
      myElement.Rotate Point, 0, 0, Radians(-rotate_angle)
      myElement.Rotate Point, 0, 0, Radians(dAngle)
      rotate_angle = dAngle
    End If
    
    IDcheck2 = IDcheck

  End If
 
  If eleComponent.Level.name = "SM2D_WANDINNEN- UND -AUSSENKANTEN" _
  Or eleComponent.Level.name = "SM2D_WÄNDE-BRÜSTUNGEN" Or eleComponent.Level.name = "SM2D_ELEKTRO_PLATZIERUNGSRAHMEN" Then
    
    offset = Point3dSubtract(Point, myElement.Vertex(1))
    myElement.Move offset
    myElement.Redraw drawMode
    
  End If
 
Loop

End Sub


Does anyone have an idea how to remove the horizontal rectangle? Only the vertical one should be displayed!


Viewing all articles
Browse latest Browse all 1677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>