Isolate STEPControl_Reader ReadFile#1525
Draft
lorenzncode wants to merge 1 commit intoCadQuery:masterfrom
Draft
Conversation
Interface to OCCT Message
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1525 +/- ##
==========================================
- Coverage 94.48% 94.37% -0.11%
==========================================
Files 28 29 +1
Lines 5780 5813 +33
Branches 1071 1077 +6
==========================================
+ Hits 5461 5486 +25
- Misses 193 199 +6
- Partials 126 128 +2 ☔ View full report in Codecov by Sentry. |
Member
Author
|
This would allow to process the 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Interface to OCCT Message