Construction geometry in assemblies.

324 views
Skip to first unread message

michal....@gmail.com

unread,
Oct 13, 2020, 2:55:53 PM10/13/20
to CadQuery
Hello,
I'd like to ask for help with finding a workflow in CadQuery for a general use-case I'm going try to describe:

Most of my 3D modelling projects could be described as placing some parts into an enclosure and then continue modeling the enclosure around the placed parts like making connector holes, creating mounting columns etc...

For example I have modeled this joystick in CQ: 1.jpg
I want to place it multiple times into a panel along with some other parts.

To be able to do that it seems that I need:
  1. Some assembly system which can place things in respect to each other according to some rules - constraints. I know that Adam Urbanczyk added such assembly functionality few days ago. Let call this point solved.
  2. I need to some way to define an attachment point+orientation in the joystick model where it should go through a surface of the target panel. Here I'm thinking about creating named/tagged dummy plane inside the joystick model for using in constraints. It probably should work, right?
  3. I somehow need to embed a construction geometry - a circle - into the joystick model which can the be used to cut openings in places where the joystick is placed. I really think that this construction geometry should be a part of the joystick itself and user can then decide whether to use it to drill a hole or not. How to embed such construction geometry into the joystick model?
  4. For each joystick I need to prepare some mounting pillars and drill holes into the panel. This is similar to point 3 but some of the geometry which can be used for this is already in the joystick model: The mounting holes. Can they be tagged in the joystick and then selected in the assembly?
I'm almost clueless about how to do 3. and 4. Perhaps it is a bad idea for some reason?
Right now I'm about to implement my own 'assembly' system where one can place whole containers/groups of models and then decided which models to contatenate/union with others and which to use for cutting and which as a construction geometry. Before I do that I'd like to know whether there perhaps is a viable workflow for this in current CQ without writing a whole new assembly framework over it.

Jeremy Wright

unread,
Oct 13, 2020, 3:47:48 PM10/13/20
to CadQuery
> Some assembly system which can place things in respect to each other according to some rules - constraints.

The docs aren't very complete for assemblies yet, but here are a couple of links to help you get started.



Don't forget the call solve() after setting up the constraints.

> I need to some way to define an attachment point+orientation in the joystick model where it should go through a surface of the target panel.

I think you can probably accomplish this with assemblies.

> I somehow need to embed a construction geometry - a circle - into the joystick model which can the be used to cut openings in places where the joystick is placed.

cqparts is unmaintained now, but it had that functionality back in the FreeCAD days. You could dig around in their codebase to see how they did it. Adam will probably have a better idea on how to do this, but in theory you should be able to select geometry (wire/edges) from one object, place them into a new Workplane object, and then do something like a cutThruAll on that. I'd need to work through it though to see how/if it would work.


> Can they be tagged in the joystick and then selected in the assembly?

Workplane objects can be tagged and selected based on that tag. There's probably a way to reuse the geometry similar to the last point.

michal....@gmail.com

unread,
Oct 14, 2020, 8:20:13 AM10/14/20
to CadQuery
> cqparts is unmaintained now, but it had that functionality back in the FreeCAD days.

Yess, you are right. The glorious cqparts. I now remember using it. Seems like it was ages ago. I even asked the author to consider re-licencing it to the same license as CQ has. https://github.com/cqparts/cqparts/issues/59
I think I'll port it to CQ2 or at least re-create something similar (with credits to cqparts of course!).

Jeremy Wright

unread,
Oct 14, 2020, 8:58:14 AM10/14/20
to CadQuery
I think my fork of cqparts is most of the way there on CQ 2.x compatibility but to my knowledge nobody has tried using it. The cqparts team never responded about whether they have any interest in CQ 2.x compatibility and I've got too many other priorities, so I just stopped working on my fork once I got the tests to pass. It should still up-to-date with cqparts master though since there hasn't been any activity.


michal....@gmail.com

unread,
Oct 14, 2020, 9:28:19 AM10/14/20
to CadQuery
Ok. I'll look into your fork.


> but to my knowledge nobody has tried using it

