直线、圆弧如何转换成多义线
<p>如题<font face="Verdana">直线(<font face="Verdana">AcDbLine</font>)<font face="Verdana">圆弧</font>(<font face="Verdana">AcDbArc</font>)如何转换成多义线(<font face="Verdana">AcDbPolyline</font>)?</font></p><p>我想给直线添加宽度,故转换为多义线(<font face="Verdana">pline->setLineWeight()不是我的答案</font>)</p>
<p>我想用多义线的<font face="Verdana">pPolyline->setWidthsAt(i,PL_Width,PL_Width);</font></p>
<p>跪求转换方法,</p> <p><font face="Verdana">AcDbObjectId PostToMS(AcDbEntity *pEnt)<br/>{<br/> AcDbBlockTable *pBlkTbl;<br/> acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl,<br/> AcDb::kForRead);<br/> AcDbBlockTableRecord *pMS;<br/> pBlkTbl->getAt(ACDB_MODEL_SPACE,pMS,AcDb::kForWrite);<br/> pBlkTbl->close();<br/> AcDbObjectId EntID;<br/> pMS->appendAcDbEntity(EntID,pEnt);<br/> pMS->close();<br/> return EntID;<br/>}</font></p>
<p> </p>
<p><font face="Verdana">static void ROYMyTest_test1(void)<br/> {<br/> // Add your code for command ROYMyTest._test1 here<br/> ads_point pt;<br/> ads_name ename;<br/> AcDbObjectId EntID;<br/> AcDbEntity *pEnt=NULL;<br/> if (acedEntSel(_T("\nSelect a line or arc:"),ename,pt)!=RTNORM<br/> || acdbGetObjectId(EntID,ename)!=Acad::eOk<br/> || acdbOpenAcDbEntity(pEnt,EntID,AcDb::kForRead)!=Acad::eOk)<br/> return;<br/> if (!(pEnt->isKindOf(AcDbLine::desc()) || pEnt->isKindOf(AcDbArc::desc())))<br/> {<br/> pEnt->close();<br/> return;<br/> }<br/> AcDbLine *pLine;<br/> AcDbArc *pArc;<br/> AcGePoint3d ptStart,ptEnd;<br/> double dBugle,startAngle,endAngle,dAngle;<br/> if (pEnt->isKindOf(AcDbLine::desc()))<br/> {<br/> pLine=AcDbLine::cast(pEnt);<br/> if (pLine!=NULL)<br/> {<br/> ptStart=pLine->startPoint();<br/> ptEnd=pLine->endPoint();<br/> dBugle=0;<br/> }<br/> }<br/> else<br/> {<br/> pArc=AcDbArc::cast(pEnt);<br/> if (pArc!=NULL)<br/> {<br/> pArc->getStartPoint(ptStart);<br/> pArc->getEndPoint(ptEnd);<br/> startAngle=pArc->startAngle();<br/> endAngle=pArc->endAngle();<br/> if (endAngle<startAngle)<br/> endAngle+=8*atan(1.0);<br/> dAngle=endAngle-startAngle;<br/> dBugle=tan(dAngle/4);<br/> }<br/> }<br/> if (pEnt->upgradeOpen()!=Acad::eOk)<br/> {<br/> pEnt->close();<br/> return;<br/> }<br/> pEnt->erase();<br/> pEnt->close();</font></p>
<p><font face="Verdana"> AcDbPolyline *pPLine;<br/> pPLine=new AcDbPolyline(2);<br/> pPLine->addVertexAt(0,asPnt2d(asDblArray(ptStart)),dBugle);<br/> pPLine->addVertexAt(1,asPnt2d(asDblArray(ptEnd)));<br/> PostToMS((AcDbEntity*)pPLine);<br/> pPLine->close();<br/> }</font></p> <p>以上代码仅供参考!</p> <p>首先感谢
<table style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" class="bbslist100 tableborder" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="BORDER-BOTTOM: #e4e7ec 1px="1px"solid; BACKGROUND: #fafdff" class="infoleft leftcolor" valign="center"><img alt="帅哥哟,离线,有人找我吗?" src="http://bbs.mjtd.com/Skins/Default/ofMale.gif"/>
<div><span style="FILTER: glow(color='#A6BA98',strength='2'); WIDTH: 105px"><font color="#61b713" face="Verdana"><b>rongyifei</b></font></div></span></td></tr></tbody></table></p>无私的把代码分享出来 <p>困惑我很久以致我自己的代码不能成功转换的就是少了:endAngle+=8*atan(1.0)这句,导致dBugle不对。</p>
<p>非常感谢。</p>
页:
[1]