From c63ac5ffbcad95e692c77fd81cda343cf15d036b Mon Sep 17 00:00:00 2001 From: Ian 'z0r0' Abreu Date: Sun, 31 Aug 2025 15:19:25 -0400 Subject: [PATCH] Finalizing Python interface bindings for assembly --- .../{AssemblyLinkPy.pyi => AssemblyLink.pyi} | 8 +- src/Mod/Assembly/App/AssemblyLinkPy.xml | 24 --- ...ssemblyObjectPy.pyi => AssemblyObject.pyi} | 13 +- src/Mod/Assembly/App/AssemblyObjectPy.xml | 182 ------------------ src/Mod/Assembly/App/BomGroup.pyi | 9 + src/Mod/Assembly/App/BomGroupPy.pyi | 18 -- src/Mod/Assembly/App/BomGroupPy.xml | 19 -- .../App/{BomObjectPy.pyi => BomObject.pyi} | 9 +- src/Mod/Assembly/App/BomObjectPy.xml | 19 -- src/Mod/Assembly/App/CMakeLists.txt | 36 ++-- src/Mod/Assembly/App/JointGroup.pyi | 9 + src/Mod/Assembly/App/JointGroupPy.pyi | 18 -- src/Mod/Assembly/App/JointGroupPy.xml | 19 -- src/Mod/Assembly/App/SimulationGroup.pyi | 9 + src/Mod/Assembly/App/SimulationGroupPy.pyi | 18 -- src/Mod/Assembly/App/SimulationGroupPy.xml | 19 -- src/Mod/Assembly/App/ViewGroup.pyi | 9 + src/Mod/Assembly/App/ViewGroupPy.pyi | 18 -- src/Mod/Assembly/App/ViewGroupPy.xml | 19 -- src/Mod/Assembly/Gui/CMakeLists.txt | 5 +- ...ssemblyPy.pyi => ViewProviderAssembly.pyi} | 13 +- .../Assembly/Gui/ViewProviderAssemblyPy.xml | 68 ------- .../templates/templateClassPyExport.py | 1 + 23 files changed, 60 insertions(+), 502 deletions(-) rename src/Mod/Assembly/App/{AssemblyLinkPy.pyi => AssemblyLink.pyi} (62%) delete mode 100644 src/Mod/Assembly/App/AssemblyLinkPy.xml rename src/Mod/Assembly/App/{AssemblyObjectPy.pyi => AssemblyObject.pyi} (92%) delete mode 100644 src/Mod/Assembly/App/AssemblyObjectPy.xml create mode 100644 src/Mod/Assembly/App/BomGroup.pyi delete mode 100644 src/Mod/Assembly/App/BomGroupPy.pyi delete mode 100644 src/Mod/Assembly/App/BomGroupPy.xml rename src/Mod/Assembly/App/{BomObjectPy.pyi => BomObject.pyi} (65%) delete mode 100644 src/Mod/Assembly/App/BomObjectPy.xml create mode 100644 src/Mod/Assembly/App/JointGroup.pyi delete mode 100644 src/Mod/Assembly/App/JointGroupPy.pyi delete mode 100644 src/Mod/Assembly/App/JointGroupPy.xml create mode 100644 src/Mod/Assembly/App/SimulationGroup.pyi delete mode 100644 src/Mod/Assembly/App/SimulationGroupPy.pyi delete mode 100644 src/Mod/Assembly/App/SimulationGroupPy.xml create mode 100644 src/Mod/Assembly/App/ViewGroup.pyi delete mode 100644 src/Mod/Assembly/App/ViewGroupPy.pyi delete mode 100644 src/Mod/Assembly/App/ViewGroupPy.xml rename src/Mod/Assembly/Gui/{ViewProviderAssemblyPy.pyi => ViewProviderAssembly.pyi} (74%) delete mode 100644 src/Mod/Assembly/Gui/ViewProviderAssemblyPy.xml diff --git a/src/Mod/Assembly/App/AssemblyLinkPy.pyi b/src/Mod/Assembly/App/AssemblyLink.pyi similarity index 62% rename from src/Mod/Assembly/App/AssemblyLinkPy.pyi rename to src/Mod/Assembly/App/AssemblyLink.pyi index 14f4b03e11..f78aa8e613 100644 --- a/src/Mod/Assembly/App/AssemblyLinkPy.pyi +++ b/src/Mod/Assembly/App/AssemblyLink.pyi @@ -5,16 +5,10 @@ from Base.Metadata import export from App.Part import Part @export( - Father="PartPy", - Name="AssemblyLinkPy", - Twin="AssemblyLink", - TwinPointer="AssemblyLink", Include="Mod/Assembly/App/AssemblyLink.h", Namespace="Assembly", - FatherInclude="App/PartPy.h", - FatherNamespace="App", ) -class AssemblyLinkPy(Part): +class AssemblyLink(Part): """ This class handles document objects in Assembly """ diff --git a/src/Mod/Assembly/App/AssemblyLinkPy.xml b/src/Mod/Assembly/App/AssemblyLinkPy.xml deleted file mode 100644 index e21a050895..0000000000 --- a/src/Mod/Assembly/App/AssemblyLinkPy.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - This class handles document objects in Assembly - - - - A list of all joints this assembly link has. - - - - - - diff --git a/src/Mod/Assembly/App/AssemblyObjectPy.pyi b/src/Mod/Assembly/App/AssemblyObject.pyi similarity index 92% rename from src/Mod/Assembly/App/AssemblyObjectPy.pyi rename to src/Mod/Assembly/App/AssemblyObject.pyi index 8d971b7d94..29e9014607 100644 --- a/src/Mod/Assembly/App/AssemblyObjectPy.pyi +++ b/src/Mod/Assembly/App/AssemblyObject.pyi @@ -4,17 +4,8 @@ from Base.Metadata import constmethod, export from App.Part import Part -@export( - Father="PartPy", - Name="AssemblyObjectPy", - Twin="AssemblyObject", - TwinPointer="AssemblyObject", - Include="Mod/Assembly/App/AssemblyObject.h", - Namespace="Assembly", - FatherInclude="App/PartPy.h", - FatherNamespace="App", -) -class AssemblyObjectPy(Part): +@export(Include="Mod/Assembly/App/AssemblyObject.h", Namespace="Assembly") +class AssemblyObject(Part): """ This class handles document objects in Assembly """ diff --git a/src/Mod/Assembly/App/AssemblyObjectPy.xml b/src/Mod/Assembly/App/AssemblyObjectPy.xml deleted file mode 100644 index 335da8064b..0000000000 --- a/src/Mod/Assembly/App/AssemblyObjectPy.xml +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - This class handles document objects in Assembly - - - - -Solve the assembly and update part placements. - -solve(enableRedo=False) -> int - -Args: -enableRedo: Whether the solve save the initial position of parts -to enable undoing it even without a transaction. -Defaults to `False` ie the solve cannot be undone if called -outside of a transaction. - -Returns: -0 in case of success, otherwise the following codes in this order of -priority: --6 if no parts are fixed. --4 if over-constrained, --3 if conflicting constraints, --5 if malformed constraints --1 if solver error, --2 if redundant constraints. - - - - - - -Generate the simulation. - -solve(simulationObject) -> int - -Args: -simulationObject: The simulation Object. - -Returns: -0 in case of success, otherwise the following codes in this order of -priority: --6 if no parts are fixed. --4 if over-constrained, --3 if conflicting constraints, --5 if malformed constraints --1 if solver error, --2 if redundant constraints. - - - - - - -Update entire assembly to frame number specified. - -updateForFrame(index) - -Args: index of frame. - -Returns: None - - - - - - -numberOfFrames() - -Args: None - -Returns: Number of frames - - - - - - -Undo the last solve of the assembly and return part placements to their initial position. - -undoSolve() - -Returns: None - - - - - - -Makes sure that LinkGroups or sub-assemblies have identity placements. - -ensureIdentityPlacements() - -Returns: None - - - - - - -Clear the registered undo positions. - -clearUndo() - -Returns: None - - - - - - -Check if a part is connected to the ground through joints. - -isPartConnected(obj) -> bool - -Args: document object to check. - -Returns: True if part is connected to ground - - - - - - -Check if a joint is connecting a part to the ground. - -isJointConnectingPartToGround(joint, propName) -> bool - -Args: -- joint: document object of the joint to check. -- propName: string 'Part1' or 'Part2' of the joint. - -Returns: True if part is connected to ground - - - - - - -Check if a part has a grounded joint. - -isPartGrounded(obj) -> bool - -Args: -- obj: document object of the part to check. - -Returns: True if part has grounded joint - - - - - - -Export the assembly in a text format called ASMT. - -exportAsASMT(fileName:str) - -Args: -fileName: The name of the file where the ASMT will be exported. - - - - - - A list of all joints this assembly has. - - - - - - diff --git a/src/Mod/Assembly/App/BomGroup.pyi b/src/Mod/Assembly/App/BomGroup.pyi new file mode 100644 index 0000000000..eec7081082 --- /dev/null +++ b/src/Mod/Assembly/App/BomGroup.pyi @@ -0,0 +1,9 @@ +from Base.Metadata import export + +from App.DocumentObjectGroup import DocumentObjectGroup + +@export(Include="Mod/Assembly/App/BomGroup.h", Namespace="Assembly") +class BomGroup(DocumentObjectGroup): + """ + This class is a group subclass for boms. + """ diff --git a/src/Mod/Assembly/App/BomGroupPy.pyi b/src/Mod/Assembly/App/BomGroupPy.pyi deleted file mode 100644 index 7ce2066a83..0000000000 --- a/src/Mod/Assembly/App/BomGroupPy.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from Base.Metadata import export - -from App.DocumentObjectGroup import DocumentObjectGroup - -@export( - Father="DocumentObjectGroupPy", - Name="BomGroupPy", - Twin="BomGroup", - TwinPointer="BomGroup", - Include="Mod/Assembly/App/BomGroup.h", - Namespace="Assembly", - FatherInclude="App/DocumentObjectGroupPy.h", - FatherNamespace="App", -) -class BomGroupPy(DocumentObjectGroup): - """ - This class is a group subclass for boms. - """ diff --git a/src/Mod/Assembly/App/BomGroupPy.xml b/src/Mod/Assembly/App/BomGroupPy.xml deleted file mode 100644 index 2a5c48abf6..0000000000 --- a/src/Mod/Assembly/App/BomGroupPy.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This class is a group subclass for boms. - - - - - diff --git a/src/Mod/Assembly/App/BomObjectPy.pyi b/src/Mod/Assembly/App/BomObject.pyi similarity index 65% rename from src/Mod/Assembly/App/BomObjectPy.pyi rename to src/Mod/Assembly/App/BomObject.pyi index a1847ab68d..fb0581b921 100644 --- a/src/Mod/Assembly/App/BomObjectPy.pyi +++ b/src/Mod/Assembly/App/BomObject.pyi @@ -2,16 +2,11 @@ from Base.Metadata import export from Spreadsheet.Sheet import Sheet @export( - Father="SheetPy", - Name="BomObjectPy", - Twin="BomObject", - TwinPointer="BomObject", Include="Mod/Assembly/App/BomObject.h", - Namespace="Assembly", FatherInclude="Mod/Spreadsheet/App/SheetPy.h", - FatherNamespace="Spreadsheet", + Namespace="Assembly", ) -class BomObjectPy(Sheet): +class BomObject(Sheet): """ This class is the BOM object of assemblies, it derives from Spreadsheet::Sheet. """ diff --git a/src/Mod/Assembly/App/BomObjectPy.xml b/src/Mod/Assembly/App/BomObjectPy.xml deleted file mode 100644 index b329fcc984..0000000000 --- a/src/Mod/Assembly/App/BomObjectPy.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This class is the BOM object of assemblies, it derives from Spreadsheet::Sheet. - - - - - diff --git a/src/Mod/Assembly/App/CMakeLists.txt b/src/Mod/Assembly/App/CMakeLists.txt index 6d944a784c..eb5882bf40 100644 --- a/src/Mod/Assembly/App/CMakeLists.txt +++ b/src/Mod/Assembly/App/CMakeLists.txt @@ -14,37 +14,29 @@ set(Assembly_LIBS OndselSolver ) -generate_from_xml(AssemblyObjectPy) -generate_from_xml(AssemblyLinkPy) -generate_from_xml(BomObjectPy) -generate_from_xml(BomGroupPy) -generate_from_xml(JointGroupPy) -generate_from_xml(ViewGroupPy) -generate_from_xml(SimulationGroupPy) - -generate_from_py_(AssemblyObjectPy) -generate_from_py_(AssemblyLinkPy) -generate_from_py_(BomObjectPy) -generate_from_py_(BomGroupPy) -generate_from_py_(JointGroupPy) -generate_from_py_(ViewGroupPy) -generate_from_py_(SimulationGroupPy) +generate_from_py(AssemblyObject) +generate_from_py(AssemblyLink) +generate_from_py(BomObject) +generate_from_py(BomGroup) +generate_from_py(JointGroup) +generate_from_py(ViewGroup) +generate_from_py(SimulationGroup) SET(Python_SRCS - AssemblyObjectPy.xml + AssemblyObject.pyi AssemblyObjectPyImp.cpp - AssemblyLinkPy.xml + AssemblyLink.pyi AssemblyLinkPyImp.cpp - BomObjectPy.xml + BomObject.pyi BomObjectPyImp.cpp - BomGroupPy.xml + BomGroup.pyi BomGroupPyImp.cpp - JointGroupPy.xml + JointGroup.pyi JointGroupPyImp.cpp - ViewGroupPy.xml + ViewGroup.pyi ViewGroupPyImp.cpp - SimulationGroupPy.xml + SimulationGroup.pyi SimulationGroupPyImp.cpp ) SOURCE_GROUP("Python" FILES ${Python_SRCS}) diff --git a/src/Mod/Assembly/App/JointGroup.pyi b/src/Mod/Assembly/App/JointGroup.pyi new file mode 100644 index 0000000000..f44a008fe3 --- /dev/null +++ b/src/Mod/Assembly/App/JointGroup.pyi @@ -0,0 +1,9 @@ +from Base.Metadata import export + +from App.DocumentObjectGroup import DocumentObjectGroup + +@export(Include="Mod/Assembly/App/JointGroup.h", Namespace="Assembly") +class JointGroup(DocumentObjectGroup): + """ + This class is a group subclass for joints. + """ diff --git a/src/Mod/Assembly/App/JointGroupPy.pyi b/src/Mod/Assembly/App/JointGroupPy.pyi deleted file mode 100644 index 89388781aa..0000000000 --- a/src/Mod/Assembly/App/JointGroupPy.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from Base.Metadata import export - -from App.DocumentObjectGroup import DocumentObjectGroup - -@export( - Father="DocumentObjectGroupPy", - Name="JointGroupPy", - Twin="JointGroup", - TwinPointer="JointGroup", - Include="Mod/Assembly/App/JointGroup.h", - Namespace="Assembly", - FatherInclude="App/DocumentObjectGroupPy.h", - FatherNamespace="App", -) -class JointGroupPy(DocumentObjectGroup): - """ - This class is a group subclass for joints. - """ diff --git a/src/Mod/Assembly/App/JointGroupPy.xml b/src/Mod/Assembly/App/JointGroupPy.xml deleted file mode 100644 index d3b8555461..0000000000 --- a/src/Mod/Assembly/App/JointGroupPy.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This class is a group subclass for joints. - - - - - diff --git a/src/Mod/Assembly/App/SimulationGroup.pyi b/src/Mod/Assembly/App/SimulationGroup.pyi new file mode 100644 index 0000000000..56d1fcf155 --- /dev/null +++ b/src/Mod/Assembly/App/SimulationGroup.pyi @@ -0,0 +1,9 @@ +from Base.Metadata import export + +from App.DocumentObjectGroup import DocumentObjectGroup + +@export(Include="Mod/Assembly/App/SimulationGroup.h", Namespace="Assembly") +class SimulationGroup(DocumentObjectGroup): + """ + This class is a group subclass for joints. + """ diff --git a/src/Mod/Assembly/App/SimulationGroupPy.pyi b/src/Mod/Assembly/App/SimulationGroupPy.pyi deleted file mode 100644 index fc1c82a0e0..0000000000 --- a/src/Mod/Assembly/App/SimulationGroupPy.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from Base.Metadata import export - -from App.DocumentObjectGroup import DocumentObjectGroup - -@export( - Father="DocumentObjectGroupPy", - Name="SimulationGroupPy", - Twin="SimulationGroup", - TwinPointer="SimulationGroup", - Include="Mod/Assembly/App/SimulationGroup.h", - Namespace="Assembly", - FatherInclude="App/DocumentObjectGroupPy.h", - FatherNamespace="App", -) -class SimulationGroupPy(DocumentObjectGroup): - """ - This class is a group subclass for joints. - """ diff --git a/src/Mod/Assembly/App/SimulationGroupPy.xml b/src/Mod/Assembly/App/SimulationGroupPy.xml deleted file mode 100644 index cab1c61da8..0000000000 --- a/src/Mod/Assembly/App/SimulationGroupPy.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This class is a group subclass for joints. - - - - - diff --git a/src/Mod/Assembly/App/ViewGroup.pyi b/src/Mod/Assembly/App/ViewGroup.pyi new file mode 100644 index 0000000000..9a4eb0e1a2 --- /dev/null +++ b/src/Mod/Assembly/App/ViewGroup.pyi @@ -0,0 +1,9 @@ +from Base.Metadata import export + +from App.DocumentObjectGroup import DocumentObjectGroup + +@export(Include="Mod/Assembly/App/ViewGroup.h", Namespace="Assembly") +class ViewGroup(DocumentObjectGroup): + """ + This class is a group subclass for joints. + """ diff --git a/src/Mod/Assembly/App/ViewGroupPy.pyi b/src/Mod/Assembly/App/ViewGroupPy.pyi deleted file mode 100644 index 5229d081ce..0000000000 --- a/src/Mod/Assembly/App/ViewGroupPy.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from Base.Metadata import export - -from App.DocumentObjectGroup import DocumentObjectGroup - -@export( - Father="DocumentObjectGroupPy", - Name="ViewGroupPy", - Twin="ViewGroup", - TwinPointer="ViewGroup", - Include="Mod/Assembly/App/ViewGroup.h", - Namespace="Assembly", - FatherInclude="App/DocumentObjectGroupPy.h", - FatherNamespace="App", -) -class ViewGroupPy(DocumentObjectGroup): - """ - This class is a group subclass for joints. - """ diff --git a/src/Mod/Assembly/App/ViewGroupPy.xml b/src/Mod/Assembly/App/ViewGroupPy.xml deleted file mode 100644 index 69446cba20..0000000000 --- a/src/Mod/Assembly/App/ViewGroupPy.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This class is a group subclass for joints. - - - - - diff --git a/src/Mod/Assembly/Gui/CMakeLists.txt b/src/Mod/Assembly/Gui/CMakeLists.txt index 534ec90174..a20ee18c82 100644 --- a/src/Mod/Assembly/Gui/CMakeLists.txt +++ b/src/Mod/Assembly/Gui/CMakeLists.txt @@ -22,8 +22,7 @@ qt_add_resources(AssemblyResource_SRCS Resources/Assembly.qrc ${Assembly_TR_QRC} SOURCE_GROUP("Resources" FILES ${AssemblyResource_SRCS}) -generate_from_xml(ViewProviderAssemblyPy) -generate_from_py_(ViewProviderAssemblyPy) +generate_from_py(ViewProviderAssembly) set(AssemblyGui_UIC_SRCS TaskAssemblyCreateBom.ui @@ -35,7 +34,7 @@ set(AssemblyGui_UIC_SRCS ) SET(Python_SRCS - ViewProviderAssemblyPy.xml + ViewProviderAssembly.pyi ViewProviderAssemblyPyImp.cpp ) SOURCE_GROUP("Python" FILES ${Python_SRCS}) diff --git a/src/Mod/Assembly/Gui/ViewProviderAssemblyPy.pyi b/src/Mod/Assembly/Gui/ViewProviderAssembly.pyi similarity index 74% rename from src/Mod/Assembly/Gui/ViewProviderAssemblyPy.pyi rename to src/Mod/Assembly/Gui/ViewProviderAssembly.pyi index 4739c4f7b8..6775edbd23 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssemblyPy.pyi +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.pyi @@ -4,17 +4,8 @@ from Base.Metadata import export from Gui.ViewProvider import ViewProvider -@export( - Father="ViewProviderPy", - Name="ViewProviderAssemblyPy", - Twin="ViewProviderAssembly", - TwinPointer="ViewProviderAssembly", - Include="Mod/Assembly/Gui/ViewProviderAssembly.h", - Namespace="AssemblyGui", - FatherInclude="Gui/ViewProviderPy.h", - FatherNamespace="Gui", -) -class ViewProviderAssemblyPy(ViewProvider): +@export(Include="Mod/Assembly/Gui/ViewProviderAssembly.h", Namespace="AssemblyGui") +class ViewProviderAssembly(ViewProvider): """ This is the ViewProviderAssembly class """ diff --git a/src/Mod/Assembly/Gui/ViewProviderAssemblyPy.xml b/src/Mod/Assembly/Gui/ViewProviderAssemblyPy.xml deleted file mode 100644 index 34db07a03d..0000000000 --- a/src/Mod/Assembly/Gui/ViewProviderAssemblyPy.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - This is the ViewProviderAssembly class - - - - - - Return true if the assembly object is currently in edit mode. - - isInEditMode() -> bool - - - - - - - Return the assembly dragger coin object. - - getDragger() -> SoTransformDragger - - Returns: dragger coin object of the assembly - - - - - - Enable moving the parts by clicking and dragging. - - - - - - If enabled, only the preselected object will move. - - - - - - If enabled, each move will be wrapped in a command. - - - - - - Show or hide the assembly dragger. - - - - - - Placement of the assembly dragger object. - - - - - diff --git a/src/Tools/bindings/templates/templateClassPyExport.py b/src/Tools/bindings/templates/templateClassPyExport.py index 3f9bb112a9..ffaac1c5a7 100644 --- a/src/Tools/bindings/templates/templateClassPyExport.py +++ b/src/Tools/bindings/templates/templateClassPyExport.py @@ -40,6 +40,7 @@ class TemplateClassPyExport(template.ModelTemplate): if self.is_python and not self.export.ModuleName in [ "Base", "App", + "Assembly", "Gui", "Part", "PartDesign",