Skip to content

Add assy imprint method - #2128

Draft
adam-urbanczyk wants to merge 2 commits into
masterfrom
adam-assy-imprint-method
Draft

adam-urbanczyk wants to merge 2 commits into
masterfrom
adam-assy-imprint-method

Conversation

@adam-urbanczyk

@adam-urbanczyk adam-urbanczyk commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #2075

@adam-urbanczyk
adam-urbanczyk marked this pull request as draft November 6, 2026 17:46
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 29.03226% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.59%. Comparing base (477d87d) to head (add645c).

Files with missing lines Patch % Lines
cadquery/assembly.py 20.83% 19 Missing ⚠️
cadquery/occ_impl/shapes.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2128      +/-   ##
==========================================
- Coverage   95.81%   95.59%   -0.22%     
==========================================
  Files          30       30              
  Lines        9605     9634      +29     
  Branches     1443     1447       +4     
==========================================
+ Hits         9203     9210       +7     
- Misses        247      269      +22     
  Partials      155      155              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

shimwell added a commit to fusion-energy/paramak that referenced this pull request Nov 6, 2026
paramak's remove() matched parts with endswith('/<name>') on the names
yielded by iterating the assembly. CadQuery/cadquery#2128 changes those
names so direct children of the root no longer carry the root prefix,
which would make remove() silently return the full assembly.

cadquery has had Assembly.remove since 2.6.0 (paramak's floor). It
removes the part in place by its key, keeps nested structure and raises
ValueError for an unknown name. Drop the override and test cadquery's
method on plain assemblies, nested sub-assemblies and a full reactor.
@shimwell

shimwell commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

this looks useful for a few workflows in cad-to-dagmc where i have functions that take assemblies and imprint them.

It might be useful to allow the assembly to know if it has been imprinted or know so that if imprinted assemblies are passed around the receiver does not accidentally imprint them again

I was looking into how this improves my upstream codes and got a few keyerrors that might be worth considering

@shimwell

shimwell commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

KeyError when a part (or a named sub-shape) is not changed by the imprint

import cadquery as cq

a = cq.Assembly()
a.add(cq.Workplane().box(10, 10, 10).val(), name="p0")
a.add(cq.Workplane().transformed(offset=(50, 0, 0)).box(10, 10, 10).val(), name="p1")
a.imprint()  # KeyError

@shimwell

shimwell commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Parts with a loc are moved twice and lose their shared faces

a = cq.Assembly()
a.add(cq.Workplane().box(10, 10, 10).val(), name="a")
a.add(cq.Workplane().box(10, 10, 10).val(), name="b", loc=cq.Location((10, 0, 0)))
a.imprint()
# "b" now spans x 15..25 (should be 5..15), and the compound has 12 faces instead of 11

@adam-urbanczyk

Copy link
Copy Markdown
Member Author

Thanks @shimwell , this is still a draft. I would not yet recommend testing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement cq.Assembly.imprint

2 participants