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
<CommandMethod("CreateLoft")> _
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
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Public Class Commands
<CommandMethod("CreateLoft")> _
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
[本日志由 tiancao1001 于 2014-01-28 06:44 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |