Assembly: Property change from Object/Part to Reference

This commit is contained in:
PaddleStroke
2024-07-12 08:36:14 +02:00
committed by Yorik van Havre
parent 336a581942
commit 4f79c675b7
9 changed files with 1217 additions and 1057 deletions

View File

@@ -44,6 +44,11 @@ class ASMTMarker;
class ASMTPart;
} // namespace MbD
namespace App
{
class PropertyXLinkSub;
} // namespace App
namespace Base
{
class Placement;
@@ -57,6 +62,8 @@ namespace Assembly
class JointGroup;
class ViewGroup;
using ObjRefPair = std::pair<App::DocumentObject*, App::PropertyXLinkSub*>;
// This enum has to be the same as the one in JointObject.py
enum class JointType
{
@@ -123,7 +130,6 @@ enum class DistanceType
Other,
};
class AssemblyExport AssemblyObject: public App::Part
{
PROPERTY_HEADER_WITH_OVERRIDE(Assembly::AssemblyObject);
@@ -173,8 +179,7 @@ public:
JointType jointType);
std::shared_ptr<MbD::ASMTJoint> makeMbdJointDistance(App::DocumentObject* joint);
std::string handleOneSideOfJoint(App::DocumentObject* joint,
const char* propObjLinkName,
const char* propPartName,
const char* propRefName,
const char* propPlcName);
void getRackPinionMarkers(App::DocumentObject* joint,
std::string& markerNameI,
@@ -197,20 +202,23 @@ public:
bool isJointConnectingPartToGround(App::DocumentObject* joint, const char* partPropName);
bool isJointTypeConnecting(App::DocumentObject* joint);
bool isObjInSetOfObjRefPairs(App::DocumentObject* obj, const std::set<ObjRefPair>& pairs);
void removeUnconnectedJoints(std::vector<App::DocumentObject*>& joints,
std::vector<App::DocumentObject*> groundedObjs);
void traverseAndMarkConnectedParts(App::DocumentObject* currentPart,
std::set<App::DocumentObject*>& connectedParts,
std::set<ObjRefPair>& connectedParts,
const std::vector<App::DocumentObject*>& joints);
std::vector<App::DocumentObject*>
getConnectedParts(App::DocumentObject* part, const std::vector<App::DocumentObject*>& joints);
std::vector<ObjRefPair> getConnectedParts(App::DocumentObject* part,
const std::vector<App::DocumentObject*>& joints);
bool isPartGrounded(App::DocumentObject* part);
bool isPartConnected(App::DocumentObject* part);
std::vector<App::DocumentObject*> getDownstreamParts(App::DocumentObject* part,
App::DocumentObject* joint);
std::vector<ObjRefPair> getDownstreamParts(App::DocumentObject* part,
App::DocumentObject* joint);
std::vector<App::DocumentObject*> getUpstreamParts(App::DocumentObject* part, int limit = 0);
App::DocumentObject* getUpstreamMovingPart(App::DocumentObject* part);
App::DocumentObject* getUpstreamMovingPart(App::DocumentObject* part,
App::DocumentObject*& joint,
std::string& name);
double getObjMass(App::DocumentObject* obj);
void setObjMasses(std::vector<std::pair<App::DocumentObject*, double>> objectMasses);
@@ -253,19 +261,23 @@ public:
static const char* getElementFromProp(App::DocumentObject* obj, const char* propName);
static std::string getElementTypeFromProp(App::DocumentObject* obj, const char* propName);
static App::DocumentObject* getObjFromProp(App::DocumentObject* joint, const char* propName);
static App::DocumentObject* getLinkedObjFromProp(App::DocumentObject* joint, const char* pObj);
static App::DocumentObject* getObjFromRef(App::PropertyXLinkSub* prop);
static App::DocumentObject* getObjFromRef(App::DocumentObject* joint, const char* propName);
App::DocumentObject* getMovingPartFromRef(App::DocumentObject* obj, std::string& sub);
App::DocumentObject* getMovingPartFromRef(App::PropertyXLinkSub* prop);
App::DocumentObject* getMovingPartFromRef(App::DocumentObject* joint, const char* propName);
static App::DocumentObject* getLinkedObjFromRef(App::DocumentObject* joint,
const char* propName);
static std::vector<std::string> getSubAsList(App::PropertyXLinkSub* prop);
static std::vector<std::string> getSubAsList(App::DocumentObject* joint, const char* propName);
static std::vector<std::string> splitSubName(const std::string& subName);
static Base::Placement getPlacementFromProp(App::DocumentObject* obj, const char* propName);
static bool getTargetPlacementRelativeTo(Base::Placement& foundPlc,
App::DocumentObject* targetObj,
App::DocumentObject* part,
App::DocumentObject* container,
bool inContainerBranch,
bool ignorePlacement = false);
static Base::Placement getGlobalPlacement(App::DocumentObject* targetObj,
App::DocumentObject* container = nullptr);
static Base::Placement getGlobalPlacement(App::DocumentObject* joint,
const char* targetObj,
const char* container = "");
App::DocumentObject* rootObj,
const std::string& sub);
static Base::Placement getGlobalPlacement(App::DocumentObject* targetObj,
App::PropertyXLinkSub* prop);
};
// using AssemblyObjectPython = App::FeaturePythonT<AssemblyObject>;