mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-01-17 13:38:16 +01:00
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):
|
def add_part(self, s):
|
||||||
args = []
|
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:
|
if match:
|
||||||
s = match.group(1)
|
s = match.group(1)
|
||||||
args = [match.group(2)]
|
args = [match.group(2)]
|
||||||
|
@ -81,7 +81,8 @@ def render(target, type):
|
|||||||
#
|
#
|
||||||
if mtime(part_file) > mtime(png_name):
|
if mtime(part_file) > mtime(png_name):
|
||||||
png_maker_name = "png.scad"
|
png_maker_name = "png.scad"
|
||||||
colour = [0, 146/255, 0]
|
pp1 = [0, 146/255, 0]
|
||||||
|
colour = pp1
|
||||||
if part in colours:
|
if part in colours:
|
||||||
colour = colours[part]
|
colour = colours[part]
|
||||||
if not '[' in colour:
|
if not '[' in colour:
|
||||||
@ -89,7 +90,7 @@ def render(target, type):
|
|||||||
with open(png_maker_name, "w") as f:
|
with open(png_maker_name, "w") as f:
|
||||||
f.write('color(%s) import("%s");\n' % (colour, part_file))
|
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"
|
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'
|
tmp_name = 'tmp.png'
|
||||||
openscad.run(colour_scheme, "--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall", "-o", tmp_name, png_maker_name);
|
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"
|
do_cmd(("magick "+ tmp_name + " -trim -resize 280x280 -background %s -gravity Center -extent 280x280 -bordercolor %s -border 10 %s"
|
||||||
|
@ -107,7 +107,7 @@ module stl_colour(colour = pp1_colour, alpha = 1) { //! Colour an stl where it i
|
|||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
|
|
||||||
module stl(name) { //! Name an stl that will appear on the BOM, there needs to a module named ```<name>_stl``` to make it
|
module stl(name) { //! Name an stl that will appear on the BOM, there needs to a module named ```<name>_stl``` to make it
|
||||||
if(bom_mode()) {
|
if(bom_mode()) {
|
||||||
colour = is_undef($stl_colour) ? pp1_colour : $stl_colour;
|
colour = is_undef($stl_colour) ? pp1_colour : $stl_colour;
|
||||||
echo(str("~", name, ".stl(colour='", colour, "')"));
|
echo(str("~", name, ".stl(colour='", colour, "')"));
|
||||||
@ -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
|
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()) {
|
||||||
echo(str("~", name, ".dxf"));
|
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
|
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();
|
render() children();
|
||||||
|
|
||||||
module render_2D_sheet(type, colour = false) //! Extrude a 2D sheet template and give it the correct colour
|
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))
|
||||||
linear_extrude(sheet_thickness(type), center = true)
|
color($dxf_colour)
|
||||||
children();
|
linear_extrude(sheet_thickness(type), center = true)
|
||||||
|
children();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user