如何修改块的名称啊?
已知一个块名为b1,如何通过c#或vb.net修改它的名称?大佬,我今天又想了一天,还是实现不了。能不能分享一个在已有块参照中添加指定实体的例子啊?谢谢了 public void Jig2()
{
Database db = HostApplicationServices.WorkingDatabase;//获取当前数据库对象
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = trans.GetObject(bt["b"], OpenMode.ForWrite) as BlockTableRecord ;
Point3d pw1 = new Point3d(0, 0, 0);
Point3d pw2 = new Point3d(0, 100, 0);
Line l1 = new Line(pw1, pw2);
btr.AppendEntity(l1); //新建的实体也加不进来,论坛也看遍了,还是做不到,请大佬在指点指点 ,删除块参照中的实体倒是容易实现
trans.Commit();
}
}
大佬,帮个忙,我想实现一个功能,比如现在的模型空间,有一个块参照“A”,和一条通过选择的得到的直线。怎么把这个直线添加到块参照里面?我自己想了一下,但老是报错,帮我看看吧:
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt["b"], OpenMode.ForWrite) as BlockTableRecord;//b是块参照
PromptSelectionResult ps = ed.SelectAll();
SelectionSet ss = ps.Value;
ObjectIdList sss = ss.GetObjectIds();
List en2 = new List();
Entityent = (Entity)sss.GetObject(OpenMode.ForWrite);//这几步是为了得到直线
btr.AppendEntity(ent);//每次运行到这里就出错了,实在是搞不懂啊(如果是新建直线,圆,都没问题,通过图形选择结果来加就不行了)
trans.Commit();
非常感谢!不愧是大佬 BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = tr.GetObject(bt["a"], OpenMode.ForWrite) as BlockTableRecord;
btr.Name = "b";
晕,原来就这样啊,我还以为先要分解然后重组啥的 上面的方法是把全图块名为 a 的改名为 b ,如果图中有多个块名为a 的图块,而且只想把某一个块改为b ,这种情况应该怎么修改,请老师提供一下思路。谢谢!
BlockReference.BlockTableRecord Property 问题解决,谢谢!! ent2=ent.clone() as entity. btr.appendentity(ent2)
页:
[1]