VBA to Get Storey name for the selected Bar

VBA to Get Storey name for the selected Bar

WALIDGIO
Advocate Advocate
681 Views
5 Replies
Message 1 of 6

VBA to Get Storey name for the selected Bar

WALIDGIO
Advocate
Advocate

Hello,

is there a way to get the storey name of an element (bar) that I already get, i'm trying to get the force that belong to that bar and output them in Excel, but also i want to add a column of which storey that bar belong to, I'm looking for something like this 

Dim storeyName As String
storeyName = bar.GetLabelName(I_LT_STOREY(name or label))

 

is there a way or i have to iterate through each storey and then put the bar code

0 Likes
Accepted solutions (1)
682 Views
5 Replies
Replies (5)
Message 2 of 6

WALIDGIO
Advocate
Advocate

So far workaround a code by finding the Noed related to that bar then get the Z elevation compared to the storey and get the storey name

        For Each bar In bars
            Dim bar_num As Long
            bar_num = bar.Number
            
            barNodeZ = bar.StartNode 
            Dim nodeStart As IRobotNode
            Set nodeStart = robapp.Project.Structure.Nodes.Get(barNodeZ)
            barHeight = nodeStart.Z

            Dim Storeys As RobotStoreyMngr, Storey As RobotStorey
            Set Storeys = robapp.Project.Structure.Storeys

            For S = 1 To Storeys.Count
                Set Storey = Storeys.Get(S)
                If Storey.Level = barHeight Then
                    storeyName = Storey.Name
                    Exit For
                End If
            Next S
....

 

if there isn't a direct call of storey Label from bar Object, I'll continue with this solution 

 

0 Likes
Message 3 of 6

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @WALIDGIO 

has mentionned here and link in message 3

 

here's a selection of bars from the "story 1" storey

Dim BarSelection As RobotSelection
Set BarSelection = RobApp.Project.Structure.Selections.CreateByStorey(I_OT_BAR, "Story 1")

 

To find out whether a bar is part of a selection, you can, for example, use "Contains". 

Dim Bar_To_Find As Long, ExistInSelection As Boolean
Bar_To_Find = 45 ' Bar to find
ExistInSelection = BarSelection.Contains(Bar_To_Find)

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 4 of 6

WALIDGIO
Advocate
Advocate

Hi @Stephane.kapetanovic 

Thank you for the replay, I think there is no proprety concerning the storey for a element yet, I thought i was Implemented after all these years, so we still need to worked around 
what i really want is to retrieve the storey of element directly without compare it, or get it from a group of selection.

like in this picture the bar proprety has a story that it belong to 

 

WALIDGIO_0-1720799180612.png

 

0 Likes
Message 5 of 6

Stephane.kapetanovic
Mentor
Mentor

hi @WALIDGIO 

This is a request you should make to the Autodesk team.

 

As explained, the suggestions presented here are intended to illustrate the capabilities of the Robot API. They are not necessarily tailored to your specific architecture and are shared as general-purpose usage examples, rather than definitive solutions for a particular or personalized implementation.

 

Regarding the use of the RobotBar class and the addition of direct-read properties from RobotStorey, I have a different point of view than changing the paradigm. The code provided consists of just a few lines and is based on selections made from text strings, which are very quick to process compared to some collections. overloading the bar class with properties that are only occasionally read is not ideal.

Instead, you can optimize access times in your code by better data management, changing your programming language, creating your own classes and parralelizing your queries. This approach would preserve the API's efficiency while allowing for the customization you need.

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
0 Likes
Message 6 of 6

Stephane.kapetanovic
Mentor
Mentor

Here you'll find an offline method that you can adapt to your own situation.

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-get-the-group-that-the-bar-belong...

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
0 Likes