Dears,
I’m trying to write a code to automatically create a structure.
I’ve noted that 95% of the spent time is when I attribute the steel sections. Here it’s this part of my code:
Dim robapp0 As IRobotApplication
Dim bar1 As IRobotBar
Dim str As IRobotStructure
Dim RLabel As RobotLabel
Dim RLabelData As RobotBarSectionData
Set robapp0 = New RobotApplication
Set str = robapp0.Project.Structure
robapp0.Project.Preferences.SetCurrentDatabase I_DT_SECTIONS, "OTUA"
robapp0.Project.Preferences.SetCurrentDatabase I_DT_SECTIONS, "RTRKK"
For i = 1 To ns
leg_section = Cells(18 + i, 19) & " " & Cells(18 + i, 20)
Set RLabel = str.Labels.Create(I_LT_BAR_SECTION, leg_section)
Set RLabelData = RLabel.Data
RLabelData.LoadFromDBase leg_section
str.Labels.Store RLabel
Robot.Project.Structure.Bars.Get(1 + 3 * (i - 1)).SetLabel I_LT_BAR_SECTION, leg_section
Robot.Project.Structure.Bars.Get(2 + 3 * (i - 1)).SetLabel I_LT_BAR_SECTION, leg_section
Robot.Project.Structure.Bars.Get(3 + 3 * (i - 1)).SetLabel I_LT_BAR_SECTION, leg_section
Next i
There is another way to select the 3 bars at the same time and attribute the steel section in one single line?
Robot.Project.Structure.Bars.Get(1 + 3 * (i - 1), 2 + 3 * (i - 1), 3 + 3 * (i - 1)).SetLabel I_LT_BAR_SECTION, leg_section
I think that will boost my app.
Solved! Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Hi @Anonymous
Create Selection and the apply Section to this selection
Robot.Project.Structure.Bars.SetLabel(....)
Can't find what you're looking for? Ask the community or share your knowledge.