找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1400|回复: 2

[ARX函数]:求救:AcDbText插入点移动的问题!

[复制链接]
发表于 2003-2-26 17:00:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
大家帮我看看下面的代码,为什么文字的内容修改成功了,但位置还是没有变:(


// 函数名称:f_ent_EditText
// 功能描述:修改文字的内容、插入点(针对AcDbText)
// 输入参数:id --- 文字id
//                         inPt --- 插入点
//                         chText --- 修改内容
// 输出参数:
// 返 回 值:0:失败;1:成功
// 作    者:snowpine
// 时    间:2003-02-25
int f_ent_EditText(AcDbObjectId id, AcGePoint3d inPt, const char *chText)
{
        if(id == NULL)
        {
                return 0;
        }
        //定义变量
        Acad::ErrorStatus        stat;
        AcDbEntity                        *pEnt = NULL;
        AcDbText                        *pText = NULL;

        acutPrintf("\ninPt = %.3f,%.3f", inPt[X], inPt[Y]);
       
        stat = acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite);
        if(stat != Acad::eOk)
        {
                return 0;
        }
       
        //判断是否为AcDbPoint
        if(!pEnt->isKindOf(AcDbText::desc()))
        {
                pEnt->close();
                return 0;
        }
        pText = AcDbText::cast(pEnt);
        pText->setPosition(inPt);//修改位置
        pText->setTextString(chText);//修改文字内容
        pEnt->close();
       
        return 1;
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-2-28 12:06:01 | 显示全部楼层

用setAlignmentPoint试试

Acad::ErrorStatus
setAlignmentPoint(

    const AcGePoint3d& pt);

pt        Input alignment point (WCS) for the text.

This function sets pt to be the alignment point for the text object.
If vertical mode is AcDb::kTextBase and horizontal mode is either AcDb::kTextLeft, AcDb::kTextAlign, or AcDb::kTextFit, then the position point (DXF group code 10) is the insertion point for the text object and, for AcDb::kTextLeft, the alignment point is automatically calculated based on the other parameters in the text object. Any setting made by this function are replaced by the newly calculated value.

For all other vertical and horizontal mode combinations, the alignment point is used as the insertion point of the text and the position point is automatically calculated based on the other parameters in the text object.
The alignment point value is the WCS equivalent of DXF group code 11.
Returns Acad::eOk if successful, or Acad::eNotApplicable if the text object's horizontal mode is AcDb::kTextLeft and vertical mode is AcDb::kTextBase.
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-10-26 17:37:56 | 显示全部楼层
如下:
        AcGePoint3d insertionpoint(pt[X],pt[Y],0.0);
               
        AcDbText* pText = new AcDbText(insertionpoint,str,
                AcDbObjectId::kNull,H,rotation);
        pText->setNormal(normal);
        pText->setHorizontalMode(AcDb::kTextRight);
        pText->setAlignmentPoint(insertionpoint);
//        pText->setTextStyle(set_textstyle());
        pText->setWidthFactor(factor);
    AcDbBlockTable*        pBlockTable;
    acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead);
    AcDbBlockTableRecord*  pBlockTableRecord;
    pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
    pBlockTable->close();
    AcDbObjectId textId;
    pBlockTableRecord->appendAcDbEntity(textId,pText);
    pText->close();
    pBlockTableRecord->close();
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 08:00 , Processed in 0.301065 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表