Skip to content

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

Open
@taliesin

Description

@taliesin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions