pythonscad --trust-python -D'run="all"' -D'label="rabbit"' planklabel.py -o "rabbit.3mf"
I think the values are not transferred to the py program. When running above command the variables are stil the default value.
Some hints to solve this?
It's a very simple program to create plant-labels.
#####################
# Title: planklabel
# Author: Matthieu Hendriks
# Date: 2025-10-05
# License: t.b.d
#
#####################
# Title: planklabel
# start include section
#####################
# Title: planklabel
from python.mhlib.mhlib import *
from python.mhscrews.mhscrews import *
import os
#####################
# start constants section
#####################
# constants
fn=128;
run="all"
xPlank=120
wall=2
yPlank=22
zVleugel=100
xVleugel=80
label="Knoflook"
#####################
# start module section
#####################
label="Konijn"
print(label)
def zijde(r=90):
obj=mvz(rotx(mvz(triangle(xVleugel,zVleugel,d=5,z=wall),-wall/2),r),5/2)
return(obj)
def top():
obj=plate(x=xPlank,y=yPlank+2*wall,z=wall,d=5)
return(obj)
def print_label():
o1=mv(zijde(r=87),0,-yPlank/2-wall/2+0.2,0.4)
o2=top()
o3=mv(zijde(r=93),0,yPlank/2+wall/2-0.2,0.4)
o4=union(o1,o2,o3)
obj=difference(o4,print_text())
return(obj)
def print_text(txt=label,size=14,h=1):
t = text(txt, size=size, font="Liberation Sans", halign="center", valign="center")
obj =roty( mvz(color(linear_extrude(t,height=h),"Red"),-h),180)
return(obj)
def print_zijde():
obj=triangle(xPlank-5,zVleugel,d=5,z=wall)
return (obj)
#####################
# start run section
#####################
# runstart Start:autogenerated run file
os.makedirs("/home/matthieu/pyscad_drawings/slicer_files/planklabel", exist_ok=True)
parts={}
parts["text"]=print_text()
parts["label"]=print_label()
num=1
fname=label.strip(' ')
for name, obj in parts.items():
path = f"/home/matthieu/pyscad_drawings/slicer_files/planklabel/{name}.3mf"
export(obj, path)
num=num+1
export(obj, path)
if run == "all":
show(list(parts.values()))
path=f"/home/matthieu/pyscad_drawings/slicer_files/planklabel/planklabel_{fname}.3mf"
export(parts, path)
else:
show(parts[run])
# runeind End:autogenerated run file