projection

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

projection

fractorr
I was wanting to use the projection function conditionally in a module but I
get an error, is there a way to do this? This is the code I have that gets
an error

module draw_circle(param1, param2, param3, flat="no") {
        if (flat == "yes") {
                projection()
        }
       
        draw shape code goes here
}



If I take out the if statement like so it does what I want


module draw_circle(param1, param2, param3, flat="no") {
        projection()
       
        draw shape code goes here
}





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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: projection

nophead
This works:

module draw_circle(param1, param2, param3, flat=false) {
        module draw_shape() {
                sphere(param1);
        }
       
        if (flat) {
            projection()
                draw_shape();
        }
        else
            draw_shape();
}


On 2 May 2018 at 18:19, fractorr <[hidden email]> wrote:
I was wanting to use the projection function conditionally in a module but I
get an error, is there a way to do this? This is the code I have that gets
an error

module draw_circle(param1, param2, param3, flat="no") {
        if (flat == "yes") {
                projection()
        }

        draw shape code goes here
}



If I take out the if statement like so it does what I want


module draw_circle(param1, param2, param3, flat="no") {
        projection()

        draw shape code goes here
}





--
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
Reply | Threaded
Open this post in threaded view
|

Re: projection

fractorr
Great, thanks.  That will require a little re-orgranization of my code
but it will be worth it to have the ability to do.


On 5/2/18, nop head <[hidden email]> wrote:

> This works:
>
> module draw_circle(param1, param2, param3, flat=false) {
>         module draw_shape() {
>                 sphere(param1);
>         }
>
>         if (flat) {
>             projection()
>                 draw_shape();
>         }
>         else
>             draw_shape();
> }
>
>
> On 2 May 2018 at 18:19, fractorr <[hidden email]> wrote:
>
>> I was wanting to use the projection function conditionally in a module
>> but
>> I
>> get an error, is there a way to do this? This is the code I have that
>> gets
>> an error
>>
>> module draw_circle(param1, param2, param3, flat="no") {
>>         if (flat == "yes") {
>>                 projection()
>>         }
>>
>>         draw shape code goes here
>> }
>>
>>
>>
>> If I take out the if statement like so it does what I want
>>
>>
>> module draw_circle(param1, param2, param3, flat="no") {
>>         projection()
>>
>>         draw shape code goes here
>> }
>>
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> [hidden email]
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>


--
Trevor Orr
FractOrr Computer Services
fractorr.com
541-490-5697

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: projection

JordanBrown
Or something like this should work:

module conditional_project(flat) {
    if (flat == "yes") {
        projection() children();
    } else {
        children();
    }
}

module draw_circle(param1, param2, param3, flat="no") {
    conditional_project(flat) {
	draw shape code goes here
    }
}


But I would use a boolean rather than a string for "flat".



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org