挤出一个区域-需要一些h
基本上,我取点,画线,闭合一个环,然后创建一个区域。但这是我遇到麻烦的部分,当试图挤出该区域时,我一无所获。有人有解决方案或修复方法吗?谢谢
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
看起来您已经尝试了所有正确的方法-问题可能是在发布的代码块之前还是之后。例如acDBObjColl实际上是否包含一组封闭的行?
一般来说,不一定与问题有关,可能不需要将区域附加到块表记录。参见示例:
<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 很好的例子,这将帮助我度过难关!我确实注意到我的一些点运算符是不同的,而且我没有使用ObjectId。我可以在我的系统上很好地运行您的示例,因此我应该能够在代码中实现这一点,只需稍作更改。
非常感谢。
页:
[1]