几何尺寸与公差论坛------致力于产品几何量公差标准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:24 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】再谈拖动

再谈拖动
www.dimcax.com
再谈拖动
继承 inherits entityjig 可以实现拖动, 继承 inherits drawjig 也可以实现。 以下代码是通过 继承inherits drawjig 实现
imports system
imports autodesk.autocad.runtime
imports autodesk.autocad.editorinput
imports autodesk.autocad.geometry
imports autodesk.autocad.databaseservices
imports autodesk.autocad.graphicsinterface
imports autodesk.autocad.applicationservices
'new class derrived from the drawjig class
public class jigexample
inherits drawjig
private previouscursorposition as point3d
private currentcursorposition as point3d
private entitytodrag as entity
dim ed as editor = application.documentmanager.mdiactivedocument.editor
<commandmethod("test")> _
public sub startjig()
'initialize cursor position
'use the geometry library to create a new 3d point object
previouscursorposition = new point3d(0, 0, 0)
entitytodrag = new circle(new point3d(0, 0, 0), new vector3d(0, 0, 1), 60)
application.documentmanager.mdiactivedocument.editor.drag(me)
end sub
'you must override this method
protected overloads overrides function sampler(byval prompts as jigprompts) as samplerstatus
'get the current cursor position
dim jigopts as new jigpromptpointoptions()
jigopts.userinputcontrols = (userinputcontrols.accept3dcoordinates or userinputcontrols.nozeroresponseaccepted or userinputcontrols.nonegativeresponseaccepted)
jigopts.message = "" & chr(10) & "enter insert point: "
dim userfeedback as promptpointresult = prompts.acquirepoint(jigopts)
currentcursorposition = userfeedback.value
if cursorhasmoved() then
'get the vector of the move
dim displacementvector as vector3d = currentcursorposition.getvectorto(previouscursorposition)
entitytodrag.transformby(matrix3d.displacement(displacementvector))
'save the cursor position
previouscursorposition = currentcursorposition
return samplerstatus.ok
else
return samplerstatus.nochange
end if
end function
dim jj as integer
'you must override this method
protected overloads overrides function worlddraw(byval draw as worlddraw) as boolean
draw.geometry.draw(entitytodrag)
return true
end function
private function cursorhasmoved() as boolean
return not (currentcursorposition = previouscursorposition)
end function
end class
复制代码
说的对,两种方法都行!我个人更喜欢inherits drawjig 。
两个类好像有差别,entityjig可用于自定义实体,文档上是这样说的!如下:
entityjig wraps the acedjig objectarx class. it may be implemented to provide on-screen editing capabilities for an application's custom entities. the entityjig object lets the user manipulate the graphical representation of a custom entity, and then applies the user's input to an actual instance of the entity.
而对drawjig :
drawjig lets the developer create a jig-based object that can be used to draw graphics and get user input independently of a custom entity.
是不是我说的意思,大家讨论讨论!?
.net暂时还不支持自定义实体。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
恩,是呀,暂时不支持自定义实体,但我前段时间看了看cad dim displacementvector as vector3d = currentcursorposition.getvectorto(previouscursorposition) 这行代码少一个负号。
没有吧,负号放在哪?
用entityjig可以实现的拖动绘制同样可以由drawjig实现,但用drawjig实现的拖动绘制不一定能用entityjig实现。entityjig可以实现一个实体的拖动绘制,drawjig可以实现一个实体和其相关实体(附属子实体或者标注等等)的一并拖动绘制。
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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



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


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