[求助]怎么样一次性画多条直线,进来看看代码
<p>我想输入两个点的坐标之后出来两条直线,下面是画直线的代码,大家帮我看看</p><p>按照这段代码这样执行的话pLine是一个点,pLine2的直线倒能画出来,请问是怎么回事?</p><p>另ads_point,ads_name的定义哪里有得查啊?</p><p>谢谢</p><p>Acad::ErrorStatus<br/>postToDatabase(AcDbEntity* pEnt,AcDbObjectId& idObj)<br/>{<br/> Acad::ErrorStatus es;<br/> AcDbBlockTable* pBlockTable;<br/> AcDbBlockTableRecord* pSpaceRecord;<br/> if(acdbHostApplicationServices()->workingDatabase()==NULL)<br/> return Acad::eNoDatabase;<br/> if ((es=acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable,AcDb::kForRead))==Acad::eOk)<br/> {<br/> if((es=pBlockTable->getAt(ACDB_MODEL_SPACE,pSpaceRecord,AcDb::kForWrite))==Acad::eOk)<br/> {<br/> if((es=pSpaceRecord->appendAcDbEntity(idObj,pEnt))==Acad::eOk)<br/> pEnt->close();<br/> pSpaceRecord->close();<br/> }<br/> pBlockTable->close();<br/> }<br/> return es;<br/>}<br/>//-----------------以下开始添加直线------------------------------------<br/>Acad::ErrorStatus newLine()<br/>{<br/> ads_point pt1,pt2;<br/> ads_point pt3,pt4;<br/> int retval;<br/> try<br/> {<br/> if((retval=acedGetPoint(NULL, "\nSelect lower left:",pt1))!=RTNORM)<br/> throw retval;<br/> if((retval=acedGetPoint(pt1,"\nSelect upper right:",pt2))!=RTNORM)<br/> throw retval;<br/> }<br/> catch (int e)<br/> {<br/> if(e==RTCAN)<br/> return Acad::eUserBreak ;<br/> if(e==RTERROR)<br/> return Acad::eInvalidInput ;<br/> }<br/> pt3=pt1;<br/> pt3=pt1+10;<br/> pt3=pt1;<br/> pt4=pt1;<br/> pt4=pt1+10;<br/> pt4=pt1;<br/> AcDbLine* pLine =new AcDbLine(asPnt3d(pt1),asPnt3d(pt2));<br/> AcDbLine* pLine2 =new AcDbLine(asPnt3d(pt3),asPnt3d(pt4));<br/> if(!pLine || !pLine2)<br/> {<br/> acedAlert("Not enough memory to create a Line!");<br/> return Acad::eOutOfMemory ;<br/> }</p><p><br/> AcDbObjectId id;<br/> postToDatabase(pLine,id);<br/> return postToDatabase(pLine2,id);</p><p>}<br/></p> <p>自己来坐沙发吧</p><p>pt3=pt1;<br/> pt3=pt1+10;<br/> pt3=pt1;<br/> pt4=pt1;<br/> pt4=pt1+10;<br/> pt4=pt1;<br/></p><p>晕死,这里写错了.应该为</p><p>pt3=pt1;<br/> pt3=pt1+10;<br/> pt3=pt1;<br/> pt4=pt2;<br/> pt4=pt2+10;<br/> pt4=pt2;<br/></p><p>大家还有更好的方法来实现这个多线么?</p> <p>自己沙发了</p><p>pt3=pt1;<br/> pt3=pt1+10;<br/> pt3=pt1;<br/> pt4=pt1;<br/> pt4=pt1+10;<br/> pt4=pt1;<br/>错了,</p><p>应该为</p><p>pt3=pt1;<br/> pt3=pt1+10;<br/> pt3=pt1;<br/> pt4=pt2;<br/> pt4=pt2+10;<br/> pt4=pt2;<br/></p> 既然你直接return不作处理,何必使用try/catch呢? try/catch是捕捉选点的时候的throw阿
页:
[1]