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: 

(API) Divide bars

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
samuel.pereira
980 Views, 9 Replies

(API) Divide bars

Hello,

 

I want divide bars using API macro in Excel. For example, divide bar number 2 into 4 parts.

You can provide an example?

 

Thanks.

9 REPLIES 9
Message 2 of 10

Dim RVA As New RobotValuesArray
RVA.SetSize 3
RVA.Set 1, 0.25
RVA.Set 2, 0.5
RVA.Set 3, 0.75
barnumber=2 RobApp.Project.Structure.Edit.DivideBar barnumber, RVA, True

 



Rafal Gaweda
Message 3 of 10

Hello,

 

When I run the the API in Excel, it show an error. I attached the error. Can you help me?

 

Thank you and best regards

Message 4 of 10

Hello,

 

When I run the the API in Excel, it show an error. I attached the error. Can you help me?

 

Thank you and best regards

Message 5 of 10

Try:

 

Dim RVA As RobotValuesArray
Set RVA = RobApp.CmpntFactory.Create(I_CT_VALUES_ARRAY)

 



Rafal Gaweda
Message 6 of 10

It works. Thanks.

It's possible generate the nodes without bar division?

 

Thank you and best regards.

Message 7 of 10

Of course. Write your own divide function

- calculate bar vector

- normalize it to 1

- use startnode + normalized vector to generate node in proper position or endnode and opposite vector to normalized one

 

or use this 🙂

http://forums.autodesk.com/t5/Autodesk-Robot-Structural/API-addin-for-merging-bars/td-p/3817730



Rafal Gaweda
Message 8 of 10

Ok.

Can you provide an example.

 

Thanks

Message 9 of 10

Dim RobApp As RobotApplication
Set RobApp = New RobotApplication

Dim RBar As RobotBar
Dim StartNode As RobotNode
Dim EndNode As RobotNode
Dim Relative As Boolean

BarNumber = 2
Distance = 0.3
Relative = True

Set RBar = RobApp.Project.Structure.Bars.Get(BarNumber)
Set StartNode = RobApp.Project.Structure.Nodes.Get(RBar.StartNode)
Set EndNode = RobApp.Project.Structure.Nodes.Get(RBar.EndNode)

Dim Vx As Double, Vy As Double, Vz As Double, VL As Double

'bar vector
Vx = EndNode.x - StartNode.x
Vy = EndNode.y - StartNode.y
Vz = EndNode.z - StartNode.z

'vector length
VL = Sqr(Vx * Vx + Vy * Vy + Vz * Vz)

'normalization
Vx = Vx / VL
Vy = Vy / VL
Vz = Vz / VL

'new node

If Relative Then
    Distance = Distance * VL
End If

RobApp.Project.Structure.Nodes.Create RobApp.Project.Structure.Nodes.FreeNumber, _
                                        StartNode.x + Vx * Distance, _
                                        StartNode.y + Vy * Distance, _
                                        StartNode.z + Vz * Distance

 



Rafal Gaweda
Message 10 of 10

Thank you very much!!

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

Post to forums  

Autodesk Design & Make Report