Core: GeoFeature: Add python binding to the new getGlobalPlacement()
This commit is contained in:
committed by
Chris Hennes
parent
6c66acacf9
commit
b01a4c6f3c
@@ -108,8 +108,9 @@ public:
|
||||
const DocumentObject *filter=nullptr,const char **element=nullptr, GeoFeature **geo=nullptr);
|
||||
|
||||
/**
|
||||
* @brief Calculates the placement in the global reference coordinate system
|
||||
* @brief Deprecated. Calculates the placement in the global reference coordinate system
|
||||
*
|
||||
* Deprecated: This does not handle App::Links correctly. Use getGlobalPlacement() instead.
|
||||
* In FreeCAD the GeoFeature placement describes the local placement of the object in its parent
|
||||
* coordinate system. This is however not always the same as the global reference system. If the
|
||||
* object is in a GeoFeatureGroup, hence in another local coordinate system, the Placement
|
||||
|
||||
@@ -30,6 +30,7 @@ Note: Not implemented.</UserDocu>
|
||||
<Methode Name="getGlobalPlacement">
|
||||
<Documentation>
|
||||
<UserDocu>getGlobalPlacement() -> Base.Placement
|
||||
Deprecated: This function does not handle Links correctly. Use getGlobalPlacementOf instead.
|
||||
|
||||
Returns the placement of the object in the global coordinate space, respecting all stacked
|
||||
relationships.
|
||||
@@ -37,6 +38,22 @@ Note: This function is not available during recompute, as there the placements o
|
||||
can change after the execution of this object, rendering the result wrong.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getGlobalPlacementOf" Static="true">
|
||||
<Documentation>
|
||||
<UserDocu>getGlobalPlacementOf(targetObj, rootObj, subname) -> Base.Placement
|
||||
Selection example: obj = "part1" sub = "linkToPart2.LinkToBody.Pad.face1"
|
||||
|
||||
Global placement of Pad in this context :
|
||||
getGlobalPlacementOf(pad, part1, "linkToPart2.LinkToBody.Pad.face1")
|
||||
|
||||
Global placement of linkToPart2 in this context :
|
||||
getGlobalPlacementOf(linkToPart2, part1, "linkToPart2.LinkToBody.Pad.face1")
|
||||
|
||||
Returns the placement of the object in the global coordinate space, respecting all stacked
|
||||
relationships.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getPropertyNameOfGeometry">
|
||||
<Documentation>
|
||||
<UserDocu>getPropertyNameOfGeometry() -> str or None
|
||||
|
||||
@@ -57,6 +57,27 @@ PyObject* GeoFeaturePy::getGlobalPlacement(PyObject * args) {
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* GeoFeaturePy::getGlobalPlacementOf(PyObject * args) {
|
||||
|
||||
PyObject* pyTargetObj;
|
||||
PyObject* pyRootObj;
|
||||
char* pname;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OOs", &pyTargetObj, &pyRootObj, &pname)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* targetObj = static_cast<App::DocumentObjectPy*>(pyTargetObj)->getDocumentObjectPtr();
|
||||
auto* rootObj = static_cast<App::DocumentObjectPy*>(pyRootObj)->getDocumentObjectPtr();
|
||||
|
||||
try {
|
||||
Base::Placement p = GeoFeature::getGlobalPlacement(targetObj, rootObj, pname);
|
||||
return new Base::PlacementPy(new Base::Placement(p));
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* GeoFeaturePy::getPropertyNameOfGeometry(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
||||
Reference in New Issue
Block a user