ahlzl大侠,我装了2010,但是Public Overridable Sub CreateLoftedSolid(ByVal crossSectionCurves() As Autodesk.AutoCAD.DatabaseServices.Entity, ByVal guideCurves() As Autodesk.AutoCAD.DatabaseServices.Entity, ByVal pathCurve As Autodesk.AutoCAD.DatabaseServices.Entity, ByVal loftOptions As Autodesk.AutoCAD.DatabaseServices.LoftOptions)要这么多参数,我只要仅横截面放样生成三维实体就可以了,不需要导向线和路径,该怎么写代码呢?我不得已加入导向线和路径参数。但是总有错误生成。不知道怎么回事。代码是这样的。你可以发个放样三维实体的代码样例给我看看吗?不甚感激! <CommandMethod("vv")> Sub nnn() Dim Db As Database = HostApplicationServices.WorkingDatabase Dim Ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor Using Trans As Transaction = Db.TransactionManager.StartTransaction() Try Dim Bt As BlockTable = Trans.GetObject(Db.BlockTableId, OpenMode.ForRead) Dim Btr As BlockTableRecord = Trans.GetObject(Bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite) Dim PL1, PL2 As Polyline Dim Res1 As PromptEntityResult = Ed.GetEntity("选择截面1") If Res1.Status = PromptStatus.OK Then PL1 = CType(Trans.GetObject(Res1.ObjectId, OpenMode.ForWrite), Polyline) End If Dim Res2 As PromptEntityResult = Ed.GetEntity("选择截面2") If Res2.Status = PromptStatus.OK Then PL2 = CType(Trans.GetObject(Res2.ObjectId, OpenMode.ForWrite), Polyline) End If Dim PL3 As Polyline Dim Res3 As PromptEntityResult = Ed.GetEntity("选择路径") If Res3.Status = PromptStatus.OK Then PL3 = CType(Trans.GetObject(Res3.ObjectId, OpenMode.ForWrite), Polyline) End If Dim Guidecur() As Entity '选择导向线 Dim k As Integer = 0 Dim Result As PromptSelectionResult = Ed.GetSelection() If Result.Status = PromptStatus.OK Then Dim sset1 As SelectionSet = Result.Value For Each elem As SelectedObject In sset1 Dim ent As Entity ent = Trans.GetObject(elem.ObjectId, OpenMode.ForWrite, False) If TypeOf ent Is Line Then ReDim Preserve Guidecur(k) Guidecur(k) = CType(ent, Line) k = k + 1 End If Next End If Dim Ents(1) As Entity Ents(0) = PL1 Ents(1) = PL2 Dim LOptB As LoftOptionsBuilder = New LoftOptionsBuilder() Dim LoftSld As Solid3d = New Solid3d()
LoftSld.CreateLoftedSolid(Ents, Guidecur, PL3, LOptB.ToLoftOptions()) Btr.AppendEntity(LoftSld) Trans.AddNewlyCreatedDBObject(LoftSld, True)
Trans.Commit() Catch ex As System.Exception MsgBox("Error: " + ex.Message) Finally End Try End Using End Sub |