几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(C++)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-14, 02:49 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】acdbface面域问题??????

acdbface面域问题??????
acdbface面域问题??????
我问过这个问题了,但是还不明白。请版主帮忙解释一下:
一下是我的做法,不知道为什么求不出面积。
acgepoint3d pa(0,0,0),pb(100,0,0),pc(100,100,0),pd(0,100,0);
acdbface *pface=new acdbface(pa,pb,pc,pd);
posttodatabase(pface,faceid);
ads_point pt1,pt2,pt;
acgepoint2darray point_array;
int stat=1;
stat=acedgetpoint(null,"选择点(esc结束)\n",pt1);
if(stat==rtcan)
return;
point_array.append(aspnt2d(pt1));
while(1)
{
acdbpointset(pt1, pt2);
stat=acedgetpoint(pt1,"选择点,(esc结束)\n",pt1);
acedgrdraw(pt2, pt1, 1, 0);
if(stat==rtcan)
break;
point_array.append(aspnt2d(pt1));
}
acdbpolyline *closepolyline=new acdbpolyline();
for(int i=0;i<point_array.length();i++)
{
acgepoint2d ptmp=point_array.at(i);
closepolyline->addvertexat(i,ptmp,0,-1,-1);
}
closepolyline->setcolorindex(1);
closepolyline->setclosed(adesk::ktrue);
posttodatabase(closepolyline,idobj);
acdbopenacdbentity(pent,idobj,acdb::kforread);
acdbpolyline *ppoly=acdbpolyline::cast(pent);
acdbvoidptrarray entities,regions;
entities.append(pface);
entities.append(ppoly);
acdbregion::createfromcurves(entities, regions);
if (regions.length() < 1)
{
acutprintf("构造闭合区域错误\n");
}
assert(pregion != null);
acdbregion *pregion = new acdbregion;

for ( i = 0; i < regions.length(); i++)
{
if(acad::eok!=preg->booleanoper(acdb::kboolintersect,(acdbregion*) regions[i]))
acutprintf("有问题\n");
delete (acrxobject*)regions[i];

}
double regarea;
preg->getarea(regarea);
preg->close();
acutprintf("area=%0.3f\n",regarea);
请高手指出错误。
回复
能贴出你完整的代码吗?
没做过,只能帮你调试一下了.
change your life style.
上面基本的程序放到一个函数里面即可。
告诉我做法了,但是我没有求出结果。
基本思想。就是两个实体(闭合的)然后求出图形交集部分的面积
回复
这里
= acedgetpoint(pick, "选择下一点(esc-quit): ", pick);
stat=acedgetpoint(pt1,"选择点,(esc结束)\n",pt1);
是什么? file:这一行需要吗?
posttodatabase也是未声明的?
很多未声明的标识符!
change your life style.
那是注释掉得语句。粘贴到帖子上就加了file。不要。
posttodatabase()是把该实体添加到图形数据库中
回复
没法调试, 这段代码中很多变量都是没有声明的.
posttodatabase
idobj
pent
pregion
preg
...
因为我没做过,所以看不出应该怎么改.
posttodatabase是个自定义的函数
acad::errorstatus posttodatabase(acdbentity* ent, acdbobjectid& objid)
{
// given an entity, this function will post it to the database
// in model_space and then return the objectid; returns eok if
// all went well.

acad::errorstatus es;
acdbblocktable* pblocktable;
acdbblocktablerecord* pspacerecord;

es = acdbhostapplicationservices()->workingdatabase()
->getsymboltable(pblocktable, acdb::kforread);
assert(es == acad::eok);

es = pblocktable->getat(acdb_model_space, pspacerecord, acdb::kforwrite);
assert(es == acad::eok);

es = pblocktable->close();
assert(es == acad::eok);

es = pspacerecord->appendacdbentity(objid, ent);
assert(es == acad::eok);

es = ent->close();
assert(es == acad::eok);

es = pspacerecord->close();
assert(es == acad::eok);

return es;
}
change your life style.
不好意思。我再发一次
void appmytoolcloreg()
{
ads_point pt1,pt2,pt;
acgepoint2darray point_array;
acdbobjectid idobj,faceid;
acdbentity *pent=null;
acgepoint3d pa(0,0,0),pb(100,0,0),pc(100,100,0),pd(0,100,0);
acdbface *pface=new acdbface(pa,pb,pc,pd);
posttodatabase(pface,faceid);
int stat=1;
stat=acedgetpoint(null,"选择点(esc结束)\n",pt1);
if(stat==rtcan)
return;
point_array.append(aspnt2d(pt1));
while(1)
{
acdbpointset(pt1, pt2);
stat=acedgetpoint(pt1,"选择点,(esc结束)\n",pt1);
acedgrdraw(pt2, pt1, 1, 0);
if(stat==rtcan)
break;
point_array.append(aspnt2d(pt1));
}
acdbpolyline *closepolyline=new acdbpolyline();
for(int i=0;i<point_array.length();i++)
{
acgepoint2d ptmp=point_array.at(i);
closepolyline->addvertexat(i,ptmp,0,-1,-1);
}
closepolyline->setcolorindex(1);
closepolyline->setclosed(adesk::ktrue);
posttodatabase(closepolyline,idobj);//添加实体数据库中
acdbopenacdbentity(pent,idobj,acdb::kforread);
acdbpolyline *ppoly=acdbpolyline::cast(pent);
acdbvoidptrarray entities,regions;
entities.append(pface);
entities.append(ppoly);
acdbregion::createfromcurves(entities, regions);
if (regions.length() < 1)
{
acutprintf("构造闭合区域错误\n");
}
assert(pregion != null);
acdbregion *pregion = new acdbregion;

for ( i = 0; i < regions.length(); i++)
{

if(acad::eok!=pregion->booleanoper(acdb::kboolintersect,(acdbregion*)regions[i]))
acutprintf("有问题\n");
delete (acrxobject*)regions[i];

}
double regarea;
pregion->getarea(regarea);
pregion->close();
pent->close();
acutprintf("area=%0.3f\n",regarea);
}
acad::errorstatus
posttodatabase(/*[in]*/acdbentity* pent,/*[out]*/acdbobjectid& idobj)
{
acad::errorstatus es;
acdbblocktable* pblocktable;
acdbblocktablerecord* pspacerecord;

if (acdbhostapplicationservices()->workingdatabase()==null)
return acad::enodatabase;


if ((es = acdbhostapplicationservices()->workingdatabase()->getblocktable(pblocktable, acdb::kforread))==acad::eok){


if ((es = pblocktable->getat(acdb_model_space, pspacerecord, acdb::kforwrite))==acad::eok){


if ((es = pspacerecord->appendacdbentity(idobj, pent))==acad::eok)
pent->close();
pspacerecord->close();
}
pblocktable->close();
}
return es;
}
先求交点,再创建一个新的面或多线段,面积就出来了
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 03:01 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多