Skip to content

apply parameter-less transforms directly#63

Closed
scifuentes wants to merge 1 commit intoSolidCode:masterfrom
scifuentes:TransformationConstructors
Closed

apply parameter-less transforms directly#63
scifuentes wants to merge 1 commit intoSolidCode:masterfrom
scifuentes:TransformationConstructors

Conversation

@scifuentes
Copy link
Copy Markdown
Contributor

Syntax sugar to allow the application of parameter-less transformations as functions i.o. objects.
Existing OpenScad-esque syntax not affected

e.g.: difference(cube(1), sphere(1)) vs difference()(cube(1). sphere(1))

@guoqiao
Copy link
Copy Markdown

guoqiao commented Sep 7, 2020

Something I was thinking:

# python set operations 
cube(1) | sphere(1)  # union,  `+` seems also make sense
cube(1) - sphere(1)  # difference, already have this
cube(1) & sphere(1) # intersection, `*` doesn't make sense for this

cube(1).union(sphere(1))
cube(1).difference(sphere(1))
cube(1).intersection(sphere(1))

cube(1).translate(1,1,1)
cube(1).translate_x(-1)
cube(1).translate_y(2)

cube(1).scale(1.1, 0, 0)
cube(1).rotate(90, 0, 0)

cube(1).color('red')
cube(1).red()

cube(1).mirror([1,0,0])
cube(1).mirror_x(1)

# support chain operations
(cube(1) | sphere(1) & cylinder(2) - cube(2)).translate_z(2).rotate_z(90).red().mirror_y(1).render()

@ilyakh
Copy link
Copy Markdown

ilyakh commented Sep 7, 2020

I have a similar design implemented in solipython-elements repo, in case you need inspiration for the API.

@etjones etjones closed this Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants