OpenJSCAD.org
OpenJSCAD.org copied to clipboard
connectors do not work, not very compatible with V2
Expected Behavior
Connectors store additional vector metadata in a way that will be very fragile in V2, currently destroyed by any transform, colorize, etc method, even if they did get stored properly in the first place.
Recommend we remove them from the public api, and reconsider if they are worth putting back in at some point.
I like the connectors as a concept, but have not used them in V1 ... if they are problematic right now. It can be worth it to remove them temporarily, to be done "properly" later on.
FYI, V1 connectors were added to primitives. For example, the eight sides of a cube each had a connector. However, designs don’t connect cubes to cylinders, etc. And, using the connectors required knowing the exact connectors being used to connect geometry, which was also almost impossible. And connectors were lost if any boolean operations were performed. Etc. Etc. Etc.
So, yeah. I support the retirement of connectors.
I think these could be used inside other functions like aligning the faces of two shapes and connecting those shapes together.
As someone who uses connecters a good bit, I hope they stay in. For me, connectors are an indispensable part of aligning and positioning complex objects.
ok, excellent to know, @johnwebbcole . We should have a discussion on how you use them, perhaps some example projects, if you'd be willing to share. For example, do you always use ones you manually create, or do you use the ones that are create for cubes?
If they are useful, let's aim to keep them. If they are fundamentally broken currently, we can take them out temporarily.
@SimonClark here's an example: https://gitlab.com/johnwebbcole/window-motor
I use both my own and the ones on the primitives (mostly on cylinders).
J
@SimonClark here's an example: https://gitlab.com/johnwebbcole/window-motor
I use both my own and the ones on the primitives (mostly on cylinders).
@johnwebbcole You are a rare bird. This is the first design that I have seen using connectors. I’ll research a little deeper now.
Having said that, I foresee some major work to make your designs work with V2. Have you started converting your utilities?
There’s an object wrapper for V2 already, and you are welcome to take that as a starting place.
I build and test my utils against v2 and use a compatibility wrapper to get them to work with v1 scripts already :-)
I use connectors for unfolding (I already have another method) and to be able to center something inside a 3d polygon (I have no other method for the moment), essentially to intrude faces or put text on them.
for(i=0; i < nb; i++){ p = CSG.fromPolygons([B[i]]); t = p.getTransformationAndInverseTransformationToFlatLying(); //c = centre(p.polygons); c = {x:0, y:0}; txt = text(c.x, c.y, i.toString()); R.push(color("black", txt.transform(t[1]))); console.log(i+"/"+nb); }
(getTransformationAndInverseTransformationToFlatLying() uses connectors)
or directly ` const v1 = p.polygons[0].vertices[0].pos; const v2 = p.polygons[0].vertices[1].pos; const v3 = p.polygons[0].vertices[2].pos;
const center= v1.plus(v2.minus(v1).times(1/2)).plus(v3.minus(v1.plus(v2.minus(v1).times(1/2))).times(1/3));
const tC = new CSG.Connector(v1, v2.minus(v1), p.polygons[0].plane.normal);
const z0xC = new CSG.Connector([0, 0, 0], [0,v2.minus(v1).length(), 0], [0, 0, 1]);
const tf = z0xC.getTransformationTo(tC, false, 0);
const tb = tC.getTransformationTo(z0xC, false, 0);
txt0 = text(0,0, i.toString());
const xy = center.transform(tb);
b = txt0.getBounds();
dxy = xy.minus(b[1].minus(b[0]).times(1/2));
`
FYI. The connectors has been temporarily disabled in V2.
Let's start some discussions about use cases, and then work on some changes to bring connectors (or something else) back into V2.
I use both my own and the ones on the primitives (mostly on cylinders).
@johnwebbcole for these connectors, i have a few questions.
- does your design expect a certain order to the connectors available? how does the design know which connector to use?
- does your design expect connectors to 'transform' whenever the shape transforms?
- connectors were only created for 3D primitives. would connectors on 2D primitives be useful?
Connectors are named so you need to know the names for the object you are connecting to/from.
Yes, they should transform with the rest of the shape (like any point on the properties parameter).
And yes, 2d connectors would be very helpful.
Just had a stupid thought...
Currently, connectors are:
- created from point and axis
- added to the 'properties' of a geometry by 'name'
- the 'properties' are transformed when a geometry is transformed
- designs know connectors by 'name', e.g. geometry.properties.center
- designs connect geometries together using known connectors
- a new geometry is created that aligns to the connectors
So, what if this is inverted, like this:
- created from point and axis
- geometries can be added to the connector
- geometries are transformed when the connector is transformed
- designs manage connectors
- connectors can be connected together
- new geometries are created that align to the connectors
The addConnector helper that I use helps with naming and construction. https://gitlab.com/johnwebbcole/window-motor/-/blob/master/dist/window-motor.jscad#L733
Here's an example in use https://gitlab.com/johnwebbcole/window-motor/-/blob/master/dist/window-motor.jscad#L733
After talking to myself in the comments here, I have deleted them, as I have come up with a proposal that is more in line with how jscad scripts work now. I am moving it all here #858