CAD读取属性块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
                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(truefalse))
                    {
                        MxDrawEntity tmpEnt = iter.GetEntity();
 
                        if (tmpEnt is MxDrawAttributeDefinition)
                        {
                            MxDrawAttributeDefinition attribDef = (MxDrawAttributeDefinition)(tmpEnt);
 
                            mxUtility.Prompt("\n Tag: " + attribDef.Tag + " Tip:" + attribDef.Prompt
                           
                           );
 
                        }
 
                    }
 
 
 
                }
                else
                {
                    MessageBox.Show("选择块引用实体");
                }

posted on 2019-06-06 13:58  梦想CAD控件  阅读(649)  评论(0)    收藏  举报

导航