几何尺寸与公差论坛------致力于产品几何量公差标准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, 03:08 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】[原创]dotnetarx(一个用于.net开发autocad程序的类库)实例教学(续)

[原创]dotnetarx(一个用于.net开发autocad程序的类库)实例教学(续)
www.dimcax.com
[原创]dotnetarx(一个用于.net开发autocad程序的类库)实例教学(续)本来已写好中文的,但不知怎么搞的,给弄丢了。先把英文的给发上来,等过段时间我再发中文的。
the following functions is provieded in dotnetarx 2.1.
addblocktablerecord
in dotnetarx,you can add the symbol table record using the addsymboltablerecord() function.but the blocktablerecord is different from the other symbol table records.so,you must use the addblocktablerecord() function to add the blocktablerecord.addblocktablerecord() function has two forms.the first one takes the entity array as its argument (which represents the entities that have not added into the autocad database).if you want to add the entities on the screen into the block table record,you will have to use the second one.it takes the objectid of the entities as its argument.
the following example show you how to use addblocktablerecord() to create block table records.
void test() { lines line=new lines(new point3d(0,0,0),new point3d(50,50,0)); circles circle=new circles(new point3d(50,50,0),25); blocktablerecord btr1=new blocktablerecord();//creates a new block table record named block1 btr1.name="block1"; btr1.origin=circle.center; tools.addblocktablerecord(btr1,new entity[]{line,circle}); //adds the line and circle to block1,then adds block1 to the block table of autocad database. promptselectionresult res=tools.editor.getselection();//selects objects on the screen. objectidcollection ids=new objectidcollection(res.value.getobjectids()); //gets the objectids of the selected objects. blocktablerecord btr2=new blocktablerecord();//creates a new block table record named block2 btr2.name="block2"; btr2.origin=new point3d(0,0,0); tools.addblocktablerecord(btr2,ids); //adds the selected objects to block2,then adds block2 to the block table of autocad database. }
coordfrompixeltoworld() and coordfromworldtopixel()
there's no first class .net api to convert pixel to world coordinates and back.special thanks to albert szilvasy on autodesk discussion group providing the way to solve this problem. the following example shows you how to use coordfrompixeltoworld() and coordfromworldtopixel() function to convert pixel to world coordinates and back. note:inorder to use the two functions,you must add the system.drawing.dll assembly to your project.
void test() { editor ed=tools.editor; point3d pt1=ed.getpoint("\nplease select a point:").value; system.drawing.point pix1;//you must add the system.drawing.dll in the reference of your project. tools.coordfromworldtopixel(0,ref pt1,out pix1); ed.writemessage("\npixel coordinate is"+pix1.tostring()+",world coordinate is"+pt1.tostring()); system.drawing.point pix2=new system.drawing.point(100,100); point3d pt2; tools.coordfrompixeltoworld(0,pix2,out pt2); ed.writemessage("\npixel coordinate is"+pix2.tostring()+",world coordinate is"+pt2.tostring()); }
getboundingbox()
in the .net api,the geomextents property of an entity can get the corner points of a box that encloses the 3d extents of the entity.but for dbtext and mtext,the geomextents property always returns the point (0,0,0) for the minpoint of the box.so,dotnetarx provides the getboundingbox() function to let you get the correct corner points of an entity including the dbtext and the mtext object.the return value of getboundingbox() is a point3d array,[0] is the minimum point of the object's bounding box,[1] is the maximum point of the object's bounding box. the following example shows you how to use getboundingbox().
void test() { editor ed=tools.editor; objectid id=ed.getentity("please select an entity on the screen:\n").objectid; //gets the objectid of a selected entity. point3d[] pts=tools.getboundingbox(id);//gets the the two points of a box enclosing the selected entity. lines line=new lines(pts[0],pts[1]);//creates a line to see the output. tools.addentity(line); }
sendcommand and regen
sendcommand() function sends a command string to the current document for processing.
there is no regen function in .net api,so i add the regen() function in dotnetarx.
the following example sends a command for evaluation to the autocad command line of a particular drawing. create a circle in the active drawing and zoom to display the entire circle.
void test() { tools.sendcommand("_circle","2,2,0","4");//you don't need the character "\n" for the return action. tools.sendcommand("_zoom","a"); tools.regen(tools.regentype.allviewports);//refresh view }dotnetarx 2.1 及帮助文档本帖包含附件
( 257.82 kb,已被下载 230 次 )
请使用winrar软件打开rar压缩文件。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
楼主,这个附件是跟6用21号那个 “dotnetarx(就是原来的zhfarx)实例教学”里的区别是什么呢?怎么好象旧版的那个dotnetarx.dll的文件还比较大?
这个是最新的,因为上次的是中文的。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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



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


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