By Adam Nagy
I have two rectanlges and I would like to create a lofted solid from them. I tried the below code and played with the input parameters but it just does not seem to work. Could you provide a sample?
...
Dim vol As New DatabaseServices.Solid3d()
vol.CreateLoftedSolid(New DatabaseServices.Entity() {e1, e2},
Nothing, Nothing, Nothing)
...
Solution
The only parameter for CreateLoftedSolid that can be null/Nothing is the pathCurve parameter.
Knowing that you can modify the code like this.
Note: please pick the entities in this order: rectangle 1, rectangle 2, path.
Imports acApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Public Class Commands
_
Public Sub CreateLoft()
Dim ed As Editor = acApp.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim psr As PromptSelectionResult = ed.GetSelection()
If psr.Status PromptStatus.OK Or psr.Value.Count 3 Then
Return
End If
Using tr As Transaction =
db.TransactionManager.StartTransaction()
Dim ent1 As Entity =
tr.GetObject(psr.Value(0).ObjectId, OpenMode.ForRead)
Dim ent2 As Entity =
tr.GetObject(psr.Value(1).ObjectId, OpenMode.ForRead)
Dim path As Entity =
tr.GetObject(psr.Value(2).ObjectId, OpenMode.ForRead)
Dim sld As New Solid3d
Dim options As New LoftOptions
' In case of this specific drawing passing in Nothing as
' path would give similar results
sld.CreateLoftedSolid(New Entity() {ent1, ent2},
New Entity() {}, path, options)
Dim bt As BlockTable =
tr.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim ms As BlockTableRecord =
tr.GetObject(bt(BlockTableRecord.ModelSpace),
OpenMode.ForWrite)
ms.AppendEntity(sld)
tr.AddNewlyCreatedDBObject(sld, True)
tr.Commit()
End Using
End Sub
End Class
I tested the above code with the following drawing: Download Rectangles

Leave a Reply