遍历图中的所有实体,找到块名为A23TIT_KH的图块,并得到它的属性
Delphi开发|大少爷|2017-07-27 11:42
-
回答:
procedure TForm1.Button1Click(Sender: TObject); var curDababase : IMxDrawDatabase; modleSpace : IMxDrawBlockTableRecord ; newIterator : IMxDrawBlockTableRecordIterator ; pEnt : IMxDrawEntity; pBlkRef : IMxDrawBlockReference; pAttribute : IMxDrawAttribute; tag : WideString; text : WideString; ii : Integer; fModel : WideString; fTitle : WideString; fDwgNo : WideString; fMaterial : WideString; fQuantity : WideString; fRemark : WideString; fDrawData : WideString; fScale : WideString; fVersion : WideString; fReview : WideString; fDrawName : WideString; fApprove : WideString; begin curDababase := MxDrawApplication1.WorkingDatabase; modleSpace := curDababase.CurrentSpace ; newIterator := modleSpace.NewIterator ; if newIterator <> nil then begin while newIterator.Done() = False do begin pEnt := newIterator.GetEntity(); newIterator.Step(True,False); if pEnt <> nil then begin pEnt.QueryInterface(IMxDrawBlockReference, pBlkRef); if pBlkRef <> nil then begin if pBlkRef.GetBlockName() = 'A23TIT_KH' then begin for ii := 0 to pBlkRef.AttributeCount -1 do begin pAttribute := pBlkRef.AttributeItem(ii); tag := pAttribute.Get_Tag(); text := pAttribute.Get_TextString(); showmessage(tag + ':' + text); case ii of 0: fModel := text; 1: fTitle := text; 2: fDwgNo := text; 3: fMaterial := text; 4: fQuantity := text; 5,6,7: fRemark := fRemark + text + ' '; 8: fDrawData := text; 9: fScale := text; 10: fVersion := text; 11: fReview := text; 12: fDrawName := text; 13: fApprove := text; end; end; end; end; end; end; end; if text = '' then begin showmessage('没有发现块名为' + 'A23TIT_KH' + '的块实体'); end; end;