 Classic List Threaded 8 messages Open this post in threaded view
|

 Hello there, i want to create a golden bar using polygon but when i type F6, i see this error in console: WARNING: Mixing 2D and 3D objects is not supported. WARNING: Ignoring 3D child object for 2D operation that's my script that i'm using: /*  Size of 2KG of Gold Linget Fonte  10mm x 4.3mm X 2.41mm  Calculated from Density of gold = 19.30 g/cm3 at 20°C  30 => 4.3  100 => 10  30 h =>2.41  25 => 3.15  5 => 1.15  95 => 8.85 */ l=4.3; L=10; h=2.41; top_x= (l/2)-1; // top_x=1.15 bottom_x= l-top_x; // bottom_x=3.15 L_R_h= L-top_x; // L_R_h=8.85 Points=[[0,0,0],[l,0,0],[bottom_x,top_x,h],[top_x,top_x,h],[top_x,L_R_h,h],[0,L,0],[l,L,0],[bottom_x,L_R_h,h]]; Paths=[[0,1,3],[1,3,2],[0,5,3],[5,3,4],[5,6,7],[5,7,4],[6,1,2],[7,2,6],[2,3,7],[3,7,4],[0,1,5],[1,5,6]]; module Torn() {     difference(){ translate([-2,2.25,(h/2.01)-0.48]) resize([1.6,1.2,0]) circle(r=5, center=true, \$fn=250); translate([-2,2.25,(h/2.01)-0.48]) resize([1.4,1,0]) circle(r=2, center=true, \$fn=250);     } } translate([1.995,0,0]){ Torn(); } color( "Gold" ) { translate([-(bottom_x/1.95)+1.06,2,(h/2.01)-0.48]) resize([1,0.5,0]) text("Gold"); translate([-(bottom_x/1.95)+1.07,-2,(h/2.01)-0.48]) resize([1,0.5,0]) text("2 Kg"); translate([-(bottom_x/1.95)+1.07,-3,(h/2.01)-0.48]) resize([1,0.4,0]) text("70.5479 oz"); translate([-l/2,-L/2,-h/2]) polyhedron(points=Points, faces=Paths);     } ===== 2KG of gold!!!  that's impossible to collect it these days   -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: 2D, 3D OpenSCAD Problem

 Like it says, you're not allowed to mix 2D and 3D objects. circle( ) and text( ) yield 2D objects.  You need to linear_extrude( ) them to make them 3D.  (Or, since the linear extrusion of a circle is a cylinder, just use cylinder().) For simplicity, you might replace your text( ) calls with calls to a module that extrudes the text, like so: ```module text3(s) {     linear_extrude(height=0.1) text(s); } ``` You probably want to re-examine your Z placement of the various objects.  You have the bar itself starting at about -1.2, the circles at 0, and the text at 0.72.  The top of the bar is at about 1.2. Note that even this tiny file triggers this failure: ```circle(); sphere(); ``` _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: 2D, 3D OpenSCAD Problem

 In reply to this post by Higraphics I have not tried your code however it is clear the cause of the warnings. The primitive text() is a 2D object and polyhedron is a 3D object. You cannot mix them. You may however make the text() getting a third dimension using the linear_extrude() operator.The second warning was possibly raised because you tried to translate the 2D primitive text in Z direction. 2D objects live in the XY plane.A sábado, 26/10/2019, 02:28, Higraphics <[hidden email]> escreveu:Hello there, i want to create a golden bar using polygon but when i type F6, i see this error in console: WARNING: Mixing 2D and 3D objects is not supported. WARNING: Ignoring 3D child object for 2D operation that's my script that i'm using: /*  Size of 2KG of Gold Linget Fonte  10mm x 4.3mm X 2.41mm  Calculated from Density of gold = 19.30 g/cm3 at 20°C  30 => 4.3  100 => 10  30 h =>2.41  25 => 3.15  5 => 1.15  95 => 8.85 */ l=4.3; L=10; h=2.41; top_x= (l/2)-1; // top_x=1.15 bottom_x= l-top_x; // bottom_x=3.15 L_R_h= L-top_x; // L_R_h=8.85 Points=[[0,0,0],[l,0,0],[bottom_x,top_x,h],[top_x,top_x,h],[top_x,L_R_h,h],[0,L,0],[l,L,0],[bottom_x,L_R_h,h]]; Paths=[[0,1,3],[1,3,2],[0,5,3],[5,3,4],[5,6,7],[5,7,4],[6,1,2],[7,2,6],[2,3,7],[3,7,4],[0,1,5],[1,5,6]]; module Torn() {     difference(){ translate([-2,2.25,(h/2.01)-0.48]) resize([1.6,1.2,0]) circle(r=5, center=true, \$fn=250); translate([-2,2.25,(h/2.01)-0.48]) resize([1.4,1,0]) circle(r=2, center=true, \$fn=250);     } } translate([1.995,0,0]){ Torn(); } color( "Gold" ) { translate([-(bottom_x/1.95)+1.06,2,(h/2.01)-0.48]) resize([1,0.5,0]) text("Gold"); translate([-(bottom_x/1.95)+1.07,-2,(h/2.01)-0.48]) resize([1,0.5,0]) text("2 Kg"); translate([-(bottom_x/1.95)+1.07,-3,(h/2.01)-0.48]) resize([1,0.4,0]) text("70.5479 oz"); translate([-l/2,-L/2,-h/2]) polyhedron(points=Points, faces=Paths);     } ===== 2KG of gold!!!  that's impossible to collect it these days  -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: 2D, 3D OpenSCAD Problem

 In reply to this post by JordanBrown Thank You Mr Brown, i modify text to linear_extrude and i got nice text i color it in black: module text_w() {     color( "Black" ) { translate([-(bottom_x/1.95)+1.06,2,h/2]) resize([1,0.5,0])     linear_extrude(height=0.005) text("Gold"); translate([-(bottom_x/1.95)+1.07,-2,h/2]) resize([1,0.5,0])     linear_extrude(height=0.005) text("2 Kg"); translate([-(bottom_x/1.95)+1.07,-3,h/2]) resize([1,0.4,0])     linear_extrude(height=0.005) text("70.5479 oz"); }   but problem when i want to apply difference in the bar i got an object like that: i apply union() to my polyhedron and i got same result, union(){     translate([-l/2,-L/2,-h/2])     polyhedron(points=Points, faces=Paths);   } is they are any solution? -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: 2D, 3D OpenSCAD Problem

Open this post in threaded view
|

## Re: 2D, 3D OpenSCAD Problem

 // Size of 2KG of Gold Linget Fonte // 10mm x 4.3mm X 2.41mm // Calculated from Density of gold = 19.30 g/cm3 at 20°C // 30 => 4.3 // 100 => 10 // 30 h =>2.41 // 25 => 3.15 // 5 => 1.15 // 95 => 8.85 l=4.3; L=10; h=2.41; top_x= (l/2)-1; // top_x=1.15 bottom_x= l-top_x; // bottom_x=3.15 L_R_h= L-top_x; // L_R_h=8.85 Points=[[0,0,0],[l,0,0],[bottom_x,top_x,h],[top_x,top_x,h],[top_x,L_R_h,h],[0,L,0],[l,L,0],[bottom_x,L_R_h,h]]; Paths=[[0,1,3],[1,3,2],[0,5,3],[5,3,4],[5,6,7],[5,7,4],[6,1,2],[7,2,6],[2,3,7],[3,7,4],[0,1,5],[1,5,6]]; module text_w() {     color( "Black" ) { translate([-(bottom_x/1.95)+1.06,2,h/2]) resize([1,0.5,0])     linear_extrude(height=0.005) text("Gold"); translate([-(bottom_x/1.95)+1.07,-2,h/2]) resize([1,0.5,0])     linear_extrude(height=0.005) text("2 Kg"); translate([-(bottom_x/1.95)+1.07,-3,h/2]) resize([1,0.4,0])     linear_extrude(height=0.005) text("70.5479 oz"); }   } module Torn() {     difference(){     resize([1.6,1.2,0])     linear_extrude(height=0.005) circle(r=5, center=true, \$fn=250);     translate([0,0,-0.001])     resize([1.4,1,0])     linear_extrude(height=0.01) circle(r=2, center=true, \$fn=250);     }   } translate([0,2.25,h/1.99]){ Torn(); } module objet(){     union(){     translate([-l/2,-L/2,-h/2])     polyhedron(points=Points, faces=Paths);   } } // difference not working in polyhedron difference(){     objet();     text_w(); } -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
 Your immediate problem is that your polyhedron is malformed.  Several of the faces are wound counterclockwise, and that confuses OpenSCAD.  Use View/Thrown Together to see.  From the outside, you want to see all yellow. It's also more complex than it needs to be, because you've built it out of triangles and your bar is built out of four-edged faces. Here's a Paths list that works: ```Paths=[ [3,2,1,0], [0,5,4,3], [5,6,7,4], [6,1,2,7], [2,3,4,7], [0,1,6,5] ]; ``` Continuing... Cleaning up your indentation would make it easier to read. The union() in objet() isn't necessary.  It doesn't even do anything, since it only encloses one object (the translated polyhedron). The linear extrusion of a circle is a cylinder, so might as well use that directly. You seem to be needing a lot of arithmetic to compensate for the fact that you've translated the bar down to be centered on Z=0.  Leaving so its bottom is at Z=0 makes it simpler. The halign="center" option on the text makes positioning simpler.  (Here it's simpler to have the bar centered on X=0 and Y=0. Cutting \$fn down from 250 to 50 is almost imperceptible and speeds F6 rendering up from 17s to 11s on my system. text_w is used as a "negative" object, so doesn't really make sense to color. Assuming that you want the "Gold" centered in the circles, the text option valign=center helps, and then the text and the circle are positioned to the same place. Here's the result of that cleanup... ```// Size of 2KG of Gold Linget Fonte // 10mm x 4.3mm X 2.41mm // Calculated from Density of gold = 19.30 g/cm3 at 20°C // 30 => 4.3 // 100 => 10 // 30 h =>2.41 // 25 => 3.15 // 5 => 1.15 // 95 => 8.85 l=4.3; L=10; h=2.41; inset = 0.005; circle_h = 0.005; epsilon = 0.001; gold_y = 2.25; top_x= (l/2)-1; // top_x=1.15 bottom_x= l-top_x; // bottom_x=3.15 L_R_h= L-top_x; // L_R_h=8.85 Points=[[0,0,0],[l,0,0],[bottom_x,top_x,h],[top_x,top_x,h],[top_x,L_R_h,h],[0,L,0],[l,L,0],[bottom_x,L_R_h,h]]; Paths=[ [3,2,1,0], [0,5,4,3], [5,6,7,4], [6,1,2,7], [2,3,4,7], [0,1,6,5] ]; module text_w() { translate([0,gold_y,h-inset]) resize([1,0.5,0]) linear_extrude(height=inset+epsilon) text("Gold", halign="center", valign="center"); translate([0,-2,h-inset]) resize([1,0.5,0]) linear_extrude(height=inset+epsilon) text("2 Kg", halign="center"); translate([0,-3,h-inset]) resize([1,0.4,0]) linear_extrude(height=inset+epsilon) text("70.5479 oz", halign="center"); } module Torn() { difference(){ resize([1.6,1.2,0]) cylinder(h=circle_h, r=5, \$fn=50); translate([0,0,-epsilon]) resize([1.4,1,0]) cylinder(h=circle_h + 2*epsilon, r=2, \$fn=50); } } translate([0,gold_y,h]){ Torn(); } module objet(){ translate([-l/2,-L/2,0]) polyhedron(points=Points, faces=Paths); } difference(){ objet(); text_w(); } ``` _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org