Part: Prevent user to remove core properties

This commit is contained in:
Florian Foinant-Willig
2025-03-16 22:55:06 +01:00
committed by Kacper Donat
parent 286483ff7d
commit 1ae550f6f4
6 changed files with 41 additions and 41 deletions

View File

@@ -114,13 +114,13 @@ class FeatureConnect:
"""The PartJoinFeature object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLinkList","Objects","Connect","Object to be connected.")
obj.addProperty("App::PropertyLinkList","Objects","Connect","Object to be connected.", locked=True)
obj.addProperty("App::PropertyBool","Refine","Connect",
"True = refine resulting shape. False = output as is.")
"True = refine resulting shape. False = output as is.", locked=True)
obj.Refine = getParamRefine()
obj.addProperty("App::PropertyLength","Tolerance","Connect",
"Tolerance when intersecting (fuzzy value). "
"In addition to tolerances of the shapes.")
"In addition to tolerances of the shapes.", locked=True)
obj.Proxy = self
self.Type = "FeatureConnect"
@@ -224,14 +224,14 @@ class FeatureEmbed:
"""The Part Embed object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLink","Base","Embed","Object to embed into.")
obj.addProperty("App::PropertyLink","Tool","Embed","Object to be embedded.")
obj.addProperty("App::PropertyLink","Base","Embed","Object to embed into.", locked=True)
obj.addProperty("App::PropertyLink","Tool","Embed","Object to be embedded.", locked=True)
obj.addProperty("App::PropertyBool","Refine","Embed",
"True = refine resulting shape. False = output as is.")
"True = refine resulting shape. False = output as is.", locked=True)
obj.Refine = getParamRefine()
obj.addProperty("App::PropertyLength","Tolerance","Embed",
"Tolerance when intersecting (fuzzy value). "
"In addition to tolerances of the shapes.")
"In addition to tolerances of the shapes.", locked=True)
obj.Proxy = self
self.Type = "FeatureEmbed"
@@ -319,13 +319,13 @@ class FeatureCutout:
"""The Part Cutout object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLink","Base","Cutout","Object to be cut.")
obj.addProperty("App::PropertyLink","Tool","Cutout","Object to make cutout for.")
obj.addProperty("App::PropertyLink","Base","Cutout","Object to be cut.", locked=True)
obj.addProperty("App::PropertyLink","Tool","Cutout","Object to make cutout for.", locked=True)
obj.addProperty("App::PropertyBool","Refine","Cutout",
"True = refine resulting shape. False = output as is.")
"True = refine resulting shape. False = output as is.", locked=True)
obj.Refine = getParamRefine()
obj.addProperty("App::PropertyLength","Tolerance","Cutout",
"Tolerance when intersecting (fuzzy value). In addition to tolerances of the shapes.")
"Tolerance when intersecting (fuzzy value). In addition to tolerances of the shapes.", locked=True)
obj.Proxy = self
self.Type = "FeatureCutout"

View File

@@ -65,15 +65,15 @@ class FeatureBooleanFragments:
"""The BooleanFragments feature object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLinkList","Objects","BooleanFragments","Object to compute intersections between.")
obj.addProperty("App::PropertyLinkList","Objects","BooleanFragments","Object to compute intersections between.", locked=True)
obj.addProperty("App::PropertyEnumeration","Mode","BooleanFragments",
"- Standard: wires, shells, compsolids remain in one piece.\n"
"- Split: wires, shells, compsolids are split.\n"
"- CompSolid: make compsolid from solid fragments.")
"- CompSolid: make compsolid from solid fragments.", locked=True)
obj.Mode = ["Standard", "Split", "CompSolid"]
obj.addProperty("App::PropertyLength","Tolerance","BooleanFragments",
"Tolerance when intersecting (fuzzy value). "
"In addition to tolerances of the shapes.")
"In addition to tolerances of the shapes.", locked=True)
obj.Proxy = self
self.Type = "FeatureBooleanFragments"
@@ -222,16 +222,16 @@ class FeatureSlice:
"""The Slice feature object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLink","Base","Slice","Object to be sliced.")
obj.addProperty("App::PropertyLinkList","Tools","Slice","Objects that slice.")
obj.addProperty("App::PropertyLink","Base","Slice","Object to be sliced.", locked=True)
obj.addProperty("App::PropertyLinkList","Tools","Slice","Objects that slice.", locked=True)
obj.addProperty("App::PropertyEnumeration","Mode","Slice",
"- Standard: wires, shells, compsolids remain in one piece.\n"
"- Split: wires, shells, compsolids are split.\n"
"- CompSolid: make compsolid from solid fragments.")
"- CompSolid: make compsolid from solid fragments.", locked=True)
obj.Mode = ["Standard", "Split", "CompSolid"]
obj.addProperty("App::PropertyLength","Tolerance","Slice",
"Tolerance when intersecting (fuzzy value). "
"In addition to tolerances of the shapes.")
"In addition to tolerances of the shapes.", locked=True)
obj.Proxy = self
self.Type = "FeatureSlice"
@@ -408,10 +408,10 @@ class FeatureXOR:
"""The XOR feature object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLinkList","Objects","XOR","Object to compute intersections between.")
obj.addProperty("App::PropertyLinkList","Objects","XOR","Object to compute intersections between.", locked=True)
obj.addProperty("App::PropertyLength","Tolerance","XOR",
"Tolerance when intersecting (fuzzy value). "
"In addition to tolerances of the shapes.")
"In addition to tolerances of the shapes.", locked=True)
obj.Proxy = self
self.Type = "FeatureXOR"

View File

@@ -106,11 +106,11 @@ class FeatureToleranceSet:
"""The PartToleranceSetFeature object."""
def __init__(self,obj):
obj.addProperty("App::PropertyLinkList","Objects","ToleranceSet","Objects to have tolerance adjusted.")
obj.addProperty("App::PropertyLinkList","Objects","ToleranceSet","Objects to have tolerance adjusted.", locked=True)
obj.addProperty("App::PropertyBool","Refine","ToleranceSet",
"True = refine resulting shape. False = output as is.")
obj.addProperty("App::PropertyLength","minTolerance","ToleranceSet", "0.1 nm")
obj.addProperty("App::PropertyLength","maxTolerance","ToleranceSet", "0")
"True = refine resulting shape. False = output as is.", locked=True)
obj.addProperty("App::PropertyLength","minTolerance","ToleranceSet", "0.1 nm", locked=True)
obj.addProperty("App::PropertyLength","maxTolerance","ToleranceSet", "0", locked=True)
obj.Refine = getParamRefine()
obj.Proxy = self
@@ -118,7 +118,7 @@ class FeatureToleranceSet:
def onDocumentRestored(self, obj):
if not hasattr(obj, 'maxTolerance'):
obj.addProperty("App::PropertyLength","maxTolerance","ToleranceSet", "0")
obj.addProperty("App::PropertyLength","maxTolerance","ToleranceSet", "0", locked=True)
def execute(self,selfobj):
shapes = []

View File

@@ -42,9 +42,9 @@ def makeTube(outerRadius, innerRadius, height):
class TubeFeature:
def __init__(self, obj):
obj.Proxy = self
obj.addProperty("App::PropertyLength","OuterRadius","Tube","Outer radius").OuterRadius = 5.0
obj.addProperty("App::PropertyLength","InnerRadius","Tube","Inner radius").InnerRadius = 2.0
obj.addProperty("App::PropertyLength","Height","Tube", "Height of the tube").Height = 10.0
obj.addProperty("App::PropertyLength","OuterRadius","Tube","Outer radius", locked=True).OuterRadius = 5.0
obj.addProperty("App::PropertyLength","InnerRadius","Tube","Inner radius", locked=True).InnerRadius = 2.0
obj.addProperty("App::PropertyLength","Height","Tube", "Height of the tube", locked=True).Height = 10.0
obj.addExtension("Part::AttachExtensionPython")
def execute(self, fp):

