# Automating positioning of parts in an assembly

8 messages
Open this post in threaded view
|

## Automating positioning of parts in an assembly

 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
Open this post in threaded view
|

## Re: Automating positioning of parts in an assembly

 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
Open this post in threaded view
|

## Re: Automating positioning of parts in an assembly

 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
Open this post in threaded view
|

## Re: Automating positioning of parts in an assembly

 For example, consider this model:https://pastebin.com/3fNius4LI 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
Open this post in threaded view
|

## Re: Automating positioning of parts in an assembly

 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
Open this post in threaded view
|

## Re: Automating positioning of parts in an assembly

 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