Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtle difference between solidpython object and bos2l object with left(), right(), back(), forward() #54

Open
taliesin opened this issue Dec 14, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@taliesin
Copy link

I've got a python function, that

def distributed4x(something, cw, cd):
    "create 4 incarnation of something cw and cd apart"
    return something.left(cw/2).forward(cd/2) + something.right(cw/2).forward(cd/2) + \
        something.left(cw/2).back(cd/2) + something.right(cw/2).back(cd/2) 

which produces the expected results when used with cylinder.

cph = cylinder(h=100, d=8, center=True)
cp = distributed4x(cph, 200, 300).color('green')

but not if 'something' is a bosl object like

import import solid2.extensions.bosl2 as b2

cph = b2.cylinder(h=100, d=8, center=True)
cp = distributed4x(cph, 200, 300).color('green')

It's because it's translated differently, for the cylinder example it becomes

	color(alpha = 1.0, c = "green") {
		union() {
			translate(v = [0, 150.0, 0]) {
				translate(v = [-100.0, 0, 0]) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
			translate(v = [0, 150.0, 0]) {
				translate(v = [100.0, 0, 0]) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
			translate(v = [0, -150.0, 0]) {
				translate(v = [-100.0, 0, 0]) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
			translate(v = [0, -150.0, 0]) {
				translate(v = [100.0, 0, 0]) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
		}
	}

for the b2.cylinder it is:

     color(alpha = 1.0, c = "green") {
		union() {
			translate(v = [0, 150.0, 0]) {
				left(x = 100.0) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
			translate(v = [0, 150.0, 0]) {
				right(x = 100.0) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
			back(y = 150.0) {
				left(x = 100.0) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
			back(y = 150.0) {
				right(x = 100.0) {
					cylinder(center = true, d = 8, h = 100);
				}
			}
		}
	}

NOTE: I'm not much of an OpenSCAD programmer, so I might be missing something obvious.

@jeff-dh
Copy link
Owner

jeff-dh commented Dec 16, 2023

Hmmmm... sh**......

The reason is that bosl2 brings it's own back, forward, left,..... commands and SolidPython (without bosl2) brings its versions (since OpenSCAD itself does not have them). The one (back and forward) defined in SolidPython (which are inherited from SolidPython"v1") are defined the other way around as the bosl2 ones.

I think we need to changed it, but this will cause another major backwards compatible breaking change......

I'll think about it for a couple of days, but I don't see any other way than a backward compatible breaking change.

Thanks a lot for finding this!

@jeff-dh
Copy link
Owner

jeff-dh commented Dec 16, 2023

Btw: Take a look at the distributors from bosl2, grid_copies do exactly what you want:

https://github.com/BelfrySCAD/BOSL2/wiki/distributors.scad#functionmodule-grid_copies

grid_copies

@taliesin
Copy link
Author

BOSL2 seems to be twisting your nerves quite a bit.

Thanks for the grid_copies() hint, thought there might be a BOSL way, but it was just too easy doing it in Python (which is closer to my base :-) )

@jeff-dh
Copy link
Owner

jeff-dh commented Dec 16, 2023 via email

@jeff-dh
Copy link
Owner

jeff-dh commented Dec 16, 2023 via email

@jeff-dh jeff-dh added the bug Something isn't working label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants