discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Optionally Applying Modifier Characters

LM
Leonard Martin Struttmann
Sun, Nov 17, 2024 3:47 PM

Is there an easy way to optionally apply Modifier Characters (#%, etc) to a
subtree based upon the value of $preview?

I'd like to apply % to several objects in my model, but only when I am
rendering, not during preview.

Thanks!

Len

Is there an easy way to optionally apply Modifier Characters (#%, etc) to a subtree based upon the value of $preview? I'd like to apply % to several objects in my model, but only when I am rendering, not during preview. Thanks! Len
TP
Torsten Paul
Sun, Nov 17, 2024 3:57 PM

On 17.11.24 16:47, Leonard Martin Struttmann via Discuss wrote:

Is there an easy way to optionally apply Modifier Characters (#%, etc)
to a subtree based upon the value of $preview?

I'd like to apply % to several objects in my model, but only when I am
rendering, not during preview.

Both # and % are already sensitive to the preview/render mode.

Preview:

highlight the marked subtree in transparent red

% show subtree as transparent separate objects

Render

no effect at all

% subtree is completely removed from render process

Using % only in render mode is useless as that has the same
effect as not writing that subtree at all.

This feels like the thing you want to achieve is a bit different
from the question you asked. Maybe just describe the effect you
want to see in both modes.

ciao,
Torsten.

On 17.11.24 16:47, Leonard Martin Struttmann via Discuss wrote: > Is there an easy way to optionally apply Modifier Characters (#%, etc) > to a subtree based upon the value of $preview? > > I'd like to apply % to several objects in my model, but only when I am > rendering, not during preview. Both # and % are already sensitive to the preview/render mode. Preview: # highlight the marked subtree in transparent red % show subtree as transparent separate objects Render # no effect at all % subtree is completely removed from render process Using % *only* in render mode is useless as that has the same effect as not writing that subtree at all. This feels like the thing you want to achieve is a bit different from the question you asked. Maybe just describe the effect you want to see in both modes. ciao, Torsten.
LM
Leonard Martin Struttmann
Sun, Nov 17, 2024 4:15 PM

Yeak, I really didn't think that through did I?

I'm building a box for an electronics project.  I've got a bunch of PCBs
and other vitamins that get translated, rotated, etc. I want to see these
fully, colored, in preview.  But I don't want them to be part of the
render.

Do I need to put each of these in an if block:

if ($preview)
{
translate(...)
rotate(...)
PCB();
}

,,,or is there some clever way to accomplish this?
Thanks!

Len

On Sun, Nov 17, 2024 at 9:57 AM Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:

On 17.11.24 16:47, Leonard Martin Struttmann via Discuss wrote:

Is there an easy way to optionally apply Modifier Characters (#%, etc)
to a subtree based upon the value of $preview?

I'd like to apply % to several objects in my model, but only when I am
rendering, not during preview.

Both # and % are already sensitive to the preview/render mode.

Preview:

highlight the marked subtree in transparent red

% show subtree as transparent separate objects

Render

no effect at all

% subtree is completely removed from render process

Using % only in render mode is useless as that has the same
effect as not writing that subtree at all.

This feels like the thing you want to achieve is a bit different
from the question you asked. Maybe just describe the effect you
want to see in both modes.

ciao,
Torsten.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Yeak, I really didn't think that through did I? I'm building a box for an electronics project. I've got a bunch of PCBs and other vitamins that get translated, rotated, etc. I want to see these fully, colored, in preview. But I don't want them to be part of the render. Do I need to put each of these in an if block: if ($preview) { translate(...) rotate(...) PCB(); } ,,,or is there some clever way to accomplish this? Thanks! Len On Sun, Nov 17, 2024 at 9:57 AM Torsten Paul via Discuss < discuss@lists.openscad.org> wrote: > On 17.11.24 16:47, Leonard Martin Struttmann via Discuss wrote: > > Is there an easy way to optionally apply Modifier Characters (#%, etc) > > to a subtree based upon the value of $preview? > > > > I'd like to apply % to several objects in my model, but only when I am > > rendering, not during preview. > > Both # and % are already sensitive to the preview/render mode. > > Preview: > # highlight the marked subtree in transparent red > % show subtree as transparent separate objects > > Render > # no effect at all > % subtree is completely removed from render process > > Using % *only* in render mode is useless as that has the same > effect as not writing that subtree at all. > > This feels like the thing you want to achieve is a bit different > from the question you asked. Maybe just describe the effect you > want to see in both modes. > > ciao, > Torsten. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
TP
Torsten Paul
Sun, Nov 17, 2024 4:25 PM

On 17.11.24 17:15, Leonard Martin Struttmann wrote:

I'm building a box for an electronics project.  I've got a bunch of PCBs
and other vitamins that get translated, rotated, etc. I want to see
these fully, colored, in preview.   But I don't want them to be part of
the render.

Right, so pretty much like what I'm printing right now:
https://imgur.com/a/TMMDD0U

I'm not seeing anything wrong with just using $preview but I'm
doing that inside the module defining the preview display with
an optional alpha parameter in case I want it transparent. In
the main/assembly view I just use esp32s3_zero() without any
additional modifier needed to make it disappear in render.

module esp32s3_zero(alpha = 1) {
if ($preview) {
w2  = esp32s3_width / 2;
color("green", alpha = alpha)
translate([0, -w2, 0])
cube([esp32s3_length, esp32s3_width, esp32s3_thickness]);
...
}
}

ciao,
Torsten.

On 17.11.24 17:15, Leonard Martin Struttmann wrote: > I'm building a box for an electronics project.  I've got a bunch of PCBs > and other vitamins that get translated, rotated, etc. I want to see > these fully, colored, in preview.   But I don't want them to be part of > the render. Right, so pretty much like what I'm printing right now: https://imgur.com/a/TMMDD0U I'm not seeing anything wrong with just using $preview but I'm doing that inside the module defining the preview display with an optional alpha parameter in case I want it transparent. In the main/assembly view I just use esp32s3_zero() without any additional modifier needed to make it disappear in render. module esp32s3_zero(alpha = 1) { if ($preview) { w2 = esp32s3_width / 2; color("green", alpha = alpha) translate([0, -w2, 0]) cube([esp32s3_length, esp32s3_width, esp32s3_thickness]); ... } } ciao, Torsten.
JB
Jordan Brown
Sun, Nov 17, 2024 4:35 PM

Is there an easy way to optionally apply Modifier Characters (#%, etc) to a subtree based upon the value of $preview?

Write a module that applies the modifier to its children, or doesn’t.

module percentIf(flag) {
If (flag) {
%children();
} else {
children();
}
}

percentIf($preview) cube();

> Is there an easy way to optionally apply Modifier Characters (#%, etc) to a subtree based upon the value of $preview? Write a module that applies the modifier to its children, or doesn’t. module percentIf(flag) { If (flag) { %children(); } else { children(); } } percentIf($preview) cube();
JB
Jordan Brown
Sun, Nov 17, 2024 4:38 PM
 If (flag) {

I’m typing this on my iPad and didn’t notice the automatically uppercased I.  It should be lower case, of course.

> If (flag) { I’m typing this on my iPad and didn’t notice the automatically uppercased I. It should be lower case, of course.
LM
Leonard Martin Struttmann
Sun, Nov 17, 2024 5:13 PM

Thanks everyone!  Just the tips that I needed. Len

On Sun, Nov 17, 2024 at 10:39 AM Jordan Brown openscad@jordan.maileater.net
wrote:

 If (flag) {

I’m typing this on my iPad and didn’t notice the automatically uppercased
I.  It should be lower case, of course.

Thanks everyone! Just the tips that I needed. Len On Sun, Nov 17, 2024 at 10:39 AM Jordan Brown <openscad@jordan.maileater.net> wrote: > > > If (flag) { > > I’m typing this on my iPad and didn’t notice the automatically uppercased > I. It should be lower case, of course. >