-
Notifications
You must be signed in to change notification settings - Fork 372
Add STEP Import for Assemblies #1779
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1779 +/- ##
==========================================
+ Coverage 95.66% 96.06% +0.39%
==========================================
Files 28 30 +2
Lines 7431 9444 +2013
Branches 1122 1562 +440
==========================================
+ Hits 7109 9072 +1963
- Misses 193 226 +33
- Partials 129 146 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@adam-urbanczyk In 4045c58 you set the We need to decide on the proper way to fix this. |
Hey, I do not understand the issue. You can always do this:
Do you mean that you need to modify |
Correct, mypy complains. I can make that change to make |
…king through indirect lookup
I found one more issue: import did not update the fist key in |
Just tinkering with this and noticed the file sizes appear to be different to the original step file, am I doing something wrong here. I have installed this branch with pip
import cadquery as cq
sphere = cq.Workplane().sphere(5.0)
assembly = cq.Assembly()
assembly.add(sphere, name="sphere")
assembly.export("sphere.step")
assembly2 = cq.Assembly()
assembly2.importStep("sphere.step")
assembly2.save("sphere2.step")
assembly2.export("sphere3.step") Filesize appears to be quite different, is some content being missed when importing and saving again ll
-rw-rw-r-- 1 jon jon 3254 Sep 12 13:43 sphere2.step
-rw-rw-r-- 1 jon jon 3254 Sep 12 13:43 sphere3.step
-rw-rw-r-- 1 jon jon 6703 Sep 12 13:43 sphere.step |
Weird, something is definitely off here |
Note that
|
I captured timing for export/load and step file size. These are only observations and perhaps are expected behavior.
# 10k boxes example from PR 1157
import cadquery as cq
import timeit
import os
box = cq.Workplane().box(1, 1, 1)
assy = cq.Assembly()
num = 100
for i in range(1, num + 1, 1):
for j in range(1, num + 1, 1):
assy.add(
box,
name=f"box{i}_{j}",
color=cq.Color("red"),
loc=cq.Location((1.1 * i, 1.1 * j, 0)),
)
# export the assembly to step
tsave = timeit.timeit('assy.export("test1.step")', globals=globals(), number=1)
# load the step
result = []
def timed_load():
result.append(assy.load("test1.step"))
tload = timeit.timeit("timed_load()", globals=globals(), number=1)
# reexport to check file size
result[0].export("test2.step")
print(f"time export: {tsave:.1f} s")
print(f"time load: {tload:.1f} s")
print(
f"original test1.step size: {os.path.getsize('test1.step') / (1024 * 1024):.2f} MB"
)
print(
f"reexport test2.step size: {os.path.getsize('test2.step') / (1024 * 1024):.2f} MB"
) (I am on a faster machine which explains the <2s export vs previous result with ~5s export)
|
FYI: I did quite some rework. Will explain later. |
|
Additionally, I tweaked the docs a little bit. |
The goal is to make it possible to round-trip assemblies to and from STEP without loss of data. This data can include:
Fixes #826 and #1427