ObjectArx OsnapMode捕捉方式说明
对应的捕捉方式说明:
enum OsnapMode { kOsModeEnd = 1,// 端点 kOsModeMid = 2,// 中点 kOsModeCen = 3,// 圆心 kOsModeNode = 4,// 节点 kOsModeQuad = 5,// 象限点 kOsModeIns = 7,// 插入点 kOsModePerp = 8,// 垂足 kOsModeTan = 9, kOsModeNear = 10,// 最近点 kOsModeCentroid = 11, };
自定义实体添加捕捉点 示例:
//设置捕捉点 Acad::ErrorStatus GeFloor::subGetOsnapPoints(AcDb::OsnapMode osnapMode, Adesk::GsMarker gsSelectionMark, const AcGePoint3d & pickPoint, const AcGePoint3d & lastPoint, const AcGeMatrix3d & viewXform, AcGePoint3dArray & snapPoints, AcDbIntArray & geomIds) const { assertReadEnabled(); for (size_t i = 0; i < BoundaryPoints.size()-1; i++) { auto p0 = BoundaryPoints[i]; auto p1 = BoundaryPoints[i + 1]; AcGeLine3d line(p0, p1); AcGePointOnCurve3d pt2; AcGePoint3d pt; switch (osnapMode) { case OsnapMode::kOsModeEnd:// 端点 if (i == 0) snapPoints.append(p0); snapPoints.append(p1); break; case OsnapMode::kOsModeMid:// 中点 snapPoints.append(AcGePoint3d((p0.x + p1.x) / 2, (p0.y + p1.y) / 2, 0)); break; case OsnapMode::kOsModePerp:// 垂足 pt = line.closestPointTo(lastPoint); snapPoints.append(pt); break; case OsnapMode::kOsModeNear:// 最近点 line.getClosestPointTo(pickPoint, pt2); snapPoints.append(pt2.point3d()); break; default: break; } } if (osnapMode == OsnapMode::kOsModeCentroid)// 几何中心 snapPoints.append(AcGePoint3d((LeftTopPoint.x + RightBottomPoint.x) / 2, (LeftTopPoint.y + RightBottomPoint.y) / 2, this->GetTopZ())); return Acad::eOk; }