Core: Fixing missing python bindings. (#23054)

* Adding missing python interfaces.

* fixing interface includes.

* attempting fix for CI build error related to path resolution.

* testing build

* More testing via Github Actions...

* renaming files

* fixing comparison operator.

* reverting...

* fixing CMakeLists

* fixing binding generation issue
This commit is contained in:
Ian Abreu
2025-08-24 23:43:39 -04:00
committed by GitHub
parent d77a070bc8
commit 8533b4fbb8
8 changed files with 256 additions and 83 deletions

View File

@@ -23,6 +23,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)
set(AssemblyGui_UIC_SRCS
TaskAssemblyCreateBom.ui

View File

@@ -0,0 +1,50 @@
from typing import Any
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):
"""
This is the ViewProviderAssembly class
"""
def isInEditMode(self) -> Any:
"""
Return true if the assembly object is currently in edit mode.
isInEditMode() -> bool"""
...
def getDragger(self) -> Any:
"""
Return the assembly dragger coin object.
getDragger() -> SoTransformDragger
Returns: dragger coin object of the assembly"""
...
EnableMovement: bool
"""Enable moving the parts by clicking and dragging."""
MoveOnlyPreselected: bool
"""If enabled, only the preselected object will move."""
MoveInCommand: bool
"""If enabled, each move will be wrapped in a command."""
DraggerVisibility: bool
"""Show or hide the assembly dragger."""
DraggerPlacement: Any
"""Placement of the assembly dragger object."""

View File

@@ -31,6 +31,7 @@ SET(PathSimulator_SRCS
)
generate_from_xml(PathSimPy)
generate_from_py_(PathSimPy)
SOURCE_GROUP("Python" FILES ${Python_SRCS})

View File

@@ -0,0 +1,54 @@
from typing import Any, Final
from Base.BaseClass import BaseClass
from Base.Metadata import export
@export(
Father="BaseClassPy",
Name="PathSimPy",
Twin="PathSim",
TwinPointer="PathSim",
FatherInclude="Base/BaseClassPy.h",
FatherNamespace="Base",
Include="Mod/CAM/PathSimulator/App/PathSim.h",
Namespace="PathSimulator",
ReadOnly=["Tool"],
Constructor=True,
Delete=True,
)
class PathSimPy(BaseClass):
"""
FreeCAD python wrapper of PathSimulator
PathSimulator.PathSim():
Create a path simulator object
"""
def BeginSimulation(self, **kwargs) -> Any:
"""BeginSimulation(stock, resolution):
Start a simulation process on a box shape stock with given resolution"""
...
def SetToolShape(self) -> Any:
"""SetToolShape(shape):
Set the shape of the tool to be used for simulation"""
...
def GetResultMesh(self) -> Any:
"""
GetResultMesh():
Return the current mesh result of the simulation."""
...
def ApplyCommand(self, **kwargs) -> Any:
"""
ApplyCommand(placement, command):
Apply a single path command on the stock starting from placement."""
...
Tool: Final[Any]
"""Return current simulation tool."""

View File

@@ -0,0 +1,62 @@
from typing import Any
from Base.BaseClass import BaseClass
from Base.Metadata import export
from Metadata import no_args
@export(
Father="BaseClassPy",
Name="CAMSimPy",
Twin="CAMSim",
TwinPointer="CAMSim",
Include="Mod/CAM/PathSimulator/AppGL/CAMSim.h",
FatherInclude="Base/BaseClassPy.h",
FatherNamespace="Base",
Namespace="CAMSimulator",
Constructor=True,
Delete=True,
)
class CAMSimPy(BaseClass):
"""
FreeCAD python wrapper of CAMSimulator
CAMSimulator.CAMSim():
Create a path simulator object
"""
def BeginSimulation(self, **kwargs) -> Any:
"""
BeginSimulation(stock, resolution):
Start a simulation process on a box shape stock with given resolution"""
...
@no_args
def ResetSimulation(self) -> Any:
"""
ResetSimulation():
Clear the simulation and all gcode commands"""
...
def AddTool(self, **kwargs) -> Any:
"""
AddTool(shape, toolnumber, diameter, resolution):
Set the shape of the tool to be used for simulation"""
...
def SetBaseShape(self, **kwargs) -> Any:
"""
SetBaseShape(shape, resolution):
Set the shape of the base object of the job"""
...
def AddCommand(self) -> Any:
"""
AddCommand(command):
Add a path command to the simulation."""
...

