(API) Get Nodes by Coordinates

(API) Get Nodes by Coordinates

a54249
Enthusiast Enthusiast
2,547 Views
2 Replies
Message 1 of 3

(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
2,548 Views
2 Replies
Replies (2)
Message 2 of 3

Stephane.kapetanovic
Mentor
Mentor

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. Here is a commonly used generic method

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
  
  Dim bounds As Variant: bounds = [Limits].Value2
  XMin = bounds(1, 1): Xmax = bounds(1, 2)
  YMin = bounds(2, 1): Ymax = bounds(2, 2)
  ZMin = bounds(3, 1): Zmax = bounds(3, 2)
  
  For i = 1 To NodCol.Count
    With NodCol.Get(i)
      If WithIn(.X, XMin, Xmax) And WithIn(.Y, YMin, Ymax) And WithIn(.Z, ZMin, Zmax) Then Txt = Txt & " " & .Number
    End With
  Next
  NodSel.FromText Txt
  Set RobApp = Nothing
End Sub

Function WithIn(V, VMin, VMax) As Boolean
  WithIn = V > VMin And V < VMax
End Function

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 3 of 3

Stephane.kapetanovic
Mentor
Mentor

Upgrade to improve speed and add selected object nodes only in the desired range

Stephanekapetanovic_0-1757060629322.png

updated on September 30, 2025

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature