Skip to content

Better imprint for assy#2069

Open
adam-urbanczyk wants to merge 6 commits into
masterfrom
adam-imprint-fix
Open

Better imprint for assy#2069
adam-urbanczyk wants to merge 6 commits into
masterfrom
adam-imprint-fix

Conversation

@adam-urbanczyk

@adam-urbanczyk adam-urbanczyk commented Jul 16, 2026

Copy link
Copy Markdown
Member

Low level fix enabling faster imprints for well behaved models.

NB: this PR also contains a typing fix related to Numba version update.


Tangentially related to this PR (I added explicit test for this use case) - it is possible to imprint subassemblies separately and on per subassy basis use different imprint glue settings in order to optimize performance:

res1, origins1 = cq.occ_impl.assembly.imprint(complex_assy.sub1, glue='partial')
res2, origins2 = cq.occ_impl.assembly.imprint(complex_assy.sub2, glue='full')

# combine the results
res: Compound = res1 | res2
origins: dict[Shape, Shape] = origins1 | origins2

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.70%. Comparing base (b47f7b7) to head (48a005a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2069   +/-   ##
=======================================
  Coverage   95.70%   95.70%           
=======================================
  Files          30       30           
  Lines        9479     9479           
  Branches     1410     1410           
=======================================
  Hits         9072     9072           
  Misses        253      253           
  Partials      154      154           

☔ 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.

@lorenzncode lorenzncode left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @adam-urbanczyk !

Comment thread cadquery/occ_impl/assembly.py
Comment thread cadquery/occ_impl/assembly.py Outdated
@adam-urbanczyk

Copy link
Copy Markdown
Member Author

@jmwright would you be able to take a look?

@jmwright jmwright left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MRE:

import cadquery as cq
from cadquery.occ_impl.assembly import imprint
imprint(cq.Assembly().add(cq.Workplane().box(1, 1, 1)))

gives this error:

Traceback (most recent call last):
  File "<python-input-4>", line 1, in <module>
    imprint(cq.Assembly().add(cq.Workplane().box(1, 1, 1)))
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jwright/repos/cadquery/cadquery/occ_impl/assembly.py", line 885, in imprint
    res = Shape(builder.Shape())
  File "/home/jwright/repos/cadquery/cadquery/occ_impl/shapes.py", line 445, in __init__
    self.wrapped = downcast(obj)
                   ~~~~~~~~^^^^^
  File "/home/jwright/repos/cadquery/cadquery/occ_impl/shapes.py", line 419, in downcast
    f_downcast: Any = downcast_LUT[shapetype(obj)]
                                   ~~~~~~~~~^^^^^
  File "/home/jwright/repos/cadquery/cadquery/occ_impl/shapes.py", line 409, in shapetype
    raise ValueError("Null TopoDS_Shape object")

"""
Imprint all the solids and construct a dictionary mapping imprinted solids to names from the input assy.

Depending on the use case, it might be required do use different `glue` option. Moreover, for large models

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Depending on the use case, it might be required do use different `glue` option. Moreover, for large models
Depending on the use case, it might be required to use a different `glue` option. Moreover, for large models

"""
Imprint arbitrary number of shapes.

Depending on the use case, it might be required do use different `glue` option. Moreover, for large models

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Depending on the use case, it might be required do use different `glue` option. Moreover, for large models
Depending on the use case, it might be required to use a different `glue` option. Moreover, for large models

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.

3 participants