请各位帮忙
<P>提示 用户选择两个点,将两点联成直线</P><P>为何不能实现啊 ,代码如下:</P>
<P>ads_point startPt, endPt;</P>
<P> acedGetPoint(NULL,"\nLocate start point : ", startPt);</P>
<P> acedGetPoint(NULL,"\nLocate end point : ", endPt);</P>
<P> AcDbLine *pLine = new AcDbLine(startPt,endPt);</P>
<P>//error C2664: '__thiscall AcDbLine::AcDbLine(const class AcGePoint3d &,const class AcGePoint3d &)' : cannot convert parameter 1 from 'double ' to 'const class AcGePoint3d &'<BR> Reason: cannot convert from 'double ' to 'const class AcGePoint3d'<BR> No constructor could take the source type, or constructor overload resolution was ambiguous</P>
<P>请各位帮忙指点一二</P> <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> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable, AcDb::kForRead);</P>
<P> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR> AcDb::kForWrite);<BR> pBlockTable->close();</P>
<P> AcDbObjectId lineId;<BR> pBlockTableRecord->appendAcDbEntity(lineId, pLine);</P>
<P> pBlockTableRecord->close();<BR> pLine->close();</P>
页:
[1]