欢迎来到天天文库
浏览记录
ID:40533729
大小:159.77 KB
页数:8页
时间:2019-08-04
《CAD二次实验报告4》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验四用户交互、选择集及扩展属性一、主要内容1、基于用户交互式的信息输入2、创建选择集3、给图形实体添加扩展属性二、学时安排三、预习内容回顾用户交互命令的使用、选择集创建的几种方式,四、实验步骤4.1用户交互Editored=Application.DocumentManager.MdiActiveDocument.Editor;//提示输入圆心坐标PromptPointOptionsfristpoint=newPromptPointOptions("请输入圆心:");……//提示输入半径PromptDoubleOptionsr=newP
2、romptDoubleOptions("请输入圆半径:");……4.1.1读入字符串//获取提示框输入的或点选的坐标PromptPointResultresult=ed.GetPoint(fristpoint);Point3dp=result.Value;4.1.2读入Double型数据//获取输入半径,并转换为double类型PromptDoubleResultTemp_radius=ed.GetDouble(r);//通过PromptDoubleResult下的属性Value转换为.NET下的Double类型doubleradius=
3、Temp_radius.Value;4.1.3读入Point//声明圆对象Circlec=newCircle();c.Center=p;c.Radius=radius;4.1.4拾取实体Entityent=(Entity)acTrans.GetObject(id,OpenMode.ForRead,false);4.1.5打开dwg文件//打开并插入dwg文件[CommandMethod("insertdwg")]staticpublicvoidinsertdwg(){OpenFileDialogpOpenFileDialog=newOpenF
4、ileDialog("打开地形图",null,"dwg","openfile",OpenFileDialog.OpenFileDialogFlags.DefaultIsFolder);pOpenFileDialog.ShowDialog();stringfname=pOpenFileDialog.Filename;Documentdoc=Application.DocumentManager.MdiActiveDocument;Editored=doc.Editor;if(!File.Exists(fname))fname=HostAppli
5、cationServices.Current.FindFile(fname,doc.Database,FindFileHint.Default);using(Databasedb=newDatabase(false,false)){db.ReadDwgFile(fname,FileShare.ReadWrite,true,null);using(Transactiont=doc.TransactionManager.StartTransaction()){intn=fname.LastIndexOf("\");ObjectIdidBTR=d
6、oc.Database.Insert(fname.Substring(n+1,fname.Length-n-5),db,false);BlockTablebt=(BlockTable)t.GetObject(doc.Database.BlockTableId,OpenMode.ForWrite);BlockTableRecordbtr=(BlockTableRecord)t.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite);using(BlockReferencebref
7、=newBlockReference(Point3d.Origin,idBTR)){DBObjectCollectionpbrefColl=newDBObjectCollection();bref.Explode(pbrefColl);intnum=pbrefColl.Count;for(inti=0;i8、获得PickFirst选择集//选择集[CommandMethod("PickFirst",CommandFlags.UsePickSet)]publicvoidC
8、获得PickFirst选择集//选择集[CommandMethod("PickFirst",CommandFlags.UsePickSet)]publicvoidC
此文档下载收益归作者所有