-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements for Assemblies #522
Comments
@bernhard-42 Thanks for your work on this. There's a lot to like about your additions. As mentioned in another thread I think, I would like to avoid the overloading of the
I would be supportive of it if you're willing to walk through the iterative process of submit->discuss->change->submit with @adam-urbanczyk and I. I think we all do better when we work through these bigger changes collaboratively.
Mates like you've implemented are more in line with the way I think about 3D constraints. As long as we could pull these changes in without blocking future expansion of the existing assembly constraints system, I would be in support of it.
As long as there's not anything that breaks backwards-compatibility (and it sounds like there's not), I think that would be fine.
Is |
The reason why I described the problems first in my post is that I think they are generic. My solutions are an attempt to solve them based on my still limited understanding of Cadquery. So as long as I see a clear and simple way to create assemblies like my four examples I would be more than happy to adapt my approach. Some more details:
If you you would give me some guidance on how to address the three problems (and maybe some other points) I am happy to come up with a PR as the basis for further discussions. |
Thanks for opening the issue and starting the discussion. I'd like to focus for now on the issue 1.1, because the rest you can for now easily handle with tags or the alternative
Currently deeply nested assemblies assume that all ids are unique, this is obviously not realistic, nor user friendly. I very much like the idea of constructing global IDs using some kind of a separator and adding them the |
I wanted to have the same selectors in CadQuery and Threejs. So it is not that Threejs would know about CadQuery, but from a usability perspective I'd liked to achieve this. I agree that "<" is not the best choice, so if we go for "/" or ":" I would need to have a different addressing for the animation part (I now provide the full path string "bottom>upper_leg>lower" as the id in threejs). Since threejs also parses for ".", all three are not optimal, so I searched for a different one (out of e.g. However, I understand if you'd like to use one of "/", ":" or ".". I would then need to think about how to best keep addressing in CadQuery and in threejs animation system in sync. Of course, I would be interested in how you would use the existing features to achieve 1.2 and 1.3 |
@bernhard-42 Does Threejs allow you to escape the selector string? I.E. Then maybe functions could be created to escape/unescape the paths to/from Threejs? Not ideal, but a potential solution. We could also use something unconventional like |
Finally, the delimiter character is not my biggest issue. I might go for offering both addressing methods for pythreejs groups in jupyter-cadquery: @adam-urbanczyk How would the construction of a unique delimited id work. If we take the example of the hexapod, for each leg that needs to be added, would we need a copy of the leg assembly with changed names? I'd like to ensure that same CadQuery objects (upper and lower legs) still have the same HashCode (to speed up the tessellation process by caching tessellation results and only tessellate uncached objects). |
Re topic 1.3: I found the new Assembly tutorial in the docs and the approach to tag holes works very well, so let's ignore 1.3 as being resolved with standard CadQuery selectors The only issue I had was that for
I did not find a way to select the circle: |
Is that outer circular edge and the hole concentric? The ">X" ( This exact problem made me do #504, try |
I think that IndexError might be a bug though, I would expect ">X[0]" to select some edges. |
Let's leave the discussion about the circle selection out of this thread. I've opened another issue. |
I did some further analysis and found out the working with tags by leveraging the So to summarize the status of the three topics: 1.1: I agree, 1.2 This can be done by using tags in a similar way as in the Assembly Tutorial (pending tests on chained objects as of 1.1) 1.3 This can be done by tags, however, it would be great to have _query either produce |
you could use the
Thanks, I think this will be beneficial for the users.
Note that tagging works with chained selectors too. Or actually: tagging is completely unrelated to selectors .
See above, we could provide another |
Indeed, tagging is very a powerful feature
The idea is to use holes to create mates. The origin of the mate should be the center of hole's circle on the face and obj = (
cq.Workplane("front")
.rect(30,30).workplane(offset=40.0).rect(7.5, 5).loft(combine=True)
.faces(">Y").workplane().circle(2).cutThruAll()
)
c = obj.faces(">Y").edges(cq.NearestToPointSelector((0,10,16)))
a = MAssembly(obj, name="obj")
a.mate("c", "obj", mate=Mate(c)) Does this make sense? Btw. the only way I found to select the circle was to use |
As discussed in bernhard-42/jupyter-cadquery#23 I had added some enhancements to Assemblies which might be helpful for cadquery:
1 Enhancements
1.1 Chained assembly selectors "name1>name2>name3"
Problem: Using the same assemblies several times in an assembly
Simplified example full code:
Now
hexapod.objects
only has onelower
element:If you need to select the
lower
leg of the left back leg (e.g. to assemble yet another object), it doesn't seem to be obvious.Solution approach: I enhanced the assembly selector to support the chain
bottom>right_back>lower
or, because it's also unique,right_back>lower
. InMAssembly
this is done via this function1.2 Chaining object selectors
Problem: Many times one selects components via a chain, e.g.
cad_obj.faces(">Z").edges(">X")
. I did not see a way to do this via"obj_name?tag1@faces@>Z"
querySolution Approach: Besides string queries also allow tuple queries like
("obj_name?tag", "faces@>Z")
and allow more than one object selector, e.g.:("obj_name?tag", "faces@>Z", "edges@>Y")
.Note:
"obj_name?tag1@faces@>Z"
and("obj_name?tag", "faces@>Z")
lead to the same result.Of course, one could also use e.g.
obj_name?tag1@faces@>Z@@edges@>X
, but for me this seems to be harder to read and I anyhow needed the tuple selector for problem 31.3 Selecting one of several holes on a face
Problem: If you have e.g. several holes on a face and want to select a specific one, the only way that came to my mind was to use the
NearestToPointSelector
. But I wanted to use that with a simple query again.Solution approach: Given the tuple query from above, I defined a new pattern:
("wires", (x,y))
. This allowed me to doIn
MAssembly
1.2 and 1.3 are implemented with these functions, however, currently without tag support.2 Questions
What is your take on my 3 problems. Do you see easier solutions already with the existing Assembly selectors?
Would you be interested in a PR to solve these three problems (assuming there is no simple solution at the moment)
The classes
MAssembly
andMate
are a little bit of aliens in my CAD viewer repo. Since theMassembly
approach is based oncq.Assembly
would you be interested in a PR to add the propertymates
and the methods mate(), assemble() tocq.Assemblies
(both methods have 8 lines of code each) and of course the Mate class?This would add a static assembly approach (similar to cqparts and Assembly4 of FreeCad) parallel to your dynamic solver.
If you would add the
MAssembly
functionality tocq.Assembly
, would it be OK to support theorigin
property that holds the origin mate of an Assembly, even if this is only necessary for jupyter_cadquery? Otherwise I would need to monkey-patch CadQuery for origin support.The
relocate()
functions could be omitted, since they are only necessary for the animations system in jupyter-cadquery.These are just a few ideas being developed while learning about assemblies and I would be happy to contribute some stuff to CadQuery if you are interested ...
The text was updated successfully, but these errors were encountered: