discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

add 2d on projection

F
fractorr
Wed, Jan 27, 2021 6:13 PM

Is it possible to add 2D functions after doing a projection ?  I want to draw
a cube in a projection and then add some 2D line on the cube and export that
as a svg file, like shown in the image.  The problem is that when I render
it the red line are gone. Any way to accomplish this?

http://forum.openscad.org/file/t1255/cube.jpg

http://forum.openscad.org/file/t1255/cube-2.jpg

This is the code I am playing around with.

projection() {
color("#ff0000") {
cube([50, 50, 10]);
}
}

translate([15, 0, 0])
color("#ff0000") {
square([1, 50], false);
}

translate([35, 0, 0])
color("#ff0000") {
square([1, 50], false);
}

--
Sent from: http://forum.openscad.org/

Is it possible to add 2D functions after doing a projection ? I want to draw a cube in a projection and then add some 2D line on the cube and export that as a svg file, like shown in the image. The problem is that when I render it the red line are gone. Any way to accomplish this? <http://forum.openscad.org/file/t1255/cube.jpg> <http://forum.openscad.org/file/t1255/cube-2.jpg> This is the code I am playing around with. projection() { color("#ff0000") { cube([50, 50, 10]); } } translate([15, 0, 0]) color("#ff0000") { square([1, 50], false); } translate([35, 0, 0]) color("#ff0000") { square([1, 50], false); } -- Sent from: http://forum.openscad.org/
L
lar3ry
Wed, Jan 27, 2021 9:44 PM

fractorr wrote

Is it possible to add 2D functions after doing a projection ?  I want to
draw
a cube in a projection and then add some 2D line on the cube and export
that
as a svg file, like shown in the image.  The problem is that when I render
it the red line are gone. Any way to accomplish this?

<http://forum.openscad.org/file/t1255/cube.jpg>

<http://forum.openscad.org/file/t1255/cube-2.jpg>

This is the code I am playing around with.

projection() {
color("#ff0000") {
cube([50, 50, 10]);
}
}

translate([15, 0, 0])
color("#ff0000") {
square([1, 50], false);
}

translate([35, 0, 0])
color("#ff0000") {
square([1, 50], false);
}

Not sure what you're trying to do, but yes, you can add 2D functions after
doing a projection.
However, you can't just draw a line and have it show up. If, for example,
you are trying to make a line on a 2D figure, then have that show up if you
are laser-cutting or engraving, you will need to use a 2D program like
Inkscape, and depending on your laser cutting software, colour various parts
of it to tell the cutter what to do. I use K40 Whisperer, and if I colour
something red, it will cut. Blue will tell it to vector engrave, and white
through black will tell it to raster engrave.

You can render a 2D drawing and export it as an SVG file, which you can then
load into a 2D program like Inkscape, and further modify it with things that
OpenSCAD can't do, or can't easily do.

union() {
difference() {
projection() {
color("#ff0000") {
cube([50, 50, 10]);
}
}

	translate([15, 0, 0])
		color("#ff0000") {
			square([1, 50], false);
		}
		
	translate([35, 0, 0])
		color("#ff0000") {
			square([1, 50], false);
		}
	translate([8,20])
		circle(4);
		
	translate([21,20])
		square(8);
	}

	translate([0,10,0])
		square([40,3]);

}

--
Sent from: http://forum.openscad.org/

fractorr wrote > Is it possible to add 2D functions after doing a projection ? I want to > draw > a cube in a projection and then add some 2D line on the cube and export > that > as a svg file, like shown in the image. The problem is that when I render > it the red line are gone. Any way to accomplish this? > > &lt;http://forum.openscad.org/file/t1255/cube.jpg&gt; > > &lt;http://forum.openscad.org/file/t1255/cube-2.jpg&gt; > > This is the code I am playing around with. > > projection() { > color("#ff0000") { > cube([50, 50, 10]); > } > } > > translate([15, 0, 0]) > color("#ff0000") { > square([1, 50], false); > } > > translate([35, 0, 0]) > color("#ff0000") { > square([1, 50], false); > } Not sure what you're trying to do, but yes, you can add 2D functions after doing a projection. However, you can't just draw a line and have it show up. If, for example, you are trying to make a line on a 2D figure, then have that show up if you are laser-cutting or engraving, you will need to use a 2D program like Inkscape, and depending on your laser cutting software, colour various parts of it to tell the cutter what to do. I use K40 Whisperer, and if I colour something red, it will cut. Blue will tell it to vector engrave, and white through black will tell it to raster engrave. You can render a 2D drawing and export it as an SVG file, which you can then load into a 2D program like Inkscape, and further modify it with things that OpenSCAD can't do, or can't easily do. union() { difference() { projection() { color("#ff0000") { cube([50, 50, 10]); } } translate([15, 0, 0]) color("#ff0000") { square([1, 50], false); } translate([35, 0, 0]) color("#ff0000") { square([1, 50], false); } translate([8,20]) circle(4); translate([21,20]) square(8); } translate([0,10,0]) square([40,3]); } -- Sent from: http://forum.openscad.org/
F
fractorr
Wed, Jan 27, 2021 10:35 PM

I was able to add the lines after exporting to SVG using inkscape as well but
was hoping to avoid doing that since I have more complex shapes I was
planning on doing this with.  And yes the added 2D lines was for the
engraving and why it was different color than cube so I could cut the shape
and engrave the added lines.

--
Sent from: http://forum.openscad.org/

I was able to add the lines after exporting to SVG using inkscape as well but was hoping to avoid doing that since I have more complex shapes I was planning on doing this with. And yes the added 2D lines was for the engraving and why it was different color than cube so I could cut the shape and engrave the added lines. -- Sent from: http://forum.openscad.org/
HL
Hans L
Wed, Jan 27, 2021 11:53 PM

The general issue with using openscad for engraving lines etc. is that it
is designed strictly for modeling solids.

In 2D this means the only lines you can render are the borders of closed
polygons, and if those borders overlap they will be implicitly unioned into
a single polygon.

However, if you run a development snapshot of OpenSCAD, you can enable the
experimental "lazy-union" Feature in Preferences, which can make it
possible to export overlapping shapes in 2D.
But still we don't really have "multi-material" support so renders and
exports are basically monotone.

color() is only really usable in preview mode for visualization purposes.

-Hans

On Wed, Jan 27, 2021 at 4:36 PM fractorr fractorr@gmail.com wrote:

I was able to add the lines after exporting to SVG using inkscape as well
but
was hoping to avoid doing that since I have more complex shapes I was
planning on doing this with.  And yes the added 2D lines was for the
engraving and why it was different color than cube so I could cut the shape
and engrave the added lines.

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

The general issue with using openscad for engraving lines etc. is that it is designed strictly for modeling solids. In 2D this means the only lines you can render are the borders of closed polygons, and if those borders overlap they will be implicitly unioned into a single polygon. However, if you run a development snapshot of OpenSCAD, you can enable the experimental "lazy-union" Feature in Preferences, which can make it possible to export overlapping shapes in 2D. But still we don't really have "multi-material" support so renders and exports are basically monotone. color() is only really usable in preview mode for visualization purposes. -Hans On Wed, Jan 27, 2021 at 4:36 PM fractorr <fractorr@gmail.com> wrote: > I was able to add the lines after exporting to SVG using inkscape as well > but > was hoping to avoid doing that since I have more complex shapes I was > planning on doing this with. And yes the added 2D lines was for the > engraving and why it was different color than cube so I could cut the shape > and engrave the added lines. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
F
fractorr
Thu, Jan 28, 2021 12:47 AM

okay, thanks.  That is a great explanation.  I didn't really think there
would be a way to do it but I was hoping there was.

--
Sent from: http://forum.openscad.org/

okay, thanks. That is a great explanation. I didn't really think there would be a way to do it but I was hoping there was. -- Sent from: http://forum.openscad.org/
F
fractorr
Sat, Jan 30, 2021 8:04 PM

I figured out a way to do this, it is a 3 step process but it works without
having to use inkscape which is great and much faster.  I first generate the
cube as an svg, then I generate the grooves as an svg.  I then edit the cube
svg and put the grooves svg path in cube svg file and outline it with a
different color. A little bit of a manual process but works much better and
faster than trying to draw it manually in inkscape.

--
Sent from: http://forum.openscad.org/

I figured out a way to do this, it is a 3 step process but it works without having to use inkscape which is great and much faster. I first generate the cube as an svg, then I generate the grooves as an svg. I then edit the cube svg and put the grooves svg path in cube svg file and outline it with a different color. A little bit of a manual process but works much better and faster than trying to draw it manually in inkscape. -- Sent from: http://forum.openscad.org/