第一点,AcDbLine接受的不是ads_point而是AcGePoint3d,要把ads_point 转换为AcGePoint3d,可以这样写:
(假定 ads_point s;AcGePoint3d p;)
p.set(s[0],s[1],s[2]);
但是你得程序可以有更快的写法:
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(); |