GetXData for all ACADPoints inside a block.

GetXData for all ACADPoints inside a block.

nmeertens
Observer Observer
203 Views
1 Reply
Message 1 of 2

GetXData for all ACADPoints inside a block.

nmeertens
Observer
Observer

Hi All,

 

I have some data I want to extract from a dwg - I do it by creating a block, then adding an ACADPoint for each datapoint and then using the SetXdata method to add 8 len array to each ACAD point. 

 

Now, I want to get the data out by using GetXData method on each ACAD point for the block, but am not able to access the ACAD points inside the block. I have tried a few things I found on this forum and others, but in vain. 

 

Below is the example code, any help is appreciated. 

 

Sub myFunc()

    Dim blockRef As Object
    Dim blockName As String
    Dim blockFound As Boolean
    
    ' Set the block name you want to retrieve
    blockName = "my-block"
    blockFound = False
    
    ' Loop through the ModelSpace to find the block
    For Each blockRef In ThisDrawing.ModelSpace
        If blockRef.ObjectName = "AcDbBlockReference" Then
            If blockRef.Name = blockName Then
                
                ' Block found, you can access its properties here
                MsgBox "Block found: " & blockRef.Name

                For Each obj In blockRef.Name
                    If Not IsNull(obj.GetXData) Then
                        xData = obj.GetXData
                        ' Process the Xdata as needed
                        For i = LBound(xData) To UBound(xData)
                            Debug.Print xData(i) 
                        Next i
                    End If
                Next obj
                
                blockFound = True
                
                Exit For
            End If
        End If
    Next blockRef
    
End Sub

 

I know that the easier solution is to store it as block attributes, but unfortunately I have to use AUTOCAD 2006 (for legacy reasons) for this task. And storing block attributes doesn't work in that version.

 

Thanks in advance! 

0 Likes
204 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

"storing block attributes doesn't work" blocks with attributes has existed since way before 2006. Can not remember if Invisible is supported in blocks in 2006, that way they exist but not shown. But you should be able to get attribute values. Not sure when Vla-get/put attributes started.

0 Likes