- 积分
- 489
- 明经币
- 个
- 注册时间
- 2008-11-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2010-5-12 14:14:00
|
显示全部楼层
不是nothing,如果这样的话,提示:“未将对象引用设置到对象的实例”。不知道怎么改了。- Imports Autodesk.AutoCAD.ApplicationServices
- Imports Autodesk.AutoCAD.Colors
- Imports Autodesk.AutoCAD.DatabaseServices
- Imports Autodesk.AutoCAD.EditorInput
- Imports Autodesk.AutoCAD.Geometry
- Imports Autodesk.AutoCAD.Runtime
- Imports Autodesk.AutoCAD.GraphicsSystem
- Imports Autodesk.AutoCAD.Windows
- Imports Autodesk.AutoCAD.Publishing
- Imports Autodesk.AutoCAD.PlottingServices
- Imports Autodesk.AutoCAD.ComponentModel
- Imports Autodesk.AutoCAD.LayerManager
- Public Class Class1
- <CommandMethod("tt")> _
- Sub 天圆地方()
- Try
- Dim Ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
- Dim db As Database = HostApplicationServices.WorkingDatabase
- Dim ent1 As Polyline = New Polyline()
- ent1.AddVertexAt(0, New Point2d(50, 50), 0, 0, 0)
- ent1.AddVertexAt(1, New Point2d(-50, 50), 0, 0, 0)
- ent1.AddVertexAt(2, New Point2d(-50, -50), 0, 0, 0)
- ent1.AddVertexAt(3, New Point2d(50, -50), 0, 0, 0)
- ent1.Closed = True
- Dim ent2 As Circle = New Circle(New Point3d(0, 0, 200), New Vector3d(0, 0, 1), 30)
- Dim crossEnts(1) As Entity
- crossEnts.SetValue(ent1, 0)
- crossEnts.SetValue(ent2, 1)
- Dim guideCurs(0) As Entity
- Dim loftOpt As LoftOptions = New LoftOptions()
- Dim solid3dEnt As Solid3d = New Solid3d()
- solid3dEnt.RecordHistory = True
- solid3dEnt.CreateLoftedSolid(crossEnts, guideCurs, Nothing, loftOpt)
- AppendEntity(ent1)
- Catch ex As System.Exception
- MsgBox("Error: " + ex.Message)
- Finally
- End Try
- End Sub
- Function AppendEntity(ByVal ent As Entity) As ObjectId
- Dim db As Database = HostApplicationServices.WorkingDatabase
- Dim entId As ObjectId
- Using trans As Transaction = db.TransactionManager.StartTransaction()
- Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
- Dim Btr As BlockTableRecord = trans.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
- entId = Btr.AppendEntity(ent)
- trans.AddNewlyCreatedDBObject(ent, True)
- trans.Commit()
- End Using
- Return entId
- End Function
- End Class
|
|