I’m not sure when open entities for read is necessary, and when it may be omit.
For example I know I don’t need to open entity when I want to use objectId()
but there are some methods which require to open entity before.
I don’t know if it’s necessary to open AcDbPolyline
before getArcSegAt()
. In many cases I can simple try to use method before it’s open I will get what I want or not. But maybe there is some easy rule for that?
Example:
AcDbObjectId id = somethingNotImportant();
AcDbPolyline* _pPoly = NULL;
if (id.isValid())
{
AcDbEntity* pEnt = NULL;
Acad::ErrorStatus es;
es = acdbOpenObject(pEnt, id, AcDb::kForRead);
if( es == Acad::eOk)
{
if(pEnt->isKindOf(AcDbPolyline::desc()))
{
this->_pPoly = AcDbPolyline::cast(pEnt);
}
es = pEnt->close();
}
}
now _pPoly
is initiallized , but it is closed because of pEnt->close();
now I want for example use:
AcGePoint3d Px = initializedSomehow();
double distAtPx = 0;
_pPoly->getDistAtPoint(Px , distAtPx);
do I need to :
es = acdbOpenObject(_pPoly, id, AcDb::kForRead);
before:
_pPoly->getDistAtPoint(Px , distAtPx);