|
void CCommonFuntion::DrowPloyLine(AcGePoint2dArray& inputpoints)
{
if (inputpoints.length() < 3)
return;
AcDbPolyline *pPolyLine = new AcDbPolyline(3);
for (int i = 0; i < inputpoints.length(); i++)
{
pPolyLine->addVertexAt(i, inputpoints.at(i), 0, 1.0, 1.0);
}
AcDbBlockTable *pBlockTable = NULL;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRocord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRocord, AcDb::kForWrite);
AcDbObjectId lineId;
pBlockTableRocord->appendAcDbEntity(lineId, pPolyLine);
pBlockTable->close();
pBlockTableRocord->close();
pPolyLine->close();
}
AcDbObjectIdArray CCommonFuntion::DrowLine(AcGePoint3dArray& inputpoints)
{
AcDbObjectIdArray ids;
if (inputpoints.length() < 2)
return ids;
for (int i=0;i<inputpoints.length();i++)
{
if (i==inputpoints.length()-1)
{
AcDbLine *pPline = new AcDbLine(inputpoints[i], inputpoints[0]);
AcDbObjectId ID=CCommonFuntion::PostToModelSpace(pPline);
if (pPline)
pPline->close();
ids.append(ID);
}
else
{
AcDbLine *pPline = new AcDbLine(inputpoints[i], inputpoints[i + 1]);
AcDbObjectId ID = CCommonFuntion::PostToModelSpace(pPline);
if (pPline)
pPline->close();
ids.append(ID);
}
}
return ids;
} |
|