
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm using this code below to create a region of an existing polygon. When I run this code it creates a region ok but it creates the region as a new entity and duplicates the polygon. Is there a way to covert the selected polygon into a region with out duplicating?
<CommandMethod("CreateRegion")>
Public Sub CreateRegion()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
'Dim copied As ObjectIdCollection = New ObjectIdCollection()
'******Prompt user to select objects
Dim psr As PromptSelectionResult = doc.Editor.GetSelection()
'Dim acSSet As SelectionSet = psr.Value
If psr.Status = PromptStatus.OK Then
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim curves = New DBObjectCollection()
For Each obj As SelectedObject In psr.Value
curves.Add(tr.GetObject(obj.ObjectId, OpenMode.ForRead))
Dim regions = Region.CreateFromCurves(curves)
Dim curSpace As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
For Each region In regions
curSpace.AppendEntity(region)
tr.AddNewlyCreatedDBObject(region, True)
Next
Next
tr.Commit()
ed.WriteMessage("Region created")
End Using
End If
End Sub
Thanks
Shaban.
Solved! Go to Solution.