- 积分
- 487
- 明经币
- 个
- 注册时间
- 2005-1-6
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2005-1-7 00:56:00
|
显示全部楼层
本帖最后由 作者 于 2005-1-7 8:26:54 编辑
这个问题不解决好多事都不能做,郁闷:下面这个完整的代码:
// This is command 'D'
void cd()
{
// TODO: Implement the command
// TODO: Implement the command
ads_name en;
double radius, height;
ads_point pt;
AcGePoint3d startPt,endPt,centerPt;
char *str, prompt[256];
AcDbLine *pLine;
AcDbCircle *pCircle;
AcDbText *pText;
if(ads_entsel("\n选择实体:",en,pt)!=RTNORM)
{
ads_printf("没有选择实体\n");
return;
}
AcDbObjectId eld;
acdbGetObjectId(eld,en);
AcDbEntity *pEnt;
acdbOpenObject(pEnt, eld, AcDb::kForWrite);
pEnt->highlight(kNullSubent);
if(strcmp(pEnt->isA()->name(),"AcDbLine")==0)
{
ads_printf(pEnt->linetype());
pEnt->setLinetype("center");
pEnt->setLinetypeScale(5.0);
pLine=AcDbLine::cast(pEnt);
ads_getpoint(NULL,"\起点:",asDblArray(startPt));
pLine->setStartPoint(startPt);
ads_getpoint(NULL,"\n终点:",asDblArray(endPt));
pLine->setEndPoint(endPt);
}
if(strcmp(pEnt->isA()->name(),"AcDbCircle")==0)
{
pCircle=AcDbCircle::cast(pEnt);
centerPt=pCircle->center();
pt[X]=centerPt[X];
pt[Y]=centerPt[Y];
pt[Z]=centerPt[Z];
ads_getpoint(pt,"\n圆心:",asDblArray(centerPt));
ads_getreal("\n半径:",&radius);
pCircle->setCenter(centerPt);
pCircle->setRadius(radius);
}
if(strcmp(pEnt->isA()->name(),"AcDbText")==0)
{
pText=AcDbText::cast(pEnt);
startPt=pText->position();
str=pText->textString();
pt[X]=startPt[X];
pt[Y]=startPt[Y];
pt[Z]=startPt[Z];
ads_getpoint(pt,"\n起点:",asDblArray(startPt));
ads_getreal("\n字高:",&height);
strcpy(prompt,"\ntext<");
strcat(prompt,str);
strcat(prompt,">:");
ads_getstring(NULL,prompt,str);
pText->setPosition(startPt);
pText->setHeight(height);
pText->setTextString(str);
}
pEnt->close();
}
分配的指针也都close()了。可是我在autocad2002下就是不能运行。调试后发现问题也是出在哪个实体选择和取得指针哪里。呜呜~~~
郁闷啊。
请帮忙解决下谢谢
另,又装了autocad 2000,运行后也是内部错误,提示和原因相同~~
|
|