OpenSCAD: Prevent user to remove core properties

This commit is contained in:
Florian Foinant-Willig
2025-03-16 22:50:43 +01:00
committed by Kacper Donat
parent 8a733f450b
commit 286483ff7d

View File

@@ -169,8 +169,8 @@ static char * openscadlogo_xpm[] = {
class OpenSCADPlaceholder:
def __init__(self,obj,children=None,arguments=None):
obj.addProperty("App::PropertyLinkList",'Children','OpenSCAD',"Base Objects")
obj.addProperty("App::PropertyString",'Arguments','OpenSCAD',"Arguments")
obj.addProperty("App::PropertyLinkList",'Children','OpenSCAD',"Base Objects", locked=True)
obj.addProperty("App::PropertyString",'Arguments','OpenSCAD',"Arguments", locked=True)
obj.Proxy = self
if children:
obj.Children = children
@@ -189,10 +189,10 @@ class Resize:
self.Target = target
self.Vector = vector
#obj.addProperty("App::PropertyPythonObject","Object","Resize", \
# "Object to be resized").Object = target
obj.addProperty("Part::PropertyPartShape","Shape","Resize", "Shape of the Resize")
# "Object to be resized", locked=True).Object = target
obj.addProperty("Part::PropertyPartShape","Shape","Resize", "Shape of the Resize", locked=True)
obj.addProperty("App::PropertyVector","Vector","Resize",
" Resize Vector").Vector = FreeCAD.Vector(vector)
" Resize Vector", locked=True).Vector = FreeCAD.Vector(vector)
obj.Proxy = self
def execute(self, fp):
@@ -213,8 +213,8 @@ class Resize:
class MatrixTransform:
def __init__(self, obj,matrix=None,child=None):
obj.addProperty("App::PropertyLink","Base","Base",
"The base object that must be tranfsformed")
obj.addProperty("App::PropertyMatrix","Matrix","Matrix", "Transformation Matrix")
"The base object that must be tranfsformed", locked=True)
obj.addProperty("App::PropertyMatrix","Matrix","Matrix", "Transformation Matrix", locked=True)
obj.Proxy = self
obj.Matrix = matrix
obj.Base = child
@@ -240,7 +240,7 @@ class MatrixTransform:
class ImportObject:
def __init__(self, obj,child=None):
obj.addProperty("App::PropertyLink", "Base", "Base",
"The base object that must be tranfsformed")
"The base object that must be tranfsformed", locked=True)
obj.Proxy = self
obj.Base = child
@@ -258,7 +258,7 @@ class RefineShape:
'''return a refined shape'''
def __init__(self, obj, child=None):
obj.addProperty("App::PropertyLink", "Base", "Base",
"The base object that must be refined")
"The base object that must be refined", locked=True)
obj.Proxy = self
obj.Base = child
@@ -277,10 +277,10 @@ class IncreaseTolerance:
in the current implementation its' placement is linked'''
def __init__(self,obj,child,tolerance=0):
obj.addProperty("App::PropertyLink", "Base", "Base",
"The base object that wire must be extracted")
obj.addProperty("App::PropertyDistance","Vertex","Tolerance","Vertexes tolerance (0 default)")
obj.addProperty("App::PropertyDistance","Edge","Tolerance","Edges tolerance (0 default)")
obj.addProperty("App::PropertyDistance","Face","Tolerance","Faces tolerance (0 default)")
"The base object that wire must be extracted", locked=True)
obj.addProperty("App::PropertyDistance","Vertex","Tolerance","Vertexes tolerance (0 default)", locked=True)
obj.addProperty("App::PropertyDistance","Edge","Tolerance","Edges tolerance (0 default)", locked=True)
obj.addProperty("App::PropertyDistance","Face","Tolerance","Faces tolerance (0 default)", locked=True)
obj.Base = child
obj.Vertex = tolerance
obj.Edge = tolerance
@@ -311,7 +311,7 @@ class GetWire:
'''return the first wire from a given shape'''
def __init__(self, obj, child=None):
obj.addProperty("App::PropertyLink","Base","Base",
"The base object that wire must be extracted")
"The base object that wire must be extracted", locked=True)
obj.Proxy = self
obj.Base = child
@@ -328,10 +328,10 @@ class GetWire:
class Frustum:
def __init__(self, obj,r1=1,r2=2,n=3,h=4):
obj.addProperty("App::PropertyInteger","FacesNumber","Base","Number of faces")
obj.addProperty("App::PropertyDistance","Radius1","Base","Radius of lower the inscribed control circle")
obj.addProperty("App::PropertyDistance","Radius2","Base","Radius of upper the inscribed control circle")
obj.addProperty("App::PropertyDistance","Height","Base","Height of the Frustum")
obj.addProperty("App::PropertyInteger","FacesNumber","Base","Number of faces", locked=True)
obj.addProperty("App::PropertyDistance","Radius1","Base","Radius of lower the inscribed control circle", locked=True)
obj.addProperty("App::PropertyDistance","Radius2","Base","Radius of upper the inscribed control circle", locked=True)
obj.addProperty("App::PropertyDistance","Height","Base","Height of the Frustum", locked=True)
obj.FacesNumber = n
obj.Radius1 = r1
@@ -372,11 +372,11 @@ class Twist:
def __init__(self, obj, child=None, h=1.0, angle=0.0, scale=[1.0,1.0]):
import FreeCAD
obj.addProperty("App::PropertyLink","Base","Base",
"The base object that must be transformed")
obj.addProperty("App::PropertyQuantity","Angle","Base","Twist Angle")
"The base object that must be transformed", locked=True)
obj.addProperty("App::PropertyQuantity","Angle","Base","Twist Angle", locked=True)
obj.Angle = FreeCAD.Units.Angle # assign the Angle unit
obj.addProperty("App::PropertyDistance","Height","Base","Height of the Extrusion")
obj.addProperty("App::PropertyFloatList","Scale","Base","Scale to apply during the Extrusion")
obj.addProperty("App::PropertyDistance","Height","Base","Height of the Extrusion", locked=True)
obj.addProperty("App::PropertyFloatList","Scale","Base","Scale to apply during the Extrusion", locked=True)
obj.Base = child
obj.Angle = angle
@@ -441,9 +441,9 @@ class Twist:
class PrismaticToroid:
def __init__(self, obj,child=None,angle=360.0,n=3):
obj.addProperty("App::PropertyLink","Base","Base",
"The 2D face that will be swept")
obj.addProperty("App::PropertyAngle","Angle","Base","Angle to sweep through")
obj.addProperty("App::PropertyInteger","Segments","Base","Number of segments per 360° (OpenSCAD's \"$fn\")")
"The 2D face that will be swept", locked=True)
obj.addProperty("App::PropertyAngle","Angle","Base","Angle to sweep through", locked=True)
obj.addProperty("App::PropertyInteger","Segments","Base","Number of segments per 360° (OpenSCAD's \"$fn\")", locked=True)
obj.Base = child
obj.Angle = angle
@@ -517,8 +517,8 @@ class PrismaticToroid:
class OffsetShape:
def __init__(self, obj,child=None,offset=1.0):
obj.addProperty("App::PropertyLink","Base","Base",
"The base object that must be transformed")
obj.addProperty("App::PropertyDistance","Offset","Base","Offset outwards")
"The base object that must be transformed", locked=True)
obj.addProperty("App::PropertyDistance","Offset","Base","Offset outwards", locked=True)
obj.Base = child
obj.Offset = offset
@@ -530,9 +530,9 @@ class OffsetShape:
class CGALFeature:
def __init__(self,obj,opname=None,children=None,arguments=None):
obj.addProperty("App::PropertyLinkList",'Children','OpenSCAD',"Base Objects")
obj.addProperty("App::PropertyString",'Arguments','OpenSCAD',"Arguments")
obj.addProperty("App::PropertyString",'Operation','OpenSCAD',"Operation")
obj.addProperty("App::PropertyLinkList",'Children','OpenSCAD',"Base Objects", locked=True)
obj.addProperty("App::PropertyString",'Arguments','OpenSCAD',"Arguments", locked=True)
obj.addProperty("App::PropertyString",'Operation','OpenSCAD',"Operation", locked=True)
obj.Proxy = self
if opname:
obj.Operation = opname