-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shared abstraction for STEP assembly
- Loading branch information
Showing
3 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import cadquery as cq | ||
from OCP.Message import Message, Message_Gravity # type: ignore | ||
|
||
|
||
class StepAssembly: | ||
""" | ||
A STEP assembly. | ||
""" | ||
def __init__(self, name: str): | ||
self.assembly = cq.Assembly(name=name) | ||
|
||
# Less verbose output | ||
for printer in Message.DefaultMessenger_s().Printers(): | ||
printer.SetTraceLevel(Message_Gravity.Message_Fail) | ||
|
||
def add_body(self, body: cq.Workplane, name: str, color: cq.Color): | ||
""" | ||
Add a body to the assembly. | ||
""" | ||
self.assembly.add(body, name=name, color=color) | ||
|
||
def save(self, path: str): | ||
""" | ||
Write the STEP file to the specified path. | ||
""" | ||
self.assembly.save(path, 'STEP', mode='fused', write_pcurves=False) |
This file contains 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