Finalizing Python interface bindings for assembly

This commit is contained in:
Ian 'z0r0' Abreu
2025-08-31 15:19:25 -04:00
parent a5b3a2caac
commit c63ac5ffbc
23 changed files with 60 additions and 502 deletions

View File

@@ -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
"""

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PartPy"
Name="AssemblyLinkPy"
Twin="AssemblyLink"
TwinPointer="AssemblyLink"
Include="Mod/Assembly/App/AssemblyLink.h"
Namespace="Assembly"
FatherInclude="App/PartPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class handles document objects in Assembly</UserDocu>
</Documentation>
<Attribute Name="Joints" ReadOnly="true">
<Documentation>
<UserDocu>A list of all joints this assembly link has.</UserDocu>
</Documentation>
<Parameter Name="Joints" Type="List"/>
</Attribute>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -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
"""

View File

@@ -1,182 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PartPy"
Name="AssemblyObjectPy"
Twin="AssemblyObject"
TwinPointer="AssemblyObject"
Include="Mod/Assembly/App/AssemblyObject.h"
Namespace="Assembly"
FatherInclude="App/PartPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class handles document objects in Assembly</UserDocu>
</Documentation>
<Methode Name="solve" Const="true">
<Documentation>
<UserDocu>
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.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="generateSimulation" Const="true">
<Documentation>
<UserDocu>
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.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="updateForFrame" Const="true">
<Documentation>
<UserDocu>
Update entire assembly to frame number specified.
updateForFrame(index)
Args: index of frame.
Returns: None
</UserDocu>
</Documentation>
</Methode>
<Methode Name="numberOfFrames" Const="true">
<Documentation>
<UserDocu>
numberOfFrames()
Args: None
Returns: Number of frames
</UserDocu>
</Documentation>
</Methode>
<Methode Name="undoSolve" Const="true">
<Documentation>
<UserDocu>
Undo the last solve of the assembly and return part placements to their initial position.
undoSolve()
Returns: None
</UserDocu>
</Documentation>
</Methode>
<Methode Name="ensureIdentityPlacements" Const="true">
<Documentation>
<UserDocu>
Makes sure that LinkGroups or sub-assemblies have identity placements.
ensureIdentityPlacements()
Returns: None
</UserDocu>
</Documentation>
</Methode>
<Methode Name="clearUndo" Const="true">
<Documentation>
<UserDocu>
Clear the registered undo positions.
clearUndo()
Returns: None
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isPartConnected" Const="true">
<Documentation>
<UserDocu>
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
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isJointConnectingPartToGround" Const="true">
<Documentation>
<UserDocu>
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
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isPartGrounded" Const="true">
<Documentation>
<UserDocu>
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
</UserDocu>
</Documentation>
</Methode>
<Methode Name="exportAsASMT" Const="true">
<Documentation>
<UserDocu>
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.
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Joints" ReadOnly="true">
<Documentation>
<UserDocu>A list of all joints this assembly has.</UserDocu>
</Documentation>
<Parameter Name="Joints" Type="List"/>
</Attribute>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -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.
"""

View File

@@ -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.
"""

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectGroupPy"
Name="BomGroupPy"
Twin="BomGroup"
TwinPointer="BomGroup"
Include="Mod/Assembly/App/BomGroup.h"
Namespace="Assembly"
FatherInclude="App/DocumentObjectGroupPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is a group subclass for boms.</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -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.
"""

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="SheetPy"
Name="BomObjectPy"
Twin="BomObject"
TwinPointer="BomObject"
Include="Mod/Assembly/App/BomObject.h"
Namespace="Assembly"
FatherInclude="Mod/Spreadsheet/App/SheetPy.h"
FatherNamespace="Spreadsheet">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is the BOM object of assemblies, it derives from Spreadsheet::Sheet.</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -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})

View File

@@ -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.
"""

View File

@@ -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.
"""

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectGroupPy"
Name="JointGroupPy"
Twin="JointGroup"
TwinPointer="JointGroup"
Include="Mod/Assembly/App/JointGroup.h"
Namespace="Assembly"
FatherInclude="App/DocumentObjectGroupPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is a group subclass for joints.</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -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.
"""

View File

@@ -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.
"""

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectGroupPy"
Name="SimulationGroupPy"
Twin="SimulationGroup"
TwinPointer="SimulationGroup"
Include="Mod/Assembly/App/SimulationGroup.h"
Namespace="Assembly"
FatherInclude="App/DocumentObjectGroupPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is a group subclass for joints.</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -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.
"""

View File

@@ -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.
"""

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectGroupPy"
Name="ViewGroupPy"
Twin="ViewGroup"
TwinPointer="ViewGroup"
Include="Mod/Assembly/App/ViewGroup.h"
Namespace="Assembly"
FatherInclude="App/DocumentObjectGroupPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is a group subclass for joints.</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>