By Adam Nagy
We have a custom entity derived from AcDbEntity that draws a given block table record:
Adesk::Boolean MyBlockEnt::subWorldDraw (AcGiWorldDraw *mode)
{
assertReadEnabled();
if (!m_blockId.isNull())
{
AcDbBlockTableRecordPointer ptrMB(m_blockId, AcDb::kForRead);
mode->geometry().draw(ptrMB);
}
return (Adesk::kTrue);
}
We also implement the subGetOsnapPoints function to provide our own snap points:
Acad::ErrorStatus MyBlockEnt::subGetOsnapPoints(
AcDb::OsnapMode osnapMode, Adesk::GsMarker gsSelectionMark,
const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint,
const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints,
AcDbIntArray& geomIds, const AcGeMatrix3d& insertionMat) const
{
snapPoints.append(m_snapPoint);
return Acad::eOk;
}
In 2d Wireframe mode only the point we provide can be snapped to, which is the behaviour we'd like to see in the other modes like Shaded view as well. However, there the osnap points of the entities residing in the block our entity is drawing can also be snapped to. How could we avoid that?
Solution
Your entity should also implement the AcDbEntity::subIsContentSnappable like so:
bool MyBlockEnt::subIsContentSnappable() const
{
return false;
}