Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA Excel macro for any object geometry modifications (API)

63 REPLIES 63
SOLVED
Reply
Message 1 of 64
Rafal.Gaweda
22223 Views, 63 Replies

VBA Excel macro for any object geometry modifications (API)

Hi

 

For those who might be interested I am attaching xls file with macro for objects geometry modifications.

One button to import geometry (characteriscic points coordinates) of selected objects (lines, polylines, arc, circles, panels), second - to update their geometry basing on data in Excell.

NOTE: modify only cells with coordinates.



Rafal Gaweda
63 REPLIES 63
Message 41 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

What do you mean by "generic"?

This was example for concrete beam section.

 

Cells(2, 10) = RBSCRD.GetValue(I_BSCDV_BEAM_H)


Rafal Gaweda
Message 42 of 64
Anonymous
in reply to: Rafal.Gaweda

@Rafal.Gaweda Concrete beam section is generic for me!!!Smiley LOL

But still does not work something...

Dim RLabel As RobotLabel
Dim RBSD As RobotBarSectionData
Dim RBSCRD As RobotBarSectionConcreteData
Dim LabelName As String


Set RBSD = RLabel.Data
Set RBSCRD = RBSD.Concrete
Cells(10, 10) = RBSCRD.GetValue(I_BSCDV_BEAM_B)
Cells(11, 10) = RBSCRD.GetValue(I_BSCDV_BEAM_H)
Message 43 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

b30x50.jpg



Rafal Gaweda
Message 44 of 64
Anonymous
in reply to: Rafal.Gaweda

why do I get always a beam 30 x 50? Also I do not understand why this row:

Set RLabel = RobApp.Project.Structure.Labels.Get(I_LT_BAR_SECTION, "B 30x50")

the bar section can have whatever dimensions. 

Message 45 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

This was JUST EXAMPLE.

Replace "B ...." by labelname \ string.



Rafal Gaweda
Message 46 of 64
Anonymous
in reply to: Rafal.Gaweda

@Rafal.Gaweda I have tried but...still problem Man Frustrated

 

Set RLabel = RobApp.Project.Structure.Labels.Get(I_LT_BAR_SECTION, "Labelname")
Set Labelname = String
Message 47 of 64
Rafal.Gaweda
in reply to: Anonymous


@Anonymous

 

Dim Labelname as String
Labelname = "B 30x50" ' here you have to give \ input real section name
Set RLabel = RobApp.Project.Structure.Labels.Get(I_LT_BAR_SECTION, Labelname)



Rafal Gaweda
Message 48 of 64
Anonymous
in reply to: Rafal.Gaweda

Thanks @Rafal.Gaweda for you patience!

What I do not understand if it is mandatory to write a Labelname (e.g. "B 30x50") or is it possible to skip it. Because like this I need to know, before importing dimensions into excel, the labelname of the section. I cannot import dimensions without know the labelname, nevertheless each time I have to change LabelName in the code. 

 

For example, if you want to get thickness  value for panels, you do not need to know the panel's thickness name. 

the code is:

 Set THData = Obj.GetLabel(I_LT_PANEL_THICKNESS).Data
                If (THData.ThicknessType = I_TT_HOMOGENEOUS) Then
                        Set HomoThickData = THData.Data
                        If (HomoThickData.Type = I_THT_CONSTANT) Then
                        Cells(Row, 2) = HomoThickData.ThickConst 
         

Now, is it a code where I can get bar section dimensions directly as we do for panel?

Message 49 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

Sure you can do it in similar way.

Example code :

 

Dim Bar As RobotBar
Dim SectionLabel As RobotLabel
Dim RBSD As RobotBarSectionData
Dim RBSCRD As RobotBarSectionConcreteData

Set Bar = RobApp.Project.Structure.Bars.Get(1)
Set SectionLabel = Bar.GetLabel(I_LT_BAR_SECTION)
Set RBSD = SectionLabel.Data

If (RBSD.ShapeType = I_BSST_CONCR_BEAM_RECT) Then
    Set RBSCRD = RBSD.Concrete
    Cells(1, 1) = RBSCRD.GetValue(I_BSCDV_BEAM_B)
    Cells(2, 1) = RBSCRD.GetValue(I_BSCDV_BEAM_H)
End If


Rafal Gaweda
Message 50 of 64
Anonymous
in reply to: Rafal.Gaweda

Thanks @Rafal.Gaweda

But...I get this error

screen1.JPG

 

Message 51 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

Do you have bar number 1 in your model?

The example code works for bar with number 1.



Rafal Gaweda
Message 52 of 64
Rafal.Gaweda
in reply to: Rafal.Gaweda

@Anonymous

 

Do you have such line in your code:

Dim Bar As RobotBar

 or

Dim Bar As IRobotBar

 



Rafal Gaweda
Message 53 of 64
Anonymous
in reply to: Rafal.Gaweda

@Rafal.Gaweda

Can It works for any bar?

Because If i do not put any bars number between brackets I do not get value

Set Bar = RobApp.Project.Structure.Bars.Get()
Message 54 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

If "any" means every RC Beam with rectangular section :

 

Dim Bar As RobotBar
Dim SectionLabel As RobotLabel
Dim RBSD As RobotBarSectionData
Dim RBSCRD As RobotBarSectionConcreteData
Dim BarCollection As RobotBarCollection

Set BarCollection = RobApp.Project.Structure.Bars.GetAll
Row = 1
For I = 1 To BarCollection.Count

Set Bar = BarCollection.Get(I)
Set SectionLabel = Bar.GetLabel(I_LT_BAR_SECTION)
Set RBSD = SectionLabel.Data

If (RBSD.ShapeType = I_BSST_CONCR_BEAM_RECT) Then
    Set RBSCRD = RBSD.Concrete
    Cells(Row, 1) = RBSCRD.GetValue(I_BSCDV_BEAM_B)
    Cells(Row, 2) = RBSCRD.GetValue(I_BSCDV_BEAM_H)
    Row = Row + 1
End If

Next I

 



Rafal Gaweda
Message 55 of 64
Anonymous
in reply to: Rafal.Gaweda

Thank so much @Rafal.Gaweda,

if you could do the last effort would be great!

Is it possible to import only bars that are selected in Robot, instead of importing all of them please? 

Message 56 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

Have fun:

 

Dim BarSelection As RobotSelection
Dim BarCollection As RobotBarCollection

Set BarSelection = RobApp.Project.Structure.Selections.Get(I_OT_BAR)
Set BarCollection = RobApp.Project.Structure.Bars.GetMany(BarSelection)


Rafal Gaweda
Message 57 of 64
Anonymous
in reply to: Rafal.Gaweda

Sorry, I have a problem.

 

When i click in Update objects appears: 

Error.PNG

What I do?

 

Thanks.

Message 58 of 64
Rafal.Gaweda
in reply to: Anonymous

Hi @Anonymous

 

My guess is You are running more than 1 Robot at the same time while using this macro .

API macros \ addins work fine only while 1 Robot is running.

 



Rafal Gaweda
Message 59 of 64
Anonymous
in reply to: Rafal.Gaweda

Thanks for your answer.

 

I only have one robot running.

The version of robot is 2016, have any problem?

Message 60 of 64
Anonymous
in reply to: Anonymous

Hi, have you found solution?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report