Skip to content
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

21 update to use the mainkcl method of organization #22

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions gridfinity/baseplate/project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[settings.app]

[settings.modeling]
base_unit = "mm"

[settings.text_editor]

[settings.command_bar]
8 changes: 8 additions & 0 deletions gridfinity/bins-stacking-lip/project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[settings.app]

[settings.modeling]
base_unit = "mm"

[settings.text_editor]

[settings.command_bar]
File renamed without changes.
8 changes: 8 additions & 0 deletions gridfinity/bins/project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[settings.app]

[settings.modeling]
base_unit = "mm"

[settings.text_editor]

[settings.command_bar]
36 changes: 25 additions & 11 deletions output_from_kcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_units(kcl_path: Path) -> UnitLength:
settings_path = kcl_path.parent / "project.toml"
if not settings_path.exists():
return kcl.UnitLength.Mm

with open(settings_path, "rb") as f:
data = tomllib.load(f)
try:
Expand Down Expand Up @@ -99,33 +99,47 @@ def snapshot(code: str, save_path: Path, unit_length: UnitLength = kcl.UnitLengt


def process_single_kcl(kcl_path: Path) -> dict:
print(f"Processing {kcl_path.name}")
# The part name is the parent folder since each file is main.kcl
part_name = kcl_path.parent.name
src_name = kcl_path.parts[-3]

print(f"Processing {src_name}/{part_name}")

# determine units based on project.toml
units = get_units(kcl_path)

# read the file to get the code as a string
with open(kcl_path, "r") as inp:
code = str(inp.read())

export_status = export_step(code=code, save_path=Path(__file__).parent / "step" / kcl_path.stem, unit_length=units)
# determine the root dir (e.g. /path/to/mcmmaster-carr)
root_dir = Path(__file__).parent
# step and screenshots for the part are based on the root dir
step_path = root_dir / "step" / part_name
screenshots_path = root_dir / "screenshots" / part_name

# attempt step export
export_status = export_step(code=code, save_path=step_path, unit_length=units)
count = 1
while not export_status and count < RETRIES:
export_status = export_step(code=code, save_path=Path(__file__).parent / "step" / kcl_path.stem,
unit_length=units)
export_status = export_step(code=code, save_path=step_path, unit_length=units)
count += 1

snapshot_status = snapshot(code=code, save_path=Path(__file__).parent / "screenshots" / kcl_path.stem,
unit_length=units)
# attempt screenshot
snapshot_status = snapshot(code=code, save_path=screenshots_path, unit_length=units)
count = 1
while not snapshot_status and count < RETRIES:
snapshot_status = snapshot(code=code, save_path=Path(__file__).parent / "screenshots" / kcl_path.stem,
unit_length=units)
snapshot_status = snapshot(code=code, save_path=screenshots_path, unit_length=units)
count += 1

return {"filename": kcl_path.name, "export_status": export_status, "snapshot_status": snapshot_status}
# find relative paths, used for building the README.md
kcl_rel_path = kcl_path.relative_to(Path(__file__).parent)

return {"filename": f"{kcl_rel_path}", "export_status": export_status, "snapshot_status": snapshot_status}


def main():
kcl_files = find_files(path=Path(__file__).parent, valid_suffixes=[".kcl"])
kcl_files = find_files(path=Path(__file__).parent, valid_suffixes=[".kcl"], name_pattern="main")

# run concurrently
with ProcessPoolExecutor(max_workers=5) as executor:
Expand Down
2 changes: 1 addition & 1 deletion step/baseplate-magnets.step
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((('zoo.dev export')), '2;1');
FILE_NAME('dump.step', '2025-01-14T20:39:05.541005414+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_NAME('dump.step', '2025-01-14T21:13:05.172134035+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));
ENDSEC;
DATA;
Expand Down
2 changes: 1 addition & 1 deletion step/baseplate.step
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((('zoo.dev export')), '2;1');
FILE_NAME('dump.step', '2025-01-14T20:39:01.874908161+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_NAME('dump.step', '2025-01-14T21:13:01.314175208+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));
ENDSEC;
DATA;
Expand Down
2 changes: 1 addition & 1 deletion step/bins-stacking-lip.step
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((('zoo.dev export')), '2;1');
FILE_NAME('dump.step', '2025-01-14T20:39:04.159604820+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_NAME('dump.step', '2025-01-14T21:13:03.532649735+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));
ENDSEC;
DATA;
Expand Down
2 changes: 1 addition & 1 deletion step/bins.step
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((('zoo.dev export')), '2;1');
FILE_NAME('dump.step', '2025-01-14T20:39:03.528552557+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_NAME('dump.step', '2025-01-14T21:13:03.032793851+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));
ENDSEC;
DATA;
Expand Down