View File

@@ -49,13 +49,13 @@ class _CompoundFilter:
"""The CompoundFilter object."""
def __init__(self, obj):
obj.addProperty("App::PropertyLink", "Base", "CompoundFilter", "Compound to be filtered")
obj.addProperty("App::PropertyLink", "Base", "CompoundFilter", "Compound to be filtered", locked=True)
obj.addProperty("App::PropertyEnumeration",
"FilterType",
"CompoundFilter",
"Type of filter method to use; some of these methods "
"require, or are affected by, a 'Stencil' object.")
"require, or are affected by, a 'Stencil' object.", locked=True)
obj.FilterType = ['bypass', 'specific items', 'collision-pass',
'window-volume', 'window-area', 'window-length',
'window-distance']
@@ -65,24 +65,24 @@ class _CompoundFilter:
obj.addProperty("App::PropertyString", "items", "CompoundFilter",
"Indices of the pieces to be returned.\n"
"These are numbers separated by a semicolon, '1;3;5'.\n"
"A range can also be provided using a colon, '1;4;8:10'.")
"A range can also be provided using a colon, '1;4;8:10'.", locked=True)
obj.addProperty("App::PropertyLink", "Stencil", "CompoundFilter",
"Object that defines filtering")
"Object that defines filtering", locked=True)
obj.addProperty("App::PropertyFloat", "WindowFrom", "CompoundFilter",
"Value of threshold, expressed as a percentage of maximum value.")
"Value of threshold, expressed as a percentage of maximum value.", locked=True)
obj.WindowFrom = 80.0
obj.addProperty("App::PropertyFloat", "WindowTo", "CompoundFilter",
"Value of threshold, expressed as a percentage of maximum value.")
"Value of threshold, expressed as a percentage of maximum value.", locked=True)
obj.WindowTo = 100.0
obj.addProperty("App::PropertyFloat", "OverrideMaxVal", "CompoundFilter",
"Volume threshold, expressed as percentage of the volume of largest child")
"Volume threshold, expressed as percentage of the volume of largest child", locked=True)
obj.OverrideMaxVal = 0
obj.addProperty("App::PropertyBool", "Invert", "CompoundFilter",
"Output shapes that are rejected by the filter, instead")
"Output shapes that are rejected by the filter, instead", locked=True)
obj.Invert = False
self.Type = "CompoundFilter"
@@ -214,7 +214,7 @@ class _ViewProviderCompoundFilter:
"DontUnhideOnDelete",
"CompoundFilter",
"When this object is deleted, Base and Stencil are unhidden. "
"This flag stops it from happening.")
"This flag stops it from happening.", locked=True)
vobj.setEditorMode("DontUnhideOnDelete", 2) # set hidden
def getIcon(self):

View File

@@ -65,16 +65,16 @@ class _PartJoinFeature:
"App::PropertyEnumeration",
"Mode",
"Join",
"The mode of operation. bypass = make compound (fast)",
"The mode of operation. bypass = make compound (fast)", locked=True,
)
obj.Mode = ["bypass", "Connect", "Embed", "Cutout"]
obj.addProperty("App::PropertyLink", "Base", "Join", "First object")
obj.addProperty("App::PropertyLink", "Tool", "Join", "Second object")
obj.addProperty("App::PropertyLink", "Base", "Join", "First object", locked=True)
obj.addProperty("App::PropertyLink", "Tool", "Join", "Second object", locked=True)
obj.addProperty(
"App::PropertyBool",
"Refine",
"Join",
"True = refine resulting shape. False = output as is.",
"True = refine resulting shape. False = output as is.", locked=True,
)
obj.Proxy = self