Jump to content

Extrude a Region - Need some help on this one.


RMS

Recommended Posts

Basically I am taking points making lines and closing a loop, then creating a Region. But here is the part I am having trouble with, when trying to Extrude the Region I get nothing. Anyone have a solution or fix?

 

Thanks!

 

                       
 Dim acDBObjColl As DBObjectCollection = New DBObjectCollection()
 Dim myRegionColl As DBObjectCollection = New DBObjectCollection()
 Dim acRegion As Region ' = CType(myRegionColl(0), Region)
                       
 Dim solidObj As Solid3d = New Solid3d()

 ' Create a line 
 acLine = New Line(New Point3d(xStart, yStart, zStart), _
                          New Point3d(xClose, yClose, zClose))
 acLine.SetDatabaseDefaults()
 acBlkTblRec.AppendEntity(acLine)
 acTrans.AddNewlyCreatedDBObject(acLine, True)

 acDBObjColl.Add(acLine)

 ' make reagion for each layer
 myRegionColl = Region.CreateFromCurves(acDBObjColl)
 ' Add the new region object to the block table record and the transaction
 acRegion = CType(myRegionColl(0), Region)
 acRegion.ColorIndex = 240 ' = redish
 acBlkTblRec.AppendEntity(acRegion)
 acTrans.AddNewlyCreatedDBObject(acRegion, True)

 'solidObj.SetDatabaseDefaults()
 'solidObj.Extrude(CType(myRegionColl(0), Region), 1.0, 0.0)
 solidObj.Extrude(acRegion, 1.0, 0.0)

 ' Add the new object to the block table record and the transaction
 'acBlkTblRec.AppendEntity(solidObj)
 ' end make region

Link to comment
Share on other sites

It looks like you’ve tried all the right stuff – is it possible that the problem is before or after the posted code block. For example; does acDBObjColl actually contain a closed set of lines?

 

As a general note, not necessarily related to the problem, appending the region to the blocktable record may not be required. See sample:

 

 

    <CommandMethod("ExLines")> _
Public Sub ExtrudeLine()
       Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
       Dim db As Database = ed.Document.Database


       Dim typeValue() As TypedValue = {New TypedValue(0, "LINE")}
       Dim selFilter As SelectionFilter = New SelectionFilter(typeValue)
       Dim selResult As PromptSelectionResult = ed.GetSelection(selFilter)
       Dim ssLine As SelectionSet = selResult.Value
       Dim oids() As ObjectId = ssLine.GetObjectIds

       Using tran As Transaction = db.TransactionManager.StartTransaction
           Dim oid As ObjectId
           Dim objcoll As DBObjectCollection = New DBObjectCollection()
           For Each oid In oids
               objcoll.Add(CType(tran.GetObject(oid, OpenMode.ForRead), Line))
           Next
           Dim regcoll As New DBObjectCollection
           Try
               regcoll = Region.CreateFromCurves(objcoll)
               Dim sol As Solid3d = New Solid3d()
               sol.Extrude(CType(regcoll(0), Region), 1.0, 0.0)
               Dim btr As BlockTableRecord = CType(tran.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
               sol.SetDatabaseDefaults()
               btr.AppendEntity(sol)
               tran.AddNewlyCreatedDBObject(sol, True)
           Catch
               ed.WriteMessage(vbCr & "General modeling failure!")
           Finally
               regcoll.Dispose()
               tran.Commit()
           End Try
       End Using


   End Sub

Link to comment
Share on other sites

Great example, this will help me out big time! I did notice that some of my dot operators are different and also I was not using ObjectId. I can run your example fine on my system, so I should be able to implement this into my code with only minor changes.

 

Thank You

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...