(API) to select all the node in the top level

(API) to select all the node in the top level

WALIDGIO
Advocate Advocate
278 Views
3 Replies
Message 1 of 4

(API) to select all the node in the top level

WALIDGIO
Advocate
Advocate

hello,
I want to know is there a better way to get all the node in the top level of stories, im doing this to apply to it a rigid link
the way I'm using is to check all the node in the project than compare them to the Height of the level desired witch is time consuming, 

' Find all nodes at the same elevation (storeyHeight)

Dim nodesAtElevation As Collection
Set nodesAtElevation = New Collection
For j = 1 To nodeServer.GetAll().Count
Dim node As IRobotNode
Set node = nodeServer.GetAll().Get(j)
If Abs(node.Z - storeyHeight) < 0.001 Then
nodesAtElevation.Add node.Number
End If
Next j


i was looking for Selecting method that does by Storeys.Selection or something like this but I cant find another way

if anyone have better idea it will be very helpful
thank you

0 Likes
279 Views
3 Replies
  • API
Replies (3)
Message 2 of 4

Stephane.kapetanovic
Mentor
Mentor

hi @WALIDGIO 

Your declaration is not clear. You indicate that you want the nodes to be at the top of each storey;

  • however, You have named your variable storeyHeight instead of TopLevelOfStorey.
  • You indicate that you want a selection, but you're actually setting up a collection.
  • To avoid multiple iterations, you should test all floor levels against the elevation of each node.
  • If your building is made up of several floors, don't these floors already include all the nodes you want?
  • At each iteration, you recreate the nodeServer.GetAll() collection to obtain the node's Z coordinate using the Get method.

It's difficult to answer your question because we don't know the type of structure you want to scan with your algorithm, let alone the purpose of selecting nodes by storeys. We would need to see the code preceding and following the snippet you shared.

Best regards

 

https://forums.autodesk.com/t5/robot-structural-analysis-forum/vba-to-get-storey-name-for-the-select...

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-list-of-nodes-by-strorey/m-p/9194...

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 4

WALIDGIO
Advocate
Advocate

thank you stephane for your response 
here my code :

 

'' Create new rigid links
Sub CreateNewRigidLinks()
    Dim robApp As IRobotApplication
    Dim storeyMngr As RobotStoreyMngr
    Dim rigidLinkServer As IRobotNodeRigidLinkServer
    Dim nodeServer As IRobotNodeServer
    Dim nodeDisplacementServer As RobotNodeDisplacementServer

    Dim i As Integer, j As Integer
    Dim newNodeNumber As Long
    Dim storeyCount As Integer

    ' Create a rigid link label
    Dim labelLink As IRobotLabel
    Dim RigidLinkLabel As String
    RigidLinkLabel = "WalidBouzRigidLink"
    Set labelLink = robApp.Project.Structure.Labels.Create(I_LT_NODE_RIGID_LINK, RigidLinkLabel)
    
    ' Set rigid link properties (parameterized)
    Dim RLdata As IRobotNodeRigidLinkData
    Set RLdata = labelLink.Data
    RLdata.UX = True
    RLdata.UY = True
    RLdata.UZ = False
    RLdata.rx = False
    RLdata.ry = False
    RLdata.RZ = True

    ' Store the label
    robApp.Project.Structure.Labels.Store labelLink

    ' Initialize storey count
    storeyCount = 0
    ' Loop through each storey
    For i = 1 To storeyMngr.Count
        Dim storeyHeight As Double
        storeyHeight = storeyMngr.Get(i).TopLevel

        ' Retrieve the storey's reference point (G.X, G.Y)
        Dim Gx As Double, Gy As Double
        Gx = robApp.Project.Structure.Results.Storeys.values(i, 1).G.X
        Gy = robApp.Project.Structure.Results.Storeys.values(i, 1).G.Y

        ' Find all nodes at the same elevation (storeyHeight)
        Dim nodesAtElevation As Collection
        Set nodesAtElevation = New Collection
        For j = 1 To nodeServer.GetAll().Count
            Dim node As IRobotNode
            Set node = nodeServer.GetAll().Get(j)
            If Abs(node.Z - storeyHeight) < 0.001 Then
                nodesAtElevation.Add node.Number
            End If
        Next j

        ' Check if a node already exists at (G.X, G.Y, storeyHeight)
        Dim masterNode As Long
        masterNode = -1 ' Default value if no node is found
        For j = 1 To nodesAtElevation.Count
            Set node = nodeServer.Get(nodesAtElevation(j))
            If Abs(node.X - Gx) < 0.001 And Abs(node.Y - Gy) < 0.001 And Abs(node.Z - storeyHeight) < 0.001 Then
                masterNode = node.Number
                Exit For
            End If
        Next j

        ' If no node exists, create a new master node
        Dim nodeCreation As String
        If masterNode = -1 Then
            masterNode = nodeServer.FreeNumber
            nodeServer.Create masterNode, Gx, Gy, storeyHeight
        Else
            ' Remove the master node from the collection of nodes at the same elevation
            For j = nodesAtElevation.Count To 1 Step -1
                If nodesAtElevation(j) = masterNode Then
                    nodesAtElevation.Remove j
                    Exit For
                End If
            Next j
        End If

        ' Create a rigid link with the master node and nodes at the same elevation
        If nodesAtElevation.Count > 0 Then
            ' Format secondary nodes as a string
            Dim secondaryNodesStr As String
            secondaryNodesStr = ""
            For j = 1 To nodesAtElevation.Count
                secondaryNodesStr = secondaryNodesStr & nodesAtElevation(j) & " "
            Next j
            
            ' Create the rigid link using the stored label
            rigidLinkServer.Set masterNode, secondaryNodesStr, RigidLinkLabel
            ' Increment storey count
            storeyCount = storeyCount + 1
        End If
    Next i
End Sub

 

 
1-  You’re right, naming it storeyHeight isn’t the clearest choice. I’ll rename it to TopLevelOfStorey to better reflect its purpose. Thanks for pointing that out.

2- You’re right. I was using a Collection to store nodes at the same elevation as a way to group them for further processing. If there’s a more efficient way to directly select nodes by elevation without iterating through all nodes and minimize unnecessary iterations, I’d be glad to learn about it. The goal is to apply rigid links efficiently to nodes at the top level of each storey.

3- Right now, I loop through all nodes and compare their Z coordinate with the top level of each storey. It’s not efficient for large models. Does RSA’s API offer a way to directly query nodes by elevation or storey?

 

5-this is the correct way you mean 

 

        ' Find all nodes at the same elevation (storeyHeight)
        Dim nodesAtElevation As Collection
        Set nodesAtElevation = New Collection
        Set allNodes = nodeServer.GetAll()
        For j = 1 To allNodes.Count
            Dim node As IRobotNode
            Set node = allNodes.Get(j)
            If Abs(node.Z - TopLevelOfStorey) < 0.001 Then
                nodesAtElevation.Add node.Number
            End If
        Next j
        

 

 

6- The structure I’m working on is a multi-storey building. The purpose of the code is to create rigid links between all nodes at the top level of each storey and a single master node.

 

 

 

0 Likes
Message 4 of 4

Stephane.kapetanovic
Mentor
Mentor

hi @WALIDGIO 

a similar subject has already been developed freely

https://apps.autodesk.com/RSA/fr/Detail/Index?id=8768390536116652588&appLang=en&os=Win64

Please contact Roman Zhelezniak @Romanich 

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