国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

DOTNETARX(一個用于.net開發AutoCAD程序的類庫)實例教學(續)

2024-07-10 13:02:57
字體:
來源:轉載
供稿:網友

本來已寫好中文的,但不知怎么搞的,給弄丟了。先把英文的給發上來,等過段時間我再發中文的。

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    }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 二手房| 嘉定区| 贵德县| 太仆寺旗| 黄梅县| 开原市| 宕昌县| 北安市| 弋阳县| 栾城县| 文水县| 长白| 黔东| 青龙| 汉阴县| 庆安县| 太原市| 昂仁县| 涪陵区| 宜兴市| 屏山县| 建始县| 锡林浩特市| 凌云县| 马龙县| 乌兰县| 吉隆县| 绵竹市| 会理县| 桃源县| 新蔡县| 龙井市| 嘉祥县| 温州市| 临洮县| 赣榆县| 武川县| 来凤县| 日照市| 东港市| 都兰县|