My observation is that very few people are trying to use these opensource CAD projects for anything even a little more complicated.
For example Lattice2 workbench for FreeCAD can be used not only for assembly but also to apply Body with both additive and subtractive features to another Body. But you very rarely see this workbench or even such functionality mentioned anywhere.
And you still can't have instances of a same Part or Body just with various parameters in your model in FreeCAD. And the thing is that there seems not to be many requests for such basic features on FreeCAD forums.
It is a little sad :(

Adam Urbanczyk

unread,
Oct 14, 2020, 12:46:21 PM10/14/20
to CadQuery
Hey,

(1) Assembly functionality allows to place parts with respect to each other (i.e. you can create a hierarchy) and use constraints if you want to.
(2) I don't understand what do you mean and/or I would not do it like that. I'd model the plate and the joystick separately and use existing features to align them (constrain 4 holes in the one part to align with 4 holes in the other). BTW: at the moment you cannot constrain on tags, but it is coming up soon.
(3) I don't think we have such functionality. I assume that you know the size of the opening (if not you could select an edge and get the radius on OCCT level) and that the positions are also known. It i just a matter of making holes of the specified radius at the desired locations, no need to use an extra geometry for that.
(4) I don't think it is practical to do it like you propose. I'd personally define the hole pattern upfront (let's say it is a input parameter) as a list of Location objects (List[Location]) and I'd use pushPoints to apply them on different solids. If one of the parts is imported you'd need to first use selectors to extract the pattern and generate the location list.

I have a general feeling that you are trying to replicate a conventional CAD flow, but that might not be always an optimal way of working in CQ.

Maybe interesting for you: the most complicated project using CQ I know is: https://github.com/fx-bricks/fx-cad-notes

HTH,
Adam

michal....@gmail.com

unread,
Oct 14, 2020, 2:04:49 PM10/14/20
to CadQuery
Regarding the point (2) I'll try to clarify it by pictures:
20201014_192427.jpg20201014_192447.jpg
The joystick should always be attached in a way where exactly half of the half-ball part is sticking out of the target panel/wall/box/whatever. Whether one decides to support it from the top like on the second picture or from the bottom does not matter. The half of the half-ball part should always be sticking out, not more, not less.

(3) I actually do not have the size of the opening. I can calculate it from the radius of the half-ball part. But it would be easier to make an intersection with a plane cuting through a half of the half-ball part then geting the outer wire and then doing 2D offset to enlarge it just a little.

Or I can prepare much more complicated geometry than a circle. Make a part which should be cut away from the target!
Jeremy reminded me that cqparts had exactly this functionality. One can even see an example in the documentation https://cqparts.github.io/cqparts/doc/cqparts/assembly-build-cycle.html#single-build-cycle. Just look for
the `def cutaway(self):`. In that specific example it is something like a bounding cylinder i.e. without the middle hole.
I image making similar thing for the joystick instead of a preparing just a circle.
20201014_194300.jpg20201014_194306.jpg
If one cuts out such solid from the target thing it won't matter whether it is a thin panel (where it will make more or less a hole) or a big solid brick (where it will make a nice pocket, although with no way to place the joystick into it without additional modelling).

I'll certainly look at the https://github.com/fx-bricks/fx-cad-notes . Thank you very much.

Adam Urbanczyk

unread,
Oct 14, 2020, 3:49:02 PM10/14/20
to CadQuery
You can still do (2) with constraints.  You could  use e.g. bottom edge of the half-ball and the edge of the opening to define a point (with a specified distance) and an axis constraint. You can also specify arbitrary geometric entities as inputs for the constraints (see the constrain method signature) if that is what you fancy to do - they will be interpreted as positioned in the local coordinate system of the given object.

Regarding (3) there are section() and offset2D() methods that can accomplish this task.

If cqparts fits your flow, then I'd say just use it. I have no personal experience with it though so I cannot help there. Please also note that in the end you have whole Python at your command so you can add methods, attributes or define new classes if that simplifies things. Using e.g. each() and eachpnt() with custom functors can go a long way in my experience.

Best,
Adam
Reply all
Reply to author
Forward
0 new messages