VB.net 在AutoCAD中绘制矩形云线
VB.net 2005 AutoCAD 2010
源代码:
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
'绘制矩形云线
Public Class TcYunXian
' 从DrawJig类继承.
Inherits DrawJig
' 拖拽的对象.
'*****************************
Private Ent(0) As Entity
'*****************************
' 拖拽指向的点.
Private StartPt, EndPt As Point3d
Dim H As Int16 = 90 '绘制云线 线宽
Dim Diameter As Long = 1000 '绘制云线 半圆的直径
'绘制矩形云线
_
Sub YunXian()
On Error Resume Next
'************************
Dim Scale As Double = 1 '绘图比例
H = 90 * Scale
Diameter = 1000 * Scale
If GetPoint(StartPt) = False Then
Exit Sub
End If
'************************
Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
Dim acEditor As Editor = Application.DocumentManager.MdiActiveDocument.Editor
' 开始拖拽.
Dim resJig As PromptResult = acEditor.Drag(Me)
If resJig.Status = PromptStatus.OK Then
'确定后添加对象
Dim N As Int16 = Ent.Length - 1
If N = 0 Then
AddEnt(Ent(0))
Else
Dim EntList(N) As ObjectId
For i As Int16 = 0 To Ent.Length - 1
EntList(i) = AddEnt(Ent(i))
Next
End If
End If
End Sub
' Sampler函数用于检测用户的输入.
Protected Overrides Function Sampler(ByVal Prompts As JigPrompts) As SamplerStatus
' 定义一个点拖动交互类.
Dim o