找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1532|回复: 2

[ARX函数]:AcDbRegion:getAreaProp返回的AREA和Centroid值均为0,何故?

[复制链接]
发表于 2004-7-22 23:35:14 | 显示全部楼层 |阅读模式

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

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

×
请问各位高手:下面AcDbRegion:getAreaProp返回的AREA和Centroid值均为0

ads_name en;
    ads_point pt;
        AcDbObjectId eId;
        AcDbRegion *region;
   const AcGePoint3d o;
   const AcGeVector3d x;
   const AcGeVector3d y;
   double perimeter;
   double area,a;
   AcGePoint2d centroid;
   double momInertia[2];
   double prodInertia;
   double prinMoments[2];
   AcGeVector2d prinAxes[2];
   double radiiGyration[2];
   AcGePoint2d extentsLow;
   AcGePoint2d extentsHigh;

    if(acedEntSel("\nSelect an entity: ", en, pt)==RTNORM)
        {
     acdbGetObjectId(eId, en);
     acdbOpenObject(region, eId, AcDb::kForRead);
region->getAreaProp(o,x,y,perimeter,area,centroid,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extentsLow,extentsHigh);
     acutPrintf("\nVertex %10.5f location is: %10.5f, %10.5f", area, centroid [0], centroid [1]);
    }
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-7-26 12:28:31 | 显示全部楼层
我热切期望,我刚学ARX,希望能多看到些源代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 3个

财富等级: 恭喜发财

发表于 2018-11-5 17:20:55 | 显示全部楼层
How to use AcDbRegion::getAreaProp()
By Xiaodong Liang

The first three parameters for the function are described as

- origin Returns origin of the region
- xAxis Returns xAxis of the region
- yAxis Returns yAxis of the region

But considering the const declaration for these parameters
virtual Acad::ErrorStatus getAreaProp(
                           const AcGePoint3d& origin,
                           const AcGeVector3d& xAxis,
                           const AcGeVector3d& yAxis, ... );

It's clear that these three parameters are not output parameters but input parameters. Using parameters that were not initialized properly results in the function returning Acad::eInvalidInput.

Here is a correct application of AcDbRegion::getAreaProp():

// note for code brevity, some error checking are omitted
//
void getRegionAreaProp()
{
    ads_name eNam;
    ads_point pt;
    AcDbObjectId eId;

    if (acedEntSel(L"\nSelect an region: ", eNam, pt) != RTNORM)
    {
        acutPrintf(L"\nNothing selected.");
        return;
    }
    acdbGetObjectId(eId, eNam);

    AcDbEntity* pEnt = NULL;
    if(acdbOpenAcDbEntity(pEnt, eId, AcDb::kForRead) != Acad::eOk)
    {
        acutPrintf(L"\nError open entity.");
        return;
    }
    AcDbRegion* pReg = AcDbRegion::cast(pEnt);
    if(!pReg)
    {
        pEnt->close();
        return;
    }   
    double perimeter, area, momInertia[2],
           prodInertia, prinMoments[2],   
           radiiGyration[2];
    AcGePoint2d centroid, extentsLow, extentsHigh;
    AcGeVector2d prinAxes[2];

    AcGePoint3d origin;
    AcGeVector3d xAxis;
    AcGeVector3d yAxis;

    // initialize the three arguments
    AcGePlane plane;
    pReg->getPlane(plane);
    plane.getCoordSystem(origin, xAxis, yAxis);

    Acad::ErrorStatus es = pReg->getAreaProp(
        // these (3) are the input parameters
        origin, xAxis, yAxis,
        perimeter,
        area,
        centroid,
        momInertia,
        prodInertia,
        prinMoments,
        prinAxes,
        radiiGyration,
        extentsLow,
        extentsHigh);

    assert(es == Acad::eOk);
    // you can determine what to do exactly with the results
    // here I just print a message
    acutPrintf(L"\nSucceded in getting an region's area prop.");
    pReg->close();
}

评分

参与人数 1D豆 +10 收起 理由
XDSoft + 10 很给力!经验;技术要点;资料分享奖!

查看全部评分

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-16 20:42 , Processed in 0.315061 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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