Automating positioning of parts in an assembly

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Automating positioning of parts in an assembly

jgalak
I'm trying to figure out if there's any way to "automate" the computation of a rotation and translation of a part to fit into an assembly. 

For example, consider a clothespin, the kind with two pivoting arms and a spring.  Let's say I have designed the two arm object.. Further, suppose I want to vary the distance between the pivot point and the outer surface of the arms, but I want the "business end" to always be touching, as if the clothespin is closed by the spring. 

What I'd like is to specify in some way that the two arms must always touch at the "business end" and at the pivot point, and have OpenSCAD somehow figure out how to rotate and position the arms accordingly.  I've found an "attachment" library that seems to do this, but it appears abandoned and poorly documented, at least in English.  (yes, I've reached out to the author, with no success).

Obviously I can do this by writing some trig functions, but I'd really rather not have to do that.  Is there another solution to this?

--
Juliean Galak
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

lostapathy
The key for this problem is to model the parts in an orientation that matches your frame of reference for the desired motion.  (Or move them into such an orientation before you rotate them).

i.e., model your clothespin arm such that the point you want to touch to always be on the y-axis, then when you rotate the part about the y-axis, it'll always be touching there and you avoid the complex math for rotating it.  Then translate/rotate the whole clothespin assembly to whatever point in space you need it at.

The same principal applies to mating surfaces of parts that are meant to be assembled.  If, for example, you're modeling a stepper motor, it's very easy to place it in another assembly if you place the mounting face on the X/Y plane and run the stepper shaft on the Z-axis.  If you model the entire stepper in the x/y/z-positive quadrant, it requires a lot of thinking to place it correctly in another model.  Even more so if you change the stepper to a different size later on and the key features move relative to the origin.

This general pattern is, IMO, critical for making good parametric models in openscad and keeping the complexity to a manageable level.

Joe


On 2/4/19 12:08 PM, Juliean Galak wrote:
I'm trying to figure out if there's any way to "automate" the computation of a rotation and translation of a part to fit into an assembly. 

For example, consider a clothespin, the kind with two pivoting arms and a spring.  Let's say I have designed the two arm object.. Further, suppose I want to vary the distance between the pivot point and the outer surface of the arms, but I want the "business end" to always be touching, as if the clothespin is closed by the spring. 

What I'd like is to specify in some way that the two arms must always touch at the "business end" and at the pivot point, and have OpenSCAD somehow figure out how to rotate and position the arms accordingly.  I've found an "attachment" library that seems to do this, but it appears abandoned and poorly documented, at least in English.  (yes, I've reached out to the author, with no success).

Obviously I can do this by writing some trig functions, but I'd really rather not have to do that.  Is there another solution to this?

--
Juliean Galak
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

jgalak
But how do you deal with two points of attachment?  In my example, sure, it makes sense to put the contact point of the jaws at the origin, oriented in a normal way.  But when changing the pivot distance, you'd still need to do trig to figure out how much to rotate and translate each arm, depending on said distance.  Putting the contact point at the origin simplifies that trig, but doesn't eliminate it.

Also, can you rotate around anything other than the origin?  It'd be nice to be able to specify that this part should rotate around this point on the part, regardless of where the part is.  I don't recall any way to specify the point of rotation, which would also simplify the above.  I guess you could translate, rotate, and then translate back, but that's kind of cludgy.

On Mon, Feb 4, 2019 at 1:22 PM Joe Francis <[hidden email]> wrote:
The key for this problem is to model the parts in an orientation that matches your frame of reference for the desired motion.  (Or move them into such an orientation before you rotate them).

i.e., model your clothespin arm such that the point you want to touch to always be on the y-axis, then when you rotate the part about the y-axis, it'll always be touching there and you avoid the complex math for rotating it.  Then translate/rotate the whole clothespin assembly to whatever point in space you need it at.

The same principal applies to mating surfaces of parts that are meant to be assembled.  If, for example, you're modeling a stepper motor, it's very easy to place it in another assembly if you place the mounting face on the X/Y plane and run the stepper shaft on the Z-axis.  If you model the entire stepper in the x/y/z-positive quadrant, it requires a lot of thinking to place it correctly in another model.  Even more so if you change the stepper to a different size later on and the key features move relative to the origin.

This general pattern is, IMO, critical for making good parametric models in openscad and keeping the complexity to a manageable level.

Joe


On 2/4/19 12:08 PM, Juliean Galak wrote:
I'm trying to figure out if there's any way to "automate" the computation of a rotation and translation of a part to fit into an assembly. 

For example, consider a clothespin, the kind with two pivoting arms and a spring.  Let's say I have designed the two arm object.. Further, suppose I want to vary the distance between the pivot point and the outer surface of the arms, but I want the "business end" to always be touching, as if the clothespin is closed by the spring. 

What I'd like is to specify in some way that the two arms must always touch at the "business end" and at the pivot point, and have OpenSCAD somehow figure out how to rotate and position the arms accordingly.  I've found an "attachment" library that seems to do this, but it appears abandoned and poorly documented, at least in English.  (yes, I've reached out to the author, with no success).

Obviously I can do this by writing some trig functions, but I'd really rather not have to do that.  Is there another solution to this?

--
Juliean Galak
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
Juliean Galak
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

jgalak
For example, consider this model:


I want to play around with pviotOffset, and have done so using a trig function.  Relatively simple, here.  But I'd love to not have to dust off my trig, especially in more complicated cases.  That attachment library I found purports to do just this, but I've not figured out how to use it...

I guess what I'm really looking for is some sort of equivalent to the "snap to" functionality found in some other modeling packages, where I could designate sets of points (or other items) and maintain their relationship.

Maybe it just doesn't exist in OpenSCAD.  If so, so be it - I can make do.  But it'd be nice :) .  Especially when I am working on more complex assemblies that have more complex interrelationships.

Thanks,
Juliean.



On Mon, Feb 4, 2019 at 1:35 PM Juliean Galak <[hidden email]> wrote:
But how do you deal with two points of attachment?  In my example, sure, it makes sense to put the contact point of the jaws at the origin, oriented in a normal way.  But when changing the pivot distance, you'd still need to do trig to figure out how much to rotate and translate each arm, depending on said distance.  Putting the contact point at the origin simplifies that trig, but doesn't eliminate it.

Also, can you rotate around anything other than the origin?  It'd be nice to be able to specify that this part should rotate around this point on the part, regardless of where the part is.  I don't recall any way to specify the point of rotation, which would also simplify the above.  I guess you could translate, rotate, and then translate back, but that's kind of cludgy.

On Mon, Feb 4, 2019 at 1:22 PM Joe Francis <[hidden email]> wrote:
The key for this problem is to model the parts in an orientation that matches your frame of reference for the desired motion.  (Or move them into such an orientation before you rotate them).

i.e., model your clothespin arm such that the point you want to touch to always be on the y-axis, then when you rotate the part about the y-axis, it'll always be touching there and you avoid the complex math for rotating it.  Then translate/rotate the whole clothespin assembly to whatever point in space you need it at.

The same principal applies to mating surfaces of parts that are meant to be assembled.  If, for example, you're modeling a stepper motor, it's very easy to place it in another assembly if you place the mounting face on the X/Y plane and run the stepper shaft on the Z-axis.  If you model the entire stepper in the x/y/z-positive quadrant, it requires a lot of thinking to place it correctly in another model.  Even more so if you change the stepper to a different size later on and the key features move relative to the origin.

This general pattern is, IMO, critical for making good parametric models in openscad and keeping the complexity to a manageable level.

Joe


On 2/4/19 12:08 PM, Juliean Galak wrote:
I'm trying to figure out if there's any way to "automate" the computation of a rotation and translation of a part to fit into an assembly. 

For example, consider a clothespin, the kind with two pivoting arms and a spring.  Let's say I have designed the two arm object.. Further, suppose I want to vary the distance between the pivot point and the outer surface of the arms, but I want the "business end" to always be touching, as if the clothespin is closed by the spring. 

What I'd like is to specify in some way that the two arms must always touch at the "business end" and at the pivot point, and have OpenSCAD somehow figure out how to rotate and position the arms accordingly.  I've found an "attachment" library that seems to do this, but it appears abandoned and poorly documented, at least in English.  (yes, I've reached out to the author, with no success).

Obviously I can do this by writing some trig functions, but I'd really rather not have to do that.  Is there another solution to this?

--
Juliean Galak
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
Juliean Galak
[hidden email]


--
Juliean Galak
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

JordanBrown
In reply to this post by lostapathy
On 2/4/2019 10:22 AM, Joe Francis wrote:
The same principal applies to mating surfaces of parts that are meant to be assembled.  If, for example, you're modeling a stepper motor, it's very easy to place it in another assembly if you place the mounting face on the X/Y plane and run the stepper shaft on the Z-axis.  If you model the entire stepper in the x/y/z-positive quadrant, it requires a lot of thinking to place it correctly in another model.  Even more so if you change the stepper to a different size later on and the key features move relative to the origin.


When I'm starting with a module, the very first question (documented in the comments) is what the origin and rotations are for that module.

For the stepper motor example, I would say that the origin is at the mounting face, centered on the shaft, with the shaft along the Z axis.  (Rotation around the Z axis left to author's discretion.)

Mostly I design model furniture for my model house, and so usually the base of the model is at Z=0.  X=0 is usually the left-right center of the model so that symmetry is easy.  Y=0 is usually the "front" of the model, but (for instance) knobs usually extend into negative Y.  Rotation-wise, "up" on the model is almost always positive Z, left is usually negative X, right is positive X, the front is toward negative Y, and the back is toward positive Y.

If the model is to be printed in one shot, that's the end; I rotate to the desired print orientation in the slicer.  If it's to be printed in multiple pieces and then assembled, as I noted in another thread I've been setting up an animation between the two positions.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

nophead
I often use $preview so that F5 shows the assembled item and F6 produces just the printed parts arranged for printing.

On Tue, 5 Feb 2019 at 01:38, Jordan Brown <[hidden email]> wrote:
On 2/4/2019 10:22 AM, Joe Francis wrote:
The same principal applies to mating surfaces of parts that are meant to be assembled.  If, for example, you're modeling a stepper motor, it's very easy to place it in another assembly if you place the mounting face on the X/Y plane and run the stepper shaft on the Z-axis.  If you model the entire stepper in the x/y/z-positive quadrant, it requires a lot of thinking to place it correctly in another model.  Even more so if you change the stepper to a different size later on and the key features move relative to the origin.


When I'm starting with a module, the very first question (documented in the comments) is what the origin and rotations are for that module.

For the stepper motor example, I would say that the origin is at the mounting face, centered on the shaft, with the shaft along the Z axis.  (Rotation around the Z axis left to author's discretion.)

Mostly I design model furniture for my model house, and so usually the base of the model is at Z=0.  X=0 is usually the left-right center of the model so that symmetry is easy.  Y=0 is usually the "front" of the model, but (for instance) knobs usually extend into negative Y.  Rotation-wise, "up" on the model is almost always positive Z, left is usually negative X, right is positive X, the front is toward negative Y, and the back is toward positive Y.

If the model is to be printed in one shot, that's the end; I rotate to the desired print orientation in the slicer.  If it's to be printed in multiple pieces and then assembled, as I noted in another thread I've been setting up an animation between the two positions.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

oystein.krog
I find that the code in attach.scad works well, the key is really the orient operator. Simply define the connection points on each part (and the direction), and you can attach them together.

On Tue, Feb 5, 2019 at 10:53 AM nop head <[hidden email]> wrote:
I often use $preview so that F5 shows the assembled item and F6 produces just the printed parts arranged for printing.

On Tue, 5 Feb 2019 at 01:38, Jordan Brown <[hidden email]> wrote:
On 2/4/2019 10:22 AM, Joe Francis wrote:
The same principal applies to mating surfaces of parts that are meant to be assembled.  If, for example, you're modeling a stepper motor, it's very easy to place it in another assembly if you place the mounting face on the X/Y plane and run the stepper shaft on the Z-axis.  If you model the entire stepper in the x/y/z-positive quadrant, it requires a lot of thinking to place it correctly in another model.  Even more so if you change the stepper to a different size later on and the key features move relative to the origin.


When I'm starting with a module, the very first question (documented in the comments) is what the origin and rotations are for that module.

For the stepper motor example, I would say that the origin is at the mounting face, centered on the shaft, with the shaft along the Z axis.  (Rotation around the Z axis left to author's discretion.)

Mostly I design model furniture for my model house, and so usually the base of the model is at Z=0.  X=0 is usually the left-right center of the model so that symmetry is easy.  Y=0 is usually the "front" of the model, but (for instance) knobs usually extend into negative Y.  Rotation-wise, "up" on the model is almost always positive Z, left is usually negative X, right is positive X, the front is toward negative Y, and the back is toward positive Y.

If the model is to be printed in one shot, that's the end; I rotate to the desired print orientation in the slicer.  If it's to be printed in multiple pieces and then assembled, as I noted in another thread I've been setting up an animation between the two positions.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Automating positioning of parts in an assembly

lostapathy
In reply to this post by jgalak
On 2/4/19 12:35 PM, Juliean Galak wrote:
But how do you deal with two points of attachment?  In my example, sure, it makes sense to put the contact point of the jaws at the origin, oriented in a normal way.  But when changing the pivot distance, you'd still need to do trig to figure out how much to rotate and translate each arm, depending on said distance.  Putting the contact point at the origin simplifies that trig, but doesn't eliminate it.
I don't think there is a way to totally eliminate the need to solve that yourself in OpenSCAD.  The strategy I outlined is just meant to simplify it to solving for that one angle, rather than solving for 2 at a time. 

From my (admittedly limited) understanding, attach.scad lets you chain together a set of attached parts based on a point of attachment, but it doesn't let you say "I want my part to touch two other surfaces, rotate it to match".  I think the inability to do that is a fundamental limitation of a CAD kernel like OpenSCAD that's built on constructive geometry - vs a system like Fusion360 that can also operate in terms of geometric constraints.



Also, can you rotate around anything other than the origin?  It'd be nice to be able to specify that this part should rotate around this point on the part, regardless of where the part is.  I don't recall any way to specify the point of rotation, which would also simplify the above.  I guess you could translate, rotate, and then translate back, but that's kind of cludgy.

That kind of operation is ripe for wrapping in a simple module to do what you need.  Something like:

module rotate_around(angle, point) {
  translate(-point)
    rotate(angle)
      translate(point)
        children();
}

rotate_around([0,45,0], [10,0,10]) {
  cube(5);
}

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org