C# 关于属性块中,怎样获取块中每个属性的图层、位置等信息
用C#在开发操作属性块,用代码怎样获取块中每个属性字的图层、位置信息、objectid或句柄等,希望拿到后,对每个属性字进行相应的单独修改,急询!!!求各路大佬回帖,先道谢! 本帖最后由 st788796 于 2021-2-3 16:46 编辑var doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
var peo = new PromptEntityOptions("\npick insert: ");
peo.SetRejectMessage("**only insert**");
peo.AddAllowedClass(typeof(BlockReference), true);
var per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
return;
using (var tr = doc.Database.TransactionManager.StartTransaction())
{
try
{
var blkRef = (BlockReference) tr.GetObject(per.ObjectId, OpenMode.ForRead);
var atts = blkRef.AttributeCollection;
if (atts.Count == 0)
{
ed.WriteMessage("\n0 attribure.");
tr.Abort();
return;
}
foreach (ObjectId id in atts)
{
var att = (AttributeReference) tr.GetObject(id, OpenMode.ForRead);
//start attribute
}
tr.Commit();
}
catch (Exception ex)
{
ed.WriteMessage(ex.ToString());
}
}
st788796 发表于 2021-2-3 16:44
你的代码可以获取到想要的信息,感谢感谢{:1_23:} 用lisp有可能获取块中每个属性的图层、位置等信息吗
页:
[1]