Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, all. This is a continue of my previous question about late binding AutoCAD VBA.
I have been able to late bind AutoCAD objects in VBA. But I am unable to get the value of the array-type object properties.
Here is my code:
Sub LateBindingCAD()
'Declaration and late binding the application objects
Dim AcadApp As Object
Dim AcadDoc As Object
Dim AcadObj As Object
Dim LineObj As Object
Dim LineLayers(), LineCoords()
Dim i
Set AcadApp = GetObject(, "AutoCAD.Application")
Set AcadDoc = AcadApp.ActiveDocument
'Select objects in targeted layers, works fine, not important to the question
SSName = Array("COLUMN","BEAM","WALL","FLOOR")
For i = 0 To 3
AcadDoc.SelectionSets.Item(SSName(i)).Delete
AcadDoc.SelectionSets.Add SSName(i)
FilterType(0) = 8
FilterData(0) = SSName(i)
AcadDoc.SelectionSets.Item(SSName(i)).Select 4, , , FilterType, FilterData
Next i
'Extract data from selected object, by late binding the objects inside application objects
ReDim LineLayers(100), LineCoords(100)
i = 0
For Each SSObj In AcadDoc.SelectionSets
For Each AcadObj In SSObj
If AcadObj.Layer = "COLUMN" And AcadObj.ObjectName = "AcDbLine" Then
Set LineObj = AcadObj
LineLayers(i) = LineObj.Layer 'success getting non-array value
LineCoords(i) = LineObj.StartPoint(0) 'error 451 here <----------
i = i + 1
End If
Next
Next
End Sub
The error occurs in almost last line: "LineCoords(i) = LineObj.StartPoint(0)", the error is "Run-time error '451': Property let procedure not defined and property get procedure did not return an object".
Assigning values for non-array type of this object works fine, for example the "LineLayers(i) = LineObj.Layer" works fine.
The "LineObj.StartPoint" is Variant/Double array type with size of (0 To 2).
Any suggestion? Thank you in advance.
Solved! Go to Solution.