AutoCAD 二次开发封装动态JIG
更新时间:2023-11-17 06:59:01 阅读量: 教育文库 文档下载
- autocad推荐度:
- 相关推荐
使用VB.Net开发AutoCAD 2010 ,动态拖动类的封装代码 Imports System
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.GraphicsInterface Imports Autodesk.AutoCAD.Runtime Imports System.Drawing Imports System.Windows.Forms '''
''' 封装简化Jig操作,函数式实现DrawJig '''
'''
Private Delegate Function AcquireMod(prompts As JigPrompts) As SamplerStatus
Private Shared _rstAsPromptResult
Private Shared _point3d As Point3d
Private Shared _PointOptionsAsJigPromptPointOptions
Private Shared _double As Double
Private Shared _DistanceOptionsAsJigPromptDistanceOptions
Private Shared _AngleOptionsAsJigPromptAngleOptions
Private Shared _cur As Point
Private Shared _StringOptionsAsJigPromptStringOptions
Private Shared _callBack As Action(Of Drag.Result)
Private Shared _acquireModAsDrag.AcquireMod
Protected Sub New()
End Sub
Protected Overrides Function WorldDraw(draw As WorldDraw) As Boolean
Drag._callBack(New Drag.Result(Drag._rst, draw))
Return True
End Function
Protected Overrides Function Sampler(prompts As JigPrompts) As SamplerStatus
Return Drag._acquireMod(prompts)
End Function
#Region \定义各种Jig模式\
Private Shared Function GetPoint(prompts As JigPrompts) As SamplerStatus
Dim rst As PromptPointResult = prompts.AcquirePoint(Drag._PointOptions)
Drag._rst = rst
If rst.Value<> Drag._point3d Then
Drag._point3d = rst.Value
Return SamplerStatus.OK
Else
Return SamplerStatus.NoChange
End If
End Function
Private Shared Function GetDistance(prompts As JigPrompts) As SamplerStatus
Dim
rst
As
PromptDoubleResult
prompts.AcquireDistance(Drag._DistanceOptions)
Drag._rst = rst
If rst.Value<>Drag._double Then
Drag._double = rst.Value
Return SamplerStatus.OK
Else
=
Return SamplerStatus.NoChange
End If
End Function
Private Shared Function GetAngle(prompts As JigPrompts) As SamplerStatus
Dim rst As PromptDoubleResult = prompts.AcquireAngle(Drag._AngleOptions)
Drag._rst = rst
If rst.Value<>Drag._double Then
Drag._double = rst.Value
Return SamplerStatus.OK
Else
Return SamplerStatus.NoChange
End If
End Function
Private Shared Function GetString(prompts As JigPrompts) As SamplerStatus
Dim rst As PromptResult = prompts.AcquireString(Drag._StringOptions)
Drag._rst = rst
Dim cur As Point = Control.MousePosition
If Control.MousePosition<>Drag._cur Then
Drag._cur = cur
Return SamplerStatus.OK
Else
Return SamplerStatus.NoChange
End If
End Function
#End Region
'''
''' ''' '''
Public Shared Function StartDrag(options As JigPromptOptions, Action(Of Drag.Result)) As PromptResult
If TypeOf options Is JigPromptPointOptions Then
_PointOptions = (TryCast(options, JigPromptPointOptions))
_acquireMod = New AcquireMod(AddressOfGetPoint)
ElseIfTypeOf options Is JigPromptDistanceOptions Then
callFun As
_DistanceOptions = (TryCast(options, JigPromptDistanceOptions))
_acquireMod = New Drag.AcquireMod(AddressOfGetDistance)
ElseIfTypeOf options Is JigPromptAngleOptions Then
_AngleOptions = (TryCast(options, JigPromptAngleOptions))
_acquireMod = New AcquireMod(AddressOfGetAngle)
ElseIfTypeOf options Is JigPromptStringOptions Then
_StringOptions = (TryCast(options, JigPromptStringOptions))
_acquireMod = New AcquireMod(AddressOfGetString)
End If
_callBack = callFun
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocum
ent.Editor.Drag(New Drag())
_callBack(New Result(_rst, Nothing))
Return _rst
End Function
'''
''' 执行Jig拖动[Point模式] '''
''' ''' ''' '''
Public Shared Function StartDrag(msg As String, kwd As String, callFun As Action(Of Drag.Result)) As PromptResult
Return StartDrag(New JigPromptPointOptions(msg, kwd), callFun)
End Function
'''
''' 执行Jig拖动[Point模式] '''
''' ''' '''
Public Shared Function StartDrag(msg As String, callFun As Action(Of Drag.Result)) As PromptResult
Return Drag.StartDrag(New JigPromptPointOptions(msg), callFun)
End Function
'''
'''
Private rstAsPromptResult
Private draw AsWorldDraw
Public ReadOnly Property PromptResult() As PromptResult
Get
Return rst
End Get
End Property
Public ReadOnly Property Geometry() As Geometry
Get
Return Me.draw.Geometry
End Get
End Property
Public ReadOnly Property Point() As Point3d
Get
Return Drag._point3d
End Get
End Property
Public ReadOnly Property Dist() As Double
Get
Return Drag._double
End Get
End Property
Public ReadOnly Property Angle() As Double
Get
Return Drag._double
End Get
End Property
Public ReadOnly Property Status() As PromptStatus
Get
Return rst.Status
End Get
End Property
Public ReadOnly Property [String]() As String
Get
Return rst.StringResult
End Get
End Property
Friend Sub New(promptResult As PromptResult, worldDraw As WorldDraw)
rst = promptResult
draw = worldDraw
End Sub
Public Sub DrawEnt(entity As Drawable)
If draw IsNotNothing Then
draw.Geometry.Draw(entity)
End If
End Sub
End Class
End Class
测试代码:
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.GraphicsInterface Imports Autodesk.AutoCAD.Runtime Imports YJSCAD Public Class Class1 Dim cir As New Circle(New Point3d(), Vector3d.ZAxis, 10.0) If Drag.StartDrag(vbCrLf& \指定圆中心点\cir.Center = rst.Point rst.DrawEnt(cir) End Sub).Status = PromptStatus.OK Then Dim result As PromptResult = Drag.StartDrag(New JigPromptDistanceOptions(vbCrLf& \指定圆半径\ Sub(rst As Drag.Result) cir.Radius = If((rst.Dist = 0), 0.000001, rst.Dist) rst.DrawEnt(cir) If result.Status = PromptStatus.OK Then ShareTool.AddToModelSpace(cir) End If End If End Sub End Class End Sub) Sub(rst As Drag.Result) cir.Radius = If((rst.Dist = 0), 0.000001, rst.Dist) rst.DrawEnt(cir) If result.Status = PromptStatus.OK Then ShareTool.AddToModelSpace(cir) End If End If End Sub End Class End Sub)
正在阅读:
AutoCAD 二次开发封装动态JIG11-17
南京信息工程大学《模拟电子技术基础》期末考试试卷A卷及答案12-05
ES品牌 秋冬产品开发方案05-29
甘肃省C类安全员证书模拟试题03-04
钉支护在深基坑护壁中的运用05-10
社区民警入党转正申请书范文(19)09-08
宝钢湛江培训复习题01-21
外婆的菊花作文500字06-23
心理团训策划09-27
中国工商银行个人理财产品分析报告12-15
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 封装
- AutoCAD
- 动态
- 开发
- JIG
- 人教版《道德与法治》七年级上册重要知识点汇总 doc
- 安全仪表系统(SIS)技术规格书
- 大学学报
- 审计理论与审计案例分析模拟试卷-(1)
- 松滋市疾控中心、卫生监督局创建级文明城市实施方案
- 国民经济核算期末复习指导计算题
- 1表哥驾到
- 中铁上海工程局沈南污水处理厂项目 - --提高北方地区大体积薄壁自防水砼施工质量 - 图文
- 无机化学实验讲义
- 依其星宿可断其日之行事吉凶
- 2012年福建高考语文试卷及详细答案(福建卷)
- 国际贸易实务练习及答案价格条款
- 华为工程督导服务规范试题(B卷)
- 高密度脂蛋白胆固醇偏低解决方案
- 罗维朋比色计使用方法
- 中南大学钢结构设计原理考题题库
- 蛋白纯化学习笔记
- 更换及调整自行车V刹图文教程
- 九年级下 二次函数 全章教案
- 地籍管理学试题