Renders of dxfs now use the sheet colour.
This commit is contained in:
parent
9da8634769
commit
52011fd6f7
|
@ -82,7 +82,7 @@ class BOM:
|
|||
|
||||
def add_part(self, s):
|
||||
args = []
|
||||
match = re.match(r'^(.*?\.stl)\((.*)\)$', s) #look for name.stl(...)
|
||||
match = re.match(r'^(.*?\.stl|.*?\.dxf)\((.*)\)$', s) #look for name.stl(...) or name.dxf(...)
|
||||
if match:
|
||||
s = match.group(1)
|
||||
args = [match.group(2)]
|
||||
|
|
|
@ -81,7 +81,8 @@ def render(target, type):
|
|||
#
|
||||
if mtime(part_file) > mtime(png_name):
|
||||
png_maker_name = "png.scad"
|
||||
colour = [0, 146/255, 0]
|
||||
pp1 = [0, 146/255, 0]
|
||||
colour = pp1
|
||||
if part in colours:
|
||||
colour = colours[part]
|
||||
if not '[' in colour:
|
||||
|
@ -89,7 +90,7 @@ def render(target, type):
|
|||
with open(png_maker_name, "w") as f:
|
||||
f.write('color(%s) import("%s");\n' % (colour, part_file))
|
||||
cam = "--camera=0,0,0,70,0,315,500" if type == 'stl' else "--camera=0,0,0,0,0,0,500"
|
||||
render = "--preview" if type == 'stl' else "--render"
|
||||
render = "--preview" if type == 'stl' or colour != pp1 else "--render"
|
||||
tmp_name = 'tmp.png'
|
||||
openscad.run(colour_scheme, "--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall", "-o", tmp_name, png_maker_name);
|
||||
do_cmd(("magick "+ tmp_name + " -trim -resize 280x280 -background %s -gravity Center -extent 280x280 -bordercolor %s -border 10 %s"
|
||||
|
|
|
@ -115,8 +115,12 @@ module stl(name) { //! Name an stl that will appear on the BOM, there needs to a
|
|||
}
|
||||
|
||||
module dxf(name) { //! Name a dxf that will appear on the BOM, there needs to a module named ```<name>_dxf``` to make it
|
||||
if(bom_mode())
|
||||
if(bom_mode()) {
|
||||
if(is_undef($dxf_colour))
|
||||
echo(str("~", name, ".dxf"));
|
||||
else
|
||||
echo(str("~", name, ".dxf(colour='", $dxf_colour, "')"));
|
||||
}
|
||||
}
|
||||
|
||||
function value_string(value) = is_string(value) ? str("\"", value, "\"") : str(value); //! Convert ```value``` to a string or quote it if it is already a string
|
||||
|
|
|
@ -83,6 +83,7 @@ module render_sheet(type, colour = false) //! Render a sheet in the correct colo
|
|||
render() children();
|
||||
|
||||
module render_2D_sheet(type, colour = false) //! Extrude a 2D sheet template and give it the correct colour
|
||||
color(colour ? colour : sheet_colour(type))
|
||||
let($dxf_colour = colour ? colour : sheet_colour(type))
|
||||
color($dxf_colour)
|
||||
linear_extrude(sheet_thickness(type), center = true)
|
||||
children();
|
||||
|
|
Loading…
Reference in New Issue