PartDesign: Convert XML bindings to Python API bindings model.

This commit is contained in:
tritao
2025-03-21 18:53:58 +00:00
committed by Benjamin Nauck
parent 176f91eea8
commit 16968aa3ee
6 changed files with 105 additions and 7 deletions

View File

@@ -0,0 +1,33 @@
from Base.Metadata import export, constmethod
from Part.BodyBase import BodyBase
from typing import Final, overload
@export(
Include="Mod/PartDesign/App/Body.h",
FatherInclude="Mod/Part/App/BodyBasePy.h",
)
class Body(BodyBase):
"""
PartDesign body class
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
Licence: LGPL
"""
VisibleFeature: Final[object] = ...
"""Return the visible feature of this body"""
def insertObject(self, feature: object, target: object, after: bool = False) -> None:
"""
insertObject(feature, target, after=False)
Insert the feature into the body after the given feature.
@param feature The feature to insert into the body
@param target The feature relative which one should be inserted the given.
If target is NULL than insert into the end if where is InsertBefore
and into the begin if where is InsertAfter.
@param after if true insert the feature after the target. Default is false.
@note the method doesn't modify the Tip unlike addObject()
"""
...

View File

@@ -16,15 +16,15 @@
<Methode Name="insertObject">
<Documentation>
<UserDocu>insertObject(feature, target, after=False)
Insert the feature into the body after the given feature.
Insert the feature into the body after the given feature.
@param feature The feature to insert into the body
@param target The feature relative which one should be inserted the given.
If target is NULL than insert into the end if where is InsertBefore
and into the begin if where is InsertAfter.
@param after if true insert the feature after the target. Default is false.
@param feature The feature to insert into the body
@param target The feature relative which one should be inserted the given.
If target is NULL than insert into the end if where is InsertBefore
and into the begin if where is InsertAfter.
@param after if true insert the feature after the target. Default is false.
@note the method doesn't modify the Tip unlike addObject()
@note the method doesn't modify the Tip unlike addObject()
</UserDocu>
</Documentation>
</Methode>

View File

@@ -12,7 +12,9 @@ include_directories(
link_directories(${OCC_LIBRARY_DIR})
generate_from_xml(BodyPy)
generate_from_py(Body)
generate_from_xml(FeaturePy)
generate_from_py(Feature)
set(PartDesign_LIBS

View File

@@ -0,0 +1,28 @@
from Base.Metadata import export
from Part.PartFeature import PartFeature
from typing import Optional, overload
@export(
Include="Mod/PartDesign/App/Feature.h",
FatherInclude="Mod/Part/App/PartFeaturePy.h",
)
class Feature(PartFeature):
"""
This is the father of all PartDesign object classes
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
Licence: LGPL
"""
@overload
def getBaseObject(self) -> Optional[object]:
"""
getBaseObject: returns feature this one fuses itself to, or None. Normally, this should be the same as BaseFeature property, except for legacy workflow. In legacy workflow, it will look up the support of referenced sketch.
"""
...
def getBaseObject(self) -> Optional[object]:
"""
getBaseObject: returns feature this one fuses itself to, or None. Normally, this should be the same as BaseFeature property, except for legacy workflow. In legacy workflow, it will look up the support of referenced sketch.
"""
...

View File

@@ -10,6 +10,7 @@ include_directories(
)
generate_from_xml(ViewProviderPy)
generate_from_py(ViewProvider)
set(PartDesignGui_LIBS

View File

@@ -0,0 +1,34 @@
from Base.Metadata import export
from Gui.ViewProviderPartExt import ViewProviderPartExt
from typing import Final, overload
@export(
Include="Mod/PartDesign/Gui/ViewProvider.h",
Namespace="PartDesignGui",
FatherInclude="Mod/Part/Gui/ViewProviderPartExtPy.h",
FatherNamespace="PartGui"
)
class ViewProvider(ViewProviderPartExt):
"""
This is the father of all PartDesign ViewProvider classes
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
Licence: LGPL
"""
def setBodyMode(self, mode: bool) -> None:
"""
setBodyMode(bool): body mode means that the object is part of a body
and that the body is used to set the visual properties, not the features. Hence
setting body mode to true will hide most viewprovider properties.
"""
...
def makeTemporaryVisible(self, visible: bool) -> None:
"""
makeTemporaryVisible(bool): makes this viewprovider visible in the
scene graph without changing any properties, not the visibility one and also not
the display mode. This can be used to show the shape of this viewprovider from
other viewproviders without doing anything to the document and properties.
"""
...