Hi All,
I am trying to execute a vba code in Civil 3D but it is giving a runtime error: Invalid use of property. The code follows below
Sub list_alignment_entyties()
Dim i As Integer
Dim oTangent As AeccAlignmentTangent
Dim oArc As AeccAlignmentArc
Dim oSpiral As AeccAlignmentSpiral
Dim oSCSGroup As AeccAlignmentSCSGroup
Debug.Print "Number of Entities: "; oAlignment.Entities.Count
For i = 0 To oAlignment.Entities.Count - 1
Select Case (oAlignment.Entities.Item(i).Type)
Case aeccTangent
Set oTangent = oAlignment.Entities.Item(i)
Debug.Print "Tangent length:" & oTangent.Length
Case aeccArc
Set oArc = oAlignment.Entities.Item(i)
Debug.Print "Arc radius:" & oArc.Radius
Case aeccSpiral
Set oSpiral = oAlignment.Entities.Item(i)
Debug.Print "Spiral A value:" & oSpiral.A
Case aeccSpiralCurveSpiralGroup
Set oSCSGroup = oAlignment.Entities.Item(i)
Debug.Print "Radius of curve in SCS group:" _
& oSCSGroup.Arc.Radius
' And so on for AeccAlignmentSTSGroup,
' AeccAlignmentSTGroup, AeccAlignmentTSGroup
' AeccAlignmentSCGroup, and AeccAlignmentCSGroup types.
End Select
Next i
End Sub
I can't identify why the error occurs as this code is in AutoCAD Civil 3D API Developers Guide
Solved! Go to Solution.
Hi All,
I am trying to execute a vba code in Civil 3D but it is giving a runtime error: Invalid use of property. The code follows below
Sub list_alignment_entyties()
Dim i As Integer
Dim oTangent As AeccAlignmentTangent
Dim oArc As AeccAlignmentArc
Dim oSpiral As AeccAlignmentSpiral
Dim oSCSGroup As AeccAlignmentSCSGroup
Debug.Print "Number of Entities: "; oAlignment.Entities.Count
For i = 0 To oAlignment.Entities.Count - 1
Select Case (oAlignment.Entities.Item(i).Type)
Case aeccTangent
Set oTangent = oAlignment.Entities.Item(i)
Debug.Print "Tangent length:" & oTangent.Length
Case aeccArc
Set oArc = oAlignment.Entities.Item(i)
Debug.Print "Arc radius:" & oArc.Radius
Case aeccSpiral
Set oSpiral = oAlignment.Entities.Item(i)
Debug.Print "Spiral A value:" & oSpiral.A
Case aeccSpiralCurveSpiralGroup
Set oSCSGroup = oAlignment.Entities.Item(i)
Debug.Print "Radius of curve in SCS group:" _
& oSCSGroup.Arc.Radius
' And so on for AeccAlignmentSTSGroup,
' AeccAlignmentSTGroup, AeccAlignmentTSGroup
' AeccAlignmentSCGroup, and AeccAlignmentCSGroup types.
End Select
Next i
End Sub
I can't identify why the error occurs as this code is in AutoCAD Civil 3D API Developers Guide
Solved! Go to Solution.
Solved by ed57gmc. Go to Solution.
Can you set a breakpoint and step through the code to identify which line gives the error?
Can you set a breakpoint and step through the code to identify which line gives the error?
Hi EdJobe, thanks for answering. Error occurs early in code
Debug.Print "Number of Entities: "; oAlignment.Entities.Count
Hi EdJobe, thanks for answering. Error occurs early in code
Debug.Print "Number of Entities: "; oAlignment.Entities.Count
Did you add the Debug statement? Are you sure you copied the code correctly? The reason I say this is because that's the first line after the dim statements and oAlignment has not been set yet. Any reference to it will be null. You can't get the Count property of something that doesn't exist.
Did you add the Debug statement? Are you sure you copied the code correctly? The reason I say this is because that's the first line after the dim statements and oAlignment has not been set yet. Any reference to it will be null. You can't get the Count property of something that doesn't exist.
That isn't a complete code sample, it doesn't have anything that gets/selects an alignment. It doesn't even have a Sub/Function statement. My guess is that it assumes you are already familiar with basic AutoCAD programming before attempting the C3D api.
That isn't a complete code sample, it doesn't have anything that gets/selects an alignment. It doesn't even have a Sub/Function statement. My guess is that it assumes you are already familiar with basic AutoCAD programming before attempting the C3D api.
ok. I have a little knowledge of vba with Excel, but in Civil 3D it's the first time I'm working. I don't know Civil's methods, objects and entities and I'm learning. I thought the Developer's Guide could give me a notion but I'm seeing that I need to study further. Thanks for the help and sorry for your time wasted on me. Thank you very much
ok. I have a little knowledge of vba with Excel, but in Civil 3D it's the first time I'm working. I don't know Civil's methods, objects and entities and I'm learning. I thought the Developer's Guide could give me a notion but I'm seeing that I need to study further. Thanks for the help and sorry for your time wasted on me. Thank you very much
No Problem.
No Problem.
Can't find what you're looking for? Ask the community or share your knowledge.