Inserting new entities - handles?
Moderators: SDS, support, admin
Inserting new entities - handles?
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:
And then later:
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
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
Re: Inserting new entities - handles?
I just found it after quite a bit of reading and stumbling:
Code: Select all
cadImage.Converter.SetHandle(entity)