请各位帮忙
提示 用户选择两个点,将两点联成直线为何不能实现啊 ,代码如下:
ads_point startPt, endPt;
acedGetPoint(NULL,"\nLocate start point : ", startPt);
acedGetPoint(NULL,"\nLocate end point : ", endPt);
AcDbLine *pLine = new AcDbLine(startPt,endPt);
//error C2664: '__thiscall AcDbLine::AcDbLine(const class AcGePoint3d &,const class AcGePoint3d &)' : cannot convert parameter 1 from 'double ' to 'const class AcGePoint3d &'
Reason: cannot convert from 'double ' to 'const class AcGePoint3d'
No constructor could take the source type, or constructor overload resolution was ambiguous
请各位帮忙指点一二
第一点,AcDbLine接受的不是ads_point而是AcGePoint3d,要把ads_point 转换为AcGePoint3d,可以这样写:
(假定 ads_point s;AcGePoint3d p;)
p.set(s,s,s);
但是你得程序可以有更快的写法:
AcDbLine *pLine = new AcDbLine(*(AcGePoint3d*)startPt,*(AcGePoint3d*)endPt);
第二点,你必须把你的图元加入到数据库中才行,这个可以参考SDK上的写法:
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId lineId;
pBlockTableRecord->appendAcDbEntity(lineId, pLine);
pBlockTableRecord->close();
pLine->close();
页:
[1]