Open and Read Customized Attributes of a DXF File

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
EXPERMEGAS
Posts: 1
Joined: 24 Jun 2008, 11:33

Open and Read Customized Attributes of a DXF File

Post by EXPERMEGAS » 24 Jun 2008, 11:54

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

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Open and Read Customized Attributes of a DXF File

Post by support » 25 Jun 2008, 17:03

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply