图纸图块名称"/>
Revit开发:获取在Revit上拾取图纸图块名称
直接获取没法得,通过间接临时事务生成模型得到
public static string GetBlockReferenceName(ImportInstance importInstance, Reference reference){var doc = RvtApp.Document;string name = null;GeometryObject go = importInstance.GetGeometryObjectFromReference(reference);using (TransactionGroup tg = new TransactionGroup(doc)){tg.Start("Temp Trans");DirectShape ds = null;using (Transaction trans = new Transaction(doc)){trans.Start("Temp DirectShape");ds = DirectShape.CreateElement(doc,new ElementId(BuiltInCategory.OST_GenericModel), Guid.NewGuid().ToString(),Guid.NewGuid().ToString());ds.AppendShape(new List<GeometryObject>() { go });trans.Commit();}Options options = new Options{ComputeReferences = true,View = doc.ActiveView};var gi = ds.get_Geometry(options).FirstOrDefault(i => i is GeometryInstance) as GeometryInstance;name = gi?.Symbol?.Name;tg.RollBack();}return name;}
更多推荐
Revit开发:获取在Revit上拾取图纸图块名称
发布评论