CAD向块引用中增一个属性定义对象

本文详细介绍了IMxDrawBlockReference::AppendAttribute方法的使用,该方法用于在块引用中添加属性定义对象。通过Delphi示例代码展示了如何设置属性的位置、旋转、高度及文本等,为CAD开发提供了实用指导。

IMxDrawBlockReference::AppendAttribute 方法

向块引用中增一个属性定义对象。

参数 

说明 

[out,retval] IMxDrawAttribute** ppNewAttribute 

返回新的属性定义对象 

例如:Delphi中的例程:

    procedure TForm1.DoInsertFlagClick();
    var
            ptInsert        : OleVariant;
            pt              :  IMxDrawPoint ;
            lId             : Integer;
            curDababase  : IMxDrawDatabase;
            pObj            : IMxDrawMcDbObject;
            pBlkRef       : IMxDrawBlockReference;
            pAtrribText   : IMxDrawAttribute;
    begin


        ptInsert := mxUtility.GetPoint(EmptyParam,'点插入点');

        pt:=IMxDrawPoint(IDisPatch(ptInsert));

        if pt = nil then
            EXIT;

        MxDrawX1.InsertBlock(MxDrawX1.GetOcxAppPath() + 'blkTsgNote.dwg','Flag');

        lId := MxDrawX1.DrawBlockReference(pt.Get_x(),pt.Get_y(),'Flag',10.0,0.0);

        curDababase := IMxDrawDatabase(MxDrawX1.GetDatabase() );

        if    curDababase = nil then
            EXIT;
        pObj := curDababase.ObjectIdToObject(lId);

        pObj.QueryInterface(IMxDrawBlockReference, pBlkRef);
        if pBlkRef <> nil then
        begin
        pBlkRef.Set_Position(pBlkRef.Position);
           pAtrribText :=  pBlkRef.AppendAttribute();
            if pAtrribText <> nil then
            begin

                    pAtrribText.Set_Oblique(0.0);

                    pAtrribText.Set_Position(pt);
               pAtrribText.Set_AlignmentPoint(pt);
                    pAtrribText.Set_Rotation(0.0);
                    pAtrribText.Set_Height(2.0);
                    //pAtrribText.TrueColor.SetRGB(255,0,0);

                    pAtrribText.Set_TextString('这是一个属性文字的测试');

                    pAtrribText.Set_Tag('TestTag');
                    pAtrribText.Set_IsInvisible(false);

                    pBlkRef.Set_Position(pBlkRef.Position);
            end;
        end;

    end;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值