Macro Autocad to Robot (API)

Macro Autocad to Robot (API)

Stephane.kapetanovic
Mentor Mentor
165 Views
0 Replies
Message 1 of 1

Macro Autocad to Robot (API)

Stephane.kapetanovic
Mentor
Mentor

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

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 !
EESignature
0 Likes
166 Views
0 Replies
Replies (0)