Inserting new entities - handles?

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
flycast
Posts: 5
Joined: 15 Sep 2013, 03:05

Inserting new entities - handles?

Post by flycast » 15 Sep 2013, 03:11

I am converting polylines to lines. I create all the lines and then delete the polyline and insert the lines. The problem is that the entity handle is not automatically assigned. If I assign a handle it might duplicate handles already created. How do I get unique handles for new entities?

Here is my code:

Code: Select all

        '************************************************************
        'Convert polylines to lines first
        '************************************************************
        Dim linesToAdd As New Collection
        Dim polylinesToRemove As New Collection
        For Each entity As CADEntity In cadImage.Converter.Entities
            If entity.EntType = EntityType.Polyline Then
                polylinesToRemove.Add(entity)
                Dim tempPolyline As CADPolyLine = entity
                For i As Integer = 1 To tempPolyline.PolyPoints.Count - 1
                    Dim line As New CADLine
                    line.Color = tempPolyline.Color
                    line.DashStyle = tempPolyline.DashStyle
                    line.Layer = tempPolyline.Layer
                    line.LineType = tempPolyline.LineType
                    line.LineTypeScale = tempPolyline.LineTypeScale
                    line.LineWeight = tempPolyline.LineWeight
                    line.Point = tempPolyline.PolyPoints(i - 1)
                    line.Point1 = tempPolyline.PolyPoints(i)
                    line.Visibility = tempPolyline.Visibility
                    line.Visible = tempPolyline.Visible
                    line.Width = tempPolyline.Width
                    line.ZThick = tempPolyline.ZThick
                    linesToAdd.Add(line)
                Next
            End If
        Next
And then later:

Code: Select all

        '************************************************************
        'Add the new lines to the cadImage
        '************************************************************
        For Each line As CADEntity In linesToAdd
            Dim newEntity As New CADEntity
            newEntity.AssignEntity(line)
        Next

flycast
Posts: 5
Joined: 15 Sep 2013, 03:05

Re: Inserting new entities - handles?

Post by flycast » 15 Sep 2013, 05:50

I just found it after quite a bit of reading and stumbling:

Code: Select all

cadImage.Converter.SetHandle(entity)

Post Reply