Message 1 of 1
Macro Autocad to Robot (API)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
A copy of a popular discussion thread from 2012.
Dim LayerName As String
Dim BN As Integer
Dim idx As Integer
Dim RGR As RobotGroup
'For every line in this drawing create a corresponding bar in Robot project
For i = 0 To ThisDrawing.ModelSpace.Count - 1
Set aObj = ThisDrawing.ModelSpace.Item(i)
If TypeOf aObj Is AcadLine Then
Dim aLine As AcadLine
Set aLine = aObj
' create nodes
n1 = rStruct.nodes.FreeNumber
LayerName = aLine.Layer
rStruct.nodes.Create n1, aLine.startPoint(0), aLine.startPoint(1), aLine.startPoint(2)
n2 = rStruct.nodes.FreeNumber
rStruct.nodes.Create n2, aLine.endPoint(0), aLine.endPoint(1), aLine.endPoint(2)
'create a bar
BN = rStruct.bars.FreeNumber
rStruct.bars.Create BN, n1, n2
idx = R.Project.Structure.Groups.Find(I_OT_BAR, LayerName)
If idx = 0 Then
R.Project.Structure.Groups.Create I_OT_BAR, LayerName, Str(BN)
Else
Set RGR = R.Project.Structure.Groups.Get(I_OT_BAR, idx)
RGR.SelList = RGR.SelList + Str(BN)
RGR.Store
End If
Set aLine = Nothing
End If
Set aObj = Nothing
Next