如何读取属性块?
C#开发|冯美娟|2018-07-31 09:34
-
回答:
MxDrawUtility mxUtility = new MxDrawUtility(); MxDrawPoint getPt; MxDrawEntity ent = mxUtility.GetEntity(out getPt, "\n 选择块引用实体:"); if (ent == null) { return; } if (ent is MxDrawBlockReference) { MxDrawBlockReference blkRef = (MxDrawBlockReference)ent; // 读取块名。 mxUtility.Prompt("\n Name" + blkRef.GetBlockName()); for (int j = 0; j < blkRef.AttributeCount; j++) { MxDrawAttribute attrib = blkRef.AttributeItem(j); mxUtility.Prompt("\n Tag: " + attrib.Tag + " Text:" + attrib.TextString ); } // 从块记录中,得到提示文字. MxDrawBlockTableRecord blkRec = blkRef.BlockTableRecord; MxDrawBlockTableRecordIterator iter = blkRec.NewIterator(); for (; !iter.Done(); iter.Step(true, false)) { MxDrawEntity tmpEnt = iter.GetEntity(); if (tmpEnt is MxDrawAttributeDefinition) { MxDrawAttributeDefinition attribDef = (MxDrawAttributeDefinition)(tmpEnt); mxUtility.Prompt("\n Tag: " + attribDef.Tag + " Tip:" + attribDef.Prompt ); } } } else { MessageBox.Show("选择块引用实体"); }