Hi @Anonymous
Sub Create_And_Apply_Offset()
Dim RobApp As IRobotApplication
Set RobApp = New RobotApplication
Dim Structure As RobotStructure
Set Structure = RobApp.Project.Structure
'// Create Offset
Dim OffsetName As String
Dim RLabelServer As RobotLabelServer
Dim RLabel As RobotLabel
Dim OffsetData As RobotBarOffsetData
Dim EndOffset As RobotBarEndOffsetData
OffsetName = "X1/Y2"
Set RLabelServer = Structure.Labels
Set RLabel = RLabelServer.Create(IRobotLabelType.I_LT_BAR_OFFSET, OffsetName)
Set OffsetData = RLabel.Data
Set EndOffset = OffsetData.Start
EndOffset.UX = 0.01 ' < 1 cm in meters
Set EndOffset = OffsetData.End
EndOffset.UY = 0.02
RLabelServer.Store RLabel
'// Get Beams from a RobotSelection to apply offset
Dim SelBar As RobotSelection
Set SelBar = Structure.Selections.Get(IRobotObjectType.I_OT_BAR)
Dim Rbars As RobotBarCollection
Set Rbars = Structure.Bars.GetMany(SelBar)
Dim Bar As IRobotBar
For i = 1 To SelBar.Count
Set Bar = Rbars.Get(i)
Bar.SetOffset OffsetName, True '< True if ReversedOffset
Next i
Set RobApp = Nothing
End Sub
See also :
https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-offset-to-a-bar-with-excel-vba/m-p/5616005
Best regards
Stéphane
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 !