View File

@@ -68,7 +68,7 @@ SET(CAMSimulator_SRCS_Core
generate_from_xml(CAMSimPy)
generate_from_py_(CAMSimPy)
SOURCE_GROUP("Module" FILES ${CAMSimulator_SRCS_Module})
SOURCE_GROUP("Python" FILES ${CAMSimulator_SRCS_Python})

View File

@@ -50,6 +50,7 @@ endif()
generate_from_xml(FemMeshPy)
generate_from_py_(FemMeshPy)
SET(Python_SRCS

View File

@@ -13,15 +13,13 @@ from App.ComplexGeoData import ComplexGeoData
Namespace="Fem",
FatherInclude="App/ComplexGeoDataPy.h",
FatherNamespace="Data",
Constructor=True,
)
class FemMeshPy(ComplexGeoData):
"""
FemMesh class
"""
@staticmethod
def PyMake(args: list, kwd: dict) -> Any: ...
def __init__(self, *args, **kwargs) -> None: ...
def setShape(self) -> Any:
"""Set the Part shape to mesh"""
...
@@ -71,61 +69,64 @@ class FemMeshPy(ComplexGeoData):
...
def read(self) -> Any:
"""Read in a various FEM mesh file formats.
read(file.endingToExportTo)
supported formats: DAT, INP, MED, STL, UNV, VTK, Z88"""
"""
Read in a various FEM mesh file formats.
read(file.endingToExportTo)
supported formats: DAT, INP, MED, STL, UNV, VTK, Z88"""
...
@constmethod
def write(self) -> Any:
"""Write out various FEM mesh file formats.
write(file.endingToExportTo)
supported formats: BDF, DAT, INP, MED, STL, UNV, VTK, Z88"""
"""
Write out various FEM mesh file formats.
write(file.endingToExportTo)
supported formats: BDF, DAT, INP, MED, STL, UNV, VTK, Z88"""
...
@constmethod
def writeABAQUS(self) -> Any:
"""Write out as ABAQUS inp
writeABAQUS(file, int elemParam, bool groupParam, str volVariant, str faceVariant, str edgeVariant)
def writeABAQUS(self, **kwargs) -> Any:
"""
Write out as ABAQUS inp
writeABAQUS(file, int elemParam, bool groupParam, str volVariant, str faceVariant, str edgeVariant)
elemParam:
0: All elements
1: Highest elements only
2: FEM elements only (only edges not belonging to faces and faces not belonging to volumes)
elemParam:
0: All elements
1: Highest elements only
2: FEM elements only (only edges not belonging to faces and faces not belonging to volumes)
groupParam:
True: Write group data
False: Do not write group data
groupParam:
True: Write group data
False: Do not write group data
volVariant: Volume elements
"standard": Tetra4 -> C3D4, Penta6 -> C3D6, Hexa8 -> C3D8, Tetra10 -> C3D10, Penta15 -> C3D15, Hexa20 -> C3D20
"reduced": Hexa8 -> C3D8R, Hexa20 -> C3D20R
"incompatible": Hexa8 -> C3D8I
"modified": Tetra10 -> C3D10T
"fluid": Tetra4 -> F3D4, Penta6 -> F3D6, Hexa8 -> F3D8
volVariant: Volume elements
"standard": Tetra4 -> C3D4, Penta6 -> C3D6, Hexa8 -> C3D8, Tetra10 -> C3D10, Penta15 -> C3D15, Hexa20 -> C3D20
"reduced": Hexa8 -> C3D8R, Hexa20 -> C3D20R
"incompatible": Hexa8 -> C3D8I
"modified": Tetra10 -> C3D10T
"fluid": Tetra4 -> F3D4, Penta6 -> F3D6, Hexa8 -> F3D8
faceVariant: Face elements
"shell": Tria3 -> S3, Quad4 -> S4, Tria6 -> S6, Quad8 -> S8
"shell reduced": Tria3 -> S3, Quad4 -> S4R, Tria6 -> S6, Quad8 -> S8R
"membrane": Tria3 -> M3D3, Quad4 -> M3D4, Tria6 -> M3D6, Quad8 -> M3D8
"membrane reduced": Tria3 -> M3D3, Quad4 -> M3D4R, Tria6 -> M3D6, Quad8 -> M3D8R
"stress": Tria3 -> CPS3, Quad4 -> CPS4, Tria6 -> CPS6, Quad8 -> CPS8
"stress reduced": Tria3 -> CPS3, Quad4 -> CPS4R, Tria6 -> CPS6, Quad8 -> CPS8R
"strain": Tria3 -> CPE3, Quad4 -> CPE4, Tria6 -> CPE6, Quad8 -> CPE8
"strain reduced": Tria3 -> CPE3, Quad4 -> CPE4R, Tria6 -> CPE6, Quad8 -> CPE8R
"axisymmetric": Tria3 -> CAX3, Quad4 -> CAX4, Tria6 -> CAX6, Quad8 -> CAX8
"axisymmetric reduced": Tria3 -> CAX3, Quad4 -> CAX4R, Tria6 -> CAX6, Quad8 -> CAX8R
faceVariant: Face elements
"shell": Tria3 -> S3, Quad4 -> S4, Tria6 -> S6, Quad8 -> S8
"shell reduced": Tria3 -> S3, Quad4 -> S4R, Tria6 -> S6, Quad8 -> S8R
"membrane": Tria3 -> M3D3, Quad4 -> M3D4, Tria6 -> M3D6, Quad8 -> M3D8
"membrane reduced": Tria3 -> M3D3, Quad4 -> M3D4R, Tria6 -> M3D6, Quad8 -> M3D8R
"stress": Tria3 -> CPS3, Quad4 -> CPS4, Tria6 -> CPS6, Quad8 -> CPS8
"stress reduced": Tria3 -> CPS3, Quad4 -> CPS4R, Tria6 -> CPS6, Quad8 -> CPS8R
"strain": Tria3 -> CPE3, Quad4 -> CPE4, Tria6 -> CPE6, Quad8 -> CPE8
"strain reduced": Tria3 -> CPE3, Quad4 -> CPE4R, Tria6 -> CPE6, Quad8 -> CPE8R
"axisymmetric": Tria3 -> CAX3, Quad4 -> CAX4, Tria6 -> CAX6, Quad8 -> CAX8
"axisymmetric reduced": Tria3 -> CAX3, Quad4 -> CAX4R, Tria6 -> CAX6, Quad8 -> CAX8R
edgeVariant: Edge elements
"beam": Seg2 -> B31, Seg3 -> B32
"beam reduced": Seg2 -> B31R, Seg3 -> B32R
"truss": Seg2 -> T3D2, eg3 -> T3D3
"network": Seg3 -> D
edgeVariant: Edge elements
"beam": Seg2 -> B31, Seg3 -> B32
"beam reduced": Seg2 -> B31R, Seg3 -> B32R
"truss": Seg2 -> T3D2, eg3 -> T3D3
"network": Seg3 -> D
Elements are selected according to CalculiX availability.
For example if volume variant "modified" is selected, Tetra10 mesh
elements are assigned to C3D10T and remain elements uses "standard".
Axisymmetric, plane strain and plane stress elements expect nodes in the plane z=0.
Elements are selected according to CalculiX availability.
For example if volume variant "modified" is selected, Tetra10 mesh
elements are assigned to C3D10T and remain elements uses "standard".
Axisymmetric, plane strain and plane stress elements expect nodes in the plane z=0.
"""
...
@@ -210,30 +211,33 @@ class FemMeshPy(ComplexGeoData):
@constmethod
def addGroup(self) -> Any:
"""Add a group to mesh with specific name and type
addGroup(name, typestring, [id])
name: string
typestring: "All", "Node", "Edge", "Face", "Volume", "0DElement", "Ball"
id: int
Optional id is used to force specific id for group, but does
not work, yet."""
"""
Add a group to mesh with specific name and type
addGroup(name, typestring, [id])
name: string
typestring: "All", "Node", "Edge", "Face", "Volume", "0DElement", "Ball"
id: int
Optional id is used to force specific id for group, but does
not work, yet."""
...
@constmethod
def addGroupElements(self) -> Any:
"""Add a tuple of ElementIDs to a given group ID
addGroupElements(groupid, list_of_elements)
groupid: int
list_of_elements: list of int
Notice that the elements have to be in the mesh."""
"""
Add a tuple of ElementIDs to a given group ID
addGroupElements(groupid, list_of_elements)
groupid: int
list_of_elements: list of int
Notice that the elements have to be in the mesh."""
...
@constmethod
def removeGroup(self) -> Any:
"""Remove a group with a given group ID
removeGroup(groupid)
groupid: int
Returns boolean."""
"""
Remove a group with a given group ID
removeGroup(groupid)
groupid: int
Returns boolean."""
...
@constmethod
@@ -245,67 +249,67 @@ class FemMeshPy(ComplexGeoData):
def getIdByElementType(self) -> Any:
"""Return a tuple of IDs to a given element type"""
...
Nodes: Final[Any]
Nodes: Final[dict]
"""Dictionary of Nodes by ID (int ID:Vector())"""
NodeCount: Final[Any]
NodeCount: Final[int]
"""Number of nodes in the Mesh."""
Edges: Final[Any]
Edges: Final[tuple]
"""Tuple of edge IDs"""
EdgesOnly: Final[Any]
EdgesOnly: Final[tuple]
"""Tuple of edge IDs which does not belong to any face (and thus not belong to any volume too)"""
EdgeCount: Final[Any]
EdgeCount: Final[int]
"""Number of edges in the Mesh."""
Faces: Final[Any]
Faces: Final[tuple]
"""Tuple of face IDs"""
FacesOnly: Final[Any]
FacesOnly: Final[tuple]
"""Tuple of face IDs which does not belong to any volume"""
FaceCount: Final[Any]
FaceCount: Final[int]
"""Number of Faces in the Mesh."""
TriangleCount: Final[Any]
TriangleCount: Final[int]
"""Number of Triangles in the Mesh."""
QuadrangleCount: Final[Any]
QuadrangleCount: Final[int]
"""Number of Quadrangles in the Mesh."""
PolygonCount: Final[Any]
PolygonCount: Final[int]
"""Number of Quadrangles in the Mesh."""
Volumes: Final[Any]
Volumes: Final[tuple]
"""Tuple of volume IDs"""
VolumeCount: Final[Any]
VolumeCount: Final[int]
"""Number of Volumes in the Mesh."""
TetraCount: Final[Any]
TetraCount: Final[int]
"""Number of Tetras in the Mesh."""
HexaCount: Final[Any]
HexaCount: Final[int]
"""Number of Hexas in the Mesh."""
PyramidCount: Final[Any]
PyramidCount: Final[int]
"""Number of Pyramids in the Mesh."""
PrismCount: Final[Any]
PrismCount: Final[int]
"""Number of Prisms in the Mesh."""
PolyhedronCount: Final[Any]
PolyhedronCount: Final[int]
"""Number of Polyhedrons in the Mesh."""
SubMeshCount: Final[Any]
SubMeshCount: Final[int]
"""Number of SubMeshs in the Mesh."""
GroupCount: Final[Any]
GroupCount: Final[int]
"""Number of Groups in the Mesh."""
Groups: Final[Any]
Groups: Final[tuple]
"""Tuple of Group IDs."""
Volume: Final[Any]