New generator: Desksign

a simple angled sign that stands on its own
This commit is contained in:
J-Waal 2023-04-08 23:39:41 +02:00 committed by Florian Festi
parent b9a14c1793
commit 7ce8e4b6ee
4 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,86 @@
#!/usr/bin/env python3
# Copyright (C) 2013-2014 Florian Festi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import *
class Desksign(Boxes):
"""Simple diagonal plate with stands to show name or mesage"""
description = """Text to be engraved can be genarated by inputing the label and fontsize fields.
height represents the area that can be used for writing text, does not match the actual
height when standing. Generated text is put in the center. Currently only a single
line of text is supported."""
ui_group = "Misc"
def __init__(self) -> None:
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(edges.StackableSettings, width=2.0) # used for feet
self.argparser.add_argument(
"--width", action="store", type=float, default=150,
help="plate width in mm (excluding holes)")
self.argparser.add_argument(
"--height", action="store", type=float, default=80,
help="plate height in mm")
self.argparser.add_argument(
"--angle", action="store", type=float, default=60,
help="plate angle in degrees (90 is vertical)")
self.argparser.add_argument(
"--label", action="store", type=str, default="",
help="optional text to engrave (leave blank to omit)")
self.argparser.add_argument(
"--fontsize", action="store", type=float, default=20,
help="height of text")
self.argparser.add_argument(
"--feet", action="store", type=boolarg, default=False,
help="add raised feet")
self.argparser.add_argument(
"--mirror", action="store", type=boolarg, default=True,
help="mirrors one of the stand so the same side of the material can be placed on the outside")
def render(self):
width = self.width
height = self.height
angle = self.angle
feet = self.feet
mirror = self.mirror
t = self.thickness
if not (0 < angle and angle < 90):
raise ValueError("angle has to between 0 and 90 degrees")
base = math.cos(math.radians(angle)) * height
h = math.sin(math.radians(angle)) * height
label = self.label
fontsize = self.fontsize
if label and fontsize:
self.rectangularWall(width, height, "eheh", move="right", callback=[
lambda: self.text("%s" % label, width/2, (height-fontsize)/2,
fontsize = fontsize, align="center", color=Color.ETCHING)]) # add text
else:
self.rectangularWall(width, height, "eheh", move="right") # front
# stands at back/side
edge = "šef" if feet else "eef"
if mirror:
self.rectangularTriangle(base, h, edge, num=1, move="right")
self.rectangularTriangle(base, h, edge, num=1, move="mirror right")
else:
self.rectangularTriangle(base, h, edge, num=2, move="right")

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
static/samples/Desksign.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -138,3 +138,4 @@ eedccf62c193224e2b86e52be8cd02faddf97d565330e2d5770390141da35069 ../static/samp
e9ee43e336401d3a0cb8e141c3a0b87a84e90f99eed30bdd420dcaead92940e1 ../static/samples/NemaPattern.jpg
3070eb2ed89461497d4dcc67021a0619338ab6d4d4d89d3cd1f83160da3c7920 ../static/samples/FanHole.jpg
c8adb0661956430ccec7fc00aa4b8e3c42d02083e17a9307541bc0160251cb96 ../static/samples/HolePattern.jpg
7c399c1cd235c3c044f676a31aa5215109e815055f2f69aef5d0cb1a24dfae41 ../static/samples/Desksign.jpg