Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

(API) Get Nodes by Coordinates

a54249
Enthusiast
Enthusiast

(API) Get Nodes by Coordinates

a54249
Enthusiast
Enthusiast

Hi,

 

Is it possible to directly select nodes with the geometry filters shown in the image attached via API? At the moment I'm selecting all the nodes and filtering them in the code but unfortunately when the model has too many nodes it becomes extremely slow.  

a54249_0-1679575780630.png

 

Thanks

 

0 Likes
Reply
434 Views
2 Replies
Replies (2)

Stephane.kapetanovic
Advisor
Advisor

hi @a54249 

you can select from nodes of panels and filter by coordinates on this more restricted list.

 

After that, yes, it is possible to do it by API.

 

 

Sub SelectNodesByCoordinatesRanges()
  Dim RobApp As RobotApplication
  Set RobApp = New RobotApplication
  
  Dim NodCol As IRobotCollection, NodSel As RobotSelection
  With RobApp.Project.Structure
    Set NodCol = .Nodes.GetAll
    Set NodSel = .Selections.Get(I_OT_NODE)
  End With
  
  Xmin = Cells(1, 1).Value2: Xmax = Cells(1, 2).Value2
  Ymin = Cells(2, 1).Value2: Ymax = Cells(2, 2).Value2
  Zmin = Cells(3, 1).Value2: Zmax = Cells(3, 2).Value2
  
  For i = 1 To NodCol.Count
    With NodCol.Get(i)
      X = .X: Y = .Y: Z = .Z
      If X > Xmin And X < Xmax Then
        If Y > Ymin And Y < Ymax Then
          If Z > Zmin And Z < Zmax Then
            Txt = Txt & " " & .Number
          End If
        End If
      End If
    End With
  Next
  NodSel.FromText Txt
  Set RobApp = Nothing
End Sub

 

 

Best Regards

 

Stephane.kapetanovic
Advisor
Advisor

Upgrade to add nodes of selected objects only in the desired range