日期:2012-06-03 浏览次数:20548 次
本来已写好中文的,但不知怎么搞的,给弄丢了。先把英文的给发上来,等过段时间我再发中文的。
The following functions is provieded in DOTNETARX 2.1.
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. }
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()); }