DSchroer / dslcad

DSLCad is a programming language & interpreter for building 3D models.
https://dslcad.com
GNU Lesser General Public License v2.1
470 stars 14 forks source link

Allow object style properties to access computed values #12

Closed ephetic closed 1 year ago

ephetic commented 1 year ago

e.g.

var table = 
    cube(x=10, y=10, z=10) 
    ->shape translate(x=1, y=2, z=3);
var vase = 
    cylinder(radius=3, height=3) 
    ->shape translate(x=table.center.x, y=table.center.y, z=table.center.z + table.z/2);
DSchroer commented 1 year ago

Out of curiosity, what properties did you have in mind? Off the top of my head I can think of:

ephetic commented 1 year ago

Honestly, I'd only thought of center, as it is another way I could have come at the centering (#14) for relative boolean geometry, but perhaps transform and/or scale would also be good. I'm thinking that if we have property access, it makes it easy to define subordinate parts relative to a parent geometry (e.g. some sort of ->shape relative_to(parent=parent) helper based on being able to extract the parent properties).

DSchroer commented 1 year ago

Hey. Just a heads up that I am making some progress on this. Got a PR upstream to expose this stuff to the software and then once that is merged I can start to add the parameters.

https://github.com/bschwind/opencascade-rs/pull/20

DSchroer commented 1 year ago

Ive added the x.center property in the code. One thing I want to do is setup a x ->shape center() function. How would you use it? The options I see are

->shape center(x=true, y=true)
->shape center(no_z=true)

I think it makes sense to have an axis control but I don't have a good signature yet.

ephetic commented 1 year ago

I'd think center(x=true, y=true, z=true) where they all default to true.

On Thu, Mar 2, 2023, 3:53 PM Dominick @.***> wrote:

Ive added the x.center property in the code. One thing I want to do is setup a x ->shape center() function. How would you use it? The options I see are

->shape center(x=true, y=true) ->shape center(no_z=true)

I think it makes sense to have an axis control but I don't have a good signature yet.

— Reply to this email directly, view it on GitHub https://github.com/DSchroer/dslcad/issues/12#issuecomment-1452740961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ43TF6RJOXO25B7WSWGFDW2EXGBANCNFSM6AAAAAAU4O6CU4 . You are receiving this because you authored the thread.Message ID: @.***>

DSchroer commented 1 year ago

Ive though of that but it really doesn't make much sense. Boolean arguments are inherently false by default. One thing I thought of was maybe having a shorthand for boolean arguments so you could do this:

center(x,y)

which is the same as :

center(x=true, y=true)
center(x=true, y=true, z=false)

Then having the unspecified value default to false still works and it would center x and y without z. However it makes center() kind of useless.

ephetic commented 1 year ago

I thought the default was whatever you set it as in the file.ds var.

On Thu, Mar 2, 2023, 5:12 PM Dominick @.***> wrote:

Ive though of that but it really doesn't make much sense. Boolean arguments are inherently false by default. One thing I thought of was maybe having a shorthand for boolean arguments so you could do this:

center(x,y)

which is the same as :

center(x=true, y=true)

Then having the unspecified value default to false still works and it would center x and y without z. However it makes center() kind of useless.

— Reply to this email directly, view it on GitHub https://github.com/DSchroer/dslcad/issues/12#issuecomment-1452793330, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ43TGCCUMRVQBSAJGSYIDW2FAQRANCNFSM6AAAAAAU4O6CU4 . You are receiving this because you authored the thread.Message ID: @.***>

DSchroer commented 1 year ago

Fair enough. Ive added:

- `center(shape=shape, x=[bool], y=[bool], z=[bool])` center a shape

The x,y,z arguments default to true. Should be available in pre-releases after 0.0.2.pre.4

DSchroer commented 1 year ago

Completed with https://github.com/DSchroer/dslcad/releases/tag/v0.0.2-pre.4