调试autodesk官方例题是的问题
<br/> public ObjectId CreateLayer() //-----------------------------------1-------------------------------<br/> {<br/> ObjectId layerId=new ObjectId(); //它返回函数的值<br/> Database db = HostApplicationServices.WorkingDatabase;<br/> Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;<br/> Transaction trans = db.TransactionManager.StartTransaction();<br/> //首先取得层表……<br/> LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForWrite);<br/> //检查EmployeeLayer层是否存在……<br/> if (lt.Has("EmployeeLayer"))<br/> {<br/> layerId = lt["EmployeeLayer"];<br/> }<br/> else<br/> {<br/> //如果EmployeeLayer层不存在,就创建它<br/> LayerTableRecord ltr = new LayerTableRecord();<br/> ltr.Name = "EmployeeLayer"; //设置层的名字<br/> ltr.Color = Color.FromColorIndex(ColorMethod.ByAci, 2);<br/> layerId = lt.Add(ltr);<br/> trans.AddNewlyCreatedDBObject(ltr, true);<br/> }<br/> trans.Commit();<p> trans.Dispose();<br/> return layerId; //-----------------------------------2-------------------------------<br/> }</p><p>调试时报错,但将程序返回类型改为void:-----1--------处改为public void CreateLayer() ,-------2------处去掉,则可正常建立层,这是为什么?</p><p>另外,要将建立的层设为当前层,我该怎么做?</p> <p>记住他的格式,命令函数必须是无返回值的,呵呵</p><p>将建立的层设为当前层</p><p>Database.Clayer Property</p><p class="Element10">Accesses the object ID of the LAYER specified by the current CLAYER value of the database. </p><p class="Element10">See the System Variables section of the AutoCAD Command Reference for information on CLAYER.</p> <p>谢谢</p>
页:
[1]