几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-20, 08:34 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】利用vb写的随鼠标移动的图形

利用vb写的随鼠标移动的图形
www.dimcax.com
利用vb写的随鼠标移动的图形
imports autodesk.autocad.runtime
imports autodesk.autocad.applicationservices
imports autodesk.autocad.editorinput
imports autodesk.autocad.geometry
imports autodesk.autocad.interop
imports autodesk.autocad.interop.common
public class class1
<commandmethod("mtest")> _
public sub test()
dim ed as editor = autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.editor
dim sd as new motionalmousepoint
addhandler ed.pointfilter, addressof sd.getmousepoint
dim pro as promptpointoptions = new promptpointoptions("请选择插入点...")
ed.getpoint(pro)
removehandler ed.pointfilter, addressof sd.getmousepoint
end sub
end class
public class motionalmousepoint
private mousepoint as point3d = new point3d(0, 0, 0) '保存当前鼠标位置
''动态获取鼠标位置
public sub getmousepoint(byval sender as object, byval e as pointfiltereventargs)
mousepoint = e.context.computedpoint
dim m_ed as editor = autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.editor
delegatetest(mousepoint, addressof objectmove2mouse)
end sub
delegate sub mathoperator(byval pt as point3d)
sub delegatetest(byval pt as point3d, byval op as mathoperator)
op.invoke(pt)
end sub
public sub objectmove2mouse(byval pt as point3d)
dim acadapp as acadapplication = ctype(application.acadapplication, acadapplication)
dim acaddoc as acaddocument = acadapp.activedocument
try
static blnfirst as boolean = false
static blnfst as boolean = false
static objtem(2) as acadobject
dim cirobj as acadcircle
dim center(2) as double
dim radius as double
dim lineobj as acadline
dim spnt(2), epnt(2) as double
dim textobj as acadtext
dim istpoint(2) as double
center(0) = pt(0) + 0 : center(1) = pt(1) + 0 : center(2) = pt(2) + 0 : radius = 50
spnt(0) = center(0) : spnt(1) = center(1) : spnt(2) = 0
epnt(0) = center(0) + 100 : epnt(1) = center(1) + 100 : epnt(2) = 0
istpoint(0) = center(0) : istpoint(1) = center(1) : istpoint(2) = center(2)
if blnfirst = true then
for i as integer = 0 to 2
objtem(i).delete() '删除上次绘制的对象
next
cirobj = acaddoc.modelspace.addcircle(center, radius) '创建一个圆对象
cirobj.color = acad_color.acred '将圆的颜色设为红色
lineobj = acaddoc.modelspace.addline(spnt, epnt) '创建一条直线
lineobj.lineweight = acad_lweight.aclnwt060
textobj = acaddoc.modelspace.addtext("哈!成了。", istpoint, 15) '创建单行文字
textobj.color = acad_color.acwhite
objtem(0) = cirobj
objtem(1) = lineobj
objtem(2) = textobj
else
cirobj = acaddoc.modelspace.addcircle(center, radius) '创建一个圆对象
cirobj.color = acad_color.acred '将圆的颜色设为红色
lineobj = acaddoc.modelspace.addline(spnt, epnt) '创建一条直线
lineobj.lineweight = acad_lweight.aclnwt060
textobj = acaddoc.modelspace.addtext("哈!成了。", istpoint, 15) '创建单行文字
textobj.color = acad_color.acwhite
objtem(0) = cirobj
objtem(1) = lineobj
objtem(2) = textobj
blnfirst = true
end if
catch ex as exception
end try
end sub
end class
回复:(scs5999)利用vb写的随鼠标移动的图形加入鼠标事件方法值得借鉴,但采用不断加入数据库对象、再不断删除的方法来实现动态显示的方法不可取
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 03:40 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多