yang611 发表于 2006-8-10 12:54:00

请各位帮忙

<P>提示&nbsp;用户选择两个点,将两点联成直线</P>
<P>为何不能实现啊 ,代码如下:</P>
<P>ads_point startPt, endPt;</P>
<P>&nbsp;acedGetPoint(NULL,"\nLocate start point : ", startPt);</P>
<P>&nbsp;acedGetPoint(NULL,"\nLocate end point : ", endPt);</P>
<P>&nbsp;&nbsp;AcDbLine *pLine = new AcDbLine(startPt,endPt);</P>
<P>//error C2664: '__thiscall AcDbLine::AcDbLine(const class AcGePoint3d &amp;,const class AcGePoint3d &amp;)' : cannot convert parameter 1 from 'double ' to 'const class AcGePoint3d &amp;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Reason: cannot convert from 'double ' to 'const class AcGePoint3d'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No constructor could take the source type, or constructor overload resolution was ambiguous</P>
<P>请各位帮忙指点一二</P>

shinjikun 发表于 2006-8-13 23:09:00

<P>第一点,AcDbLine接受的不是ads_point而是AcGePoint3d,要把ads_point 转换为AcGePoint3d,可以这样写:</P>
<P>(假定 ads_point s;AcGePoint3d p;)</P>
<P>p.set(s,s,s);</P>
<P>但是你得程序可以有更快的写法:</P>
<P>AcDbLine *pLine = new AcDbLine(*(AcGePoint3d*)startPt,*(AcGePoint3d*)endPt);</P>
<P>第二点,你必须把你的图元加入到数据库中才行,这个可以参考SDK上的写法:</P>
<P>&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pBlockTable, AcDb::kForRead);</P>
<P>&nbsp;&nbsp;AcDbBlockTableRecord *pBlockTableRecord;<BR>&nbsp;&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR>&nbsp;&nbsp;&nbsp;AcDb::kForWrite);<BR>&nbsp;&nbsp;pBlockTable-&gt;close();</P>
<P>&nbsp;&nbsp;AcDbObjectId lineId;<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(lineId, pLine);</P>
<P>&nbsp;&nbsp;pBlockTableRecord-&gt;close();<BR>&nbsp;&nbsp;pLine-&gt;close();</P>
页: [1]
查看完整版本: 请各位帮忙