In my opnion, there's no need to explode the polyline, it can be passed as is to the Region.CreateFromCurves() method.

Anyway, you may explicitely dispose the DBObjectCollections (lines and regions) in case ther're some objects left for which no managed wrapper have been created.You must explicitely dispose each region used to create a solid as a managed wrapped is creadted and is not added to the Database (the same for the curves used to create the region as you explode the polyline).

The following code is extract from a topic at TheSwamp about "To dispose or not To Dispose" (reply #82). It's quite closed to yours and try to cover most of the 'disposing or not' issues.

// Dispose DBObjectCollection in case there're some objects left // for which no managed wrapper have been created using (DBObjectCollection plineCollection = new DBObjectCollection()) { plineCollection.Add(pline);

// Dispose DBObjectCollection in case there're some objects left // for which no managed wrapper have been created using (DBObjectCollection regionCollection = Region.CreateFromCurves(plineCollection)) { // Always dispose an object contained in a DBObjectCollection // for which a managed wrapper is created and isn't added to the database using (Region region = (Region)regionCollection[0]) { // Use Dispose to insure the new DBObject will be disposed // if an exception occurs before it is added to the Database using (Solid3d solid = new Solid3d()) { solid.Extrude(region, 30.0, 0.0); currentSpace.AppendEntity(solid); tr.AddNewlyCreatedDBObject(solid, true); } } } } if ((short)Application.GetSystemVariable("DELOBJ") == 0) { currentSpace.AppendEntity(pline); tr.AddNewlyCreatedDBObject(pline, true); } } tr.Commit(); } }F#

// Dispose DBObjectCollection in case there're some objects left // for which no managed wrapper have been created use plineCollection = new DBObjectCollection() plineCollection.Add(pline) |> ignore

// Dispose DBObjectCollection in case there're some objects left // for which no managed wrapper have been created use regionCollection = Region.CreateFromCurves(plineCollection)

// Always dispose an object contained in a DBObjectCollection // for which a managed wrapper is created and isn't added to the database use region = regionCollection.[0] :?> Region

// Use Dispose to insure the new DBObject will be disposed // if an exception occurs before it is added to the Database use solid = new Solid3d() solid.Extrude(region, 30.0, 0.0) currentSpace.AppendEntity(solid) |> ignore tr.AddNewlyCreatedDBObject(solid, true)

' Dispose DBObjectCollection in case there're some objects left ' for which no managed wrapper have been created Using plineCollection As New DBObjectCollection() plineCollection.Add(pline)

' Dispose DBObjectCollection in case there're some objects left ' for which no managed wrapper have been created Using regionCollection As DBObjectCollection = _ Region.CreateFromCurves(plineCollection)

' Always dispose an object contained in a DBObjectCollection ' for which a managed wrapper is created and isn't added to the database Using region As Region = DirectCast(regionCollection(0), Region)

' Use Dispose to insure the new DBObject will be disposed ' if an exception occurs before it is added to the Database Using solid As New Solid3d() solid.Extrude(region, 30.0, 0.0) currentSpace.AppendEntity(solid) tr.AddNewlyCreatedDBObject(solid, True) End Using End Using End Using End Using If CShort(Application.GetSystemVariable("DELOBJ")) = 0 Then currentSpace.AppendEntity(pline) tr.AddNewlyCreatedDBObject(pline, True) End If End Using tr.Commit() End Using End Using End Sub