Open lorenzncode opened 4 months ago
Attention: 8 lines
in your changes are missing coverage. Please review.
Comparison is base (
153ed3f
) 94.48% compared to head (4853b7b
) 94.37%.
Files | Patch % | Lines |
---|---|---|
cadquery/occ_impl/message.py | 76.92% | 5 Missing and 1 partial :warning: |
cadquery/occ_impl/importers/__init__.py | 80.00% | 1 Missing and 1 partial :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This would allow to process the STEPControl_Reader
object without continuing to import the STEP file for example to extract header info. Another use case might be to abort STEP import if certain alerts or messages are issued on read. There may be other more general purpose OCCT message reporting uses.
import cadquery as cq
report = cq.message.Message.add_report()
reader = cq.importers.readStep("BROKEN_FILE.STEP")
alerts = report.GetAlerts(cq.message.Level.info.value)
if alerts:
raise ValueError("STEP file read resulted in alerts, skip importStep")
else:
res = cq.importers.importStep(reader)
import cadquery as cq
def import_step_abort_on_alert(filename, report=None):
"""
Import STEP
Abort in case of OCCT alert info messages
This is NOT guaranteed to eliminate all crashes.
It is an example based a known corrupted STEP file. See issue #1521.
It *might* help filter some problematic STEP files.
In other cases perhaps trace level messages must be inspected or there
may not be any way to know up front whether a STEP file is problematic.
"""
if report is None:
report = cq.message.Message.add_report()
report.Clear(cq.message.Level.info.value)
reader = cq.importers.readStep(filename)
alerts = report.GetAlerts(cq.message.Level.info.value)
if alerts:
raise ValueError("abort STEP import")
else:
res = cq.importers.importStep(reader)
return res
step_files = ("BROKEN_FILE.STEP", "good.step", "BROKEN_FILE.STEP", "good.step")
report = cq.message.Message.add_report()
for f in step_files:
try:
res = import_step_abort_on_alert(f, report)
except ValueError:
res = None
Interface to OCCT Message