TechDraw: Allow 3d dimension references to use point objects (#28199)

* [TD]fix 3d point object reference in dimension

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
WandererFan
2026-03-11 06:08:35 +01:00
committed by GitHub
co-authored by pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
parent 4083c7c616
commit e44c1ce75a
2 changed files with 22 additions and 6 deletions
+11 -3
View File
@@ -106,9 +106,17 @@ ResolveResult ShapeFinder::resolveSelection(
// and ShapeFinder::getLinkAttachParent()
TopoDS_Shape ShapeFinder::getLocatedShape(const App::DocumentObject& rootObject, const std::string& leafSub)
{
auto resolved = resolveSelection(rootObject, leafSub);
auto target = &resolved.getTarget();
auto shortSub = resolved.getShortSub();
// point objects are weird.
const std::string VertexTag {"Vertex"};
const std::string PointTag {"Point"};
std::string objName {rootObject.getNameInDocument()};
if (objName.find(VertexTag) != std::string::npos || objName.find(PointTag) != std::string::npos) {
return Part::Feature::getShape(&rootObject, Part::ShapeOption::Transform);
}
ResolveResult resolved = resolveSelection(rootObject, leafSub);
App::DocumentObject* target = &resolved.getTarget();
std::string shortSub = resolved.getShortSub();
if (!target) {
return {};
}
+11 -3
View File
@@ -77,10 +77,18 @@ TechDraw::DrawViewPart* TechDraw::getReferencesFromSelection(ReferenceVector& re
}
} else if (!selItem.getObject()->isDerivedFrom<TechDraw::DrawView>()) {
App::DocumentObject* obj3d = selItem.getObject();
// this is a regular 3d reference in form obj + long subelement
for (auto& sub3d : selItem.getSubNames()) {
ReferenceEntry ref(obj3d, sub3d);
// obj3d is a point object, in which case the sub will be empty instead of
// containing Vertex1. Inserting "Vertex1" here gets us through
// validation, but doesn't work in Measure::shapefinder.
if (ShapeExtractor::isPointType(obj3d)) {
ReferenceEntry ref(obj3d, "Vertex1");
references3d.push_back(ref);
} else {
// this is a regular 3d reference in form obj + long subelement
for (auto& sub3d : selItem.getSubNames()) {
ReferenceEntry ref(obj3d, sub3d);
references3d.push_back(ref);
}
}
}
}