Page 1 of 1

Open and Read Customized Attributes of a DXF File

Posted: 24 Jun 2008, 11:54
by EXPERMEGAS
Hello,

I need to do something in VB.NET that must be very easy but I don't see how to begin.

I need to open a DXF File, show it, and find names of blocks, (x,y) points they refer to, names and values of customized attributes. I only need to read theses values.

Which control do I need to show my DXF File ? And secondly, the most important for me, how can I get from this file properties of blocks, names and values of customized attributes ?

A sample of code in VB.NET would be a precious help for me. I understand most of concepts of this powerful tool, but I don't see how to begin.

Thanks so much for your help.
Pierre

Re: Open and Read Customized Attributes of a DXF File

Posted: 25 Jun 2008, 17:03
by support
Hello Pierre,

Please try the follwoing code:

Code: Select all

    Private Sub btnGetBlocksFromInserts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetBlocksFromInserts.Click
        Dim i, j, entCounts As Integer
        Dim entBlock As CADBlock
        Dim entInsert As CADInsert
        Dim BlockName As String
        Dim insertPoint As DPoint
        Dim attributes As CADEntityCollection
        Dim Attrib As CADAttrib

        If Me.cadImage Is Nothing Then
            Me.cadImage = New CADImage
            Me.cadImage.InitialNewImage()
            Me.cadImage.UseDoubleBuffering = False
        End If

        'Get all blocks:
        For i = 0 To Me.cadImage.Converter.Blocks.Count - 1
            entBlock = Me.cadImage.Converter.Blocks(i)            
        Next i

        'Get blocks from inserts:
        entCounts = Me.cadImage.Converter.GetCounts(ConvSection.Entities)
        For i = 0 To entCounts - 1
            If (TypeOf Me.cadImage.Converter.GetSection(ConvSection.Entities).Entities(i) Is CADInsert) Then
                entInsert = Me.cadImage.Converter.GetSection(ConvSection.Entities).Entities(i)

               'Get all attributes from the current insert
                attributes = entInsert.Attribs
                If Not (attributes Is Nothing) Then
                    For j = 0 To attributes.Count - 1
                        Attrib = attributes.Item(j)                        
                    Next j                    
                End If
                
                'Get block name and insert point
                entBlock = entInsert.Block
                BlockName = entBlock.Name
                insertPoint = entInsert.Point
            End If
        Next i
    End Sub
Sergey.