How to access information of an object in robot api?

How to access information of an object in robot api?

wllao
Explorer Explorer
512 Views
1 Reply
Message 1 of 2

How to access information of an object in robot api?

wllao
Explorer
Explorer

 

for example,

1) I want to get the "Node 1" and "Node 2" through the api

2) I want to get the length of the beam

 

Screenshot 2022-10-20 at 4.38.33 PM.png

 

0 Likes
Accepted solutions (1)
513 Views
1 Reply
Reply (1)
Message 2 of 2

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

HI @wllao 

two ways (by bar, by node)

Sub GetBarLength()
  Dim RobApp As IRobotApplication: Set RobApp = New RobotApplication
  Dim Structure As RobotStructure: Set Structure = RobApp.Project.Structure
  
  BarNo = 1 'Example: Barre number 1
  Dim Bar As RobotBar: Set Bar = Structure.Bars.Get(BarNo)
  
  'First Method
  BarLength1 = Bar.Length
  
  'Second Method
  Dim N1 As RobotNode, N2 As RobotNode
  With Structure.Nodes: Set N1 = .Get(Bar.StartNode): Set N2 = .Get(Bar.EndNode): End With
  DX = N1.X - N2.X: DY = N1.Y - N2.Y: DZ = N1.Z - N2.Z
  BarLength2 = (DX * DX + DY * DY + DZ * DZ) ^ 0.5
  
  Debug.Print BarNo, BarLength1, BarLength2
  
  Set RobApp = Nothing
End Sub

Best Regards

Stéphane Kapetanovic

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