diff --git a/3mf/base/Electronics_Cover_Bottom.3mf b/3mf/base/Electronics_Cover_Bottom_[x1].3mf similarity index 97% rename from 3mf/base/Electronics_Cover_Bottom.3mf rename to 3mf/base/Electronics_Cover_Bottom_[x1].3mf index 72f2e8a..1049a29 100644 Binary files a/3mf/base/Electronics_Cover_Bottom.3mf and b/3mf/base/Electronics_Cover_Bottom_[x1].3mf differ diff --git a/3mf/base/Electronics_Cover_Center_Module_[x2].3mf b/3mf/base/Electronics_Cover_Center_Module_[x2].3mf new file mode 100644 index 0000000..f364fff Binary files /dev/null and b/3mf/base/Electronics_Cover_Center_Module_[x2].3mf differ diff --git a/3mf/base/Electronics_Cover_Connectors_Module.3mf b/3mf/base/Electronics_Cover_Connectors_Module_[x1].3mf similarity index 98% rename from 3mf/base/Electronics_Cover_Connectors_Module.3mf rename to 3mf/base/Electronics_Cover_Connectors_Module_[x1].3mf index f9c9315..b050c80 100644 Binary files a/3mf/base/Electronics_Cover_Connectors_Module.3mf and b/3mf/base/Electronics_Cover_Connectors_Module_[x1].3mf differ diff --git a/3mf/base/Electronics_Cover_Display_Module.3mf b/3mf/base/Electronics_Cover_Display_Module.3mf deleted file mode 100644 index 5277db1..0000000 Binary files a/3mf/base/Electronics_Cover_Display_Module.3mf and /dev/null differ diff --git a/3mf/base/Electronics_Cover_Display_Module_Hinge_Lock_[x1].3mf b/3mf/base/Electronics_Cover_Display_Module_Hinge_Lock_[x1].3mf new file mode 100644 index 0000000..13d3c66 Binary files /dev/null and b/3mf/base/Electronics_Cover_Display_Module_Hinge_Lock_[x1].3mf differ diff --git a/3mf/base/Electronics_Cover_Display_Module_Hinge_[x1].3mf b/3mf/base/Electronics_Cover_Display_Module_Hinge_[x1].3mf new file mode 100644 index 0000000..06f6cb0 Binary files /dev/null and b/3mf/base/Electronics_Cover_Display_Module_Hinge_[x1].3mf differ diff --git a/3mf/base/Electronics_Cover_Display_Module_Panel_[x1].3mf b/3mf/base/Electronics_Cover_Display_Module_Panel_[x1].3mf new file mode 100644 index 0000000..c88d934 Binary files /dev/null and b/3mf/base/Electronics_Cover_Display_Module_Panel_[x1].3mf differ diff --git a/3mf/base/Electronics_Cover_Fan_Module.3mf b/3mf/base/Electronics_Cover_Fan_Module_[x2].3mf similarity index 99% rename from 3mf/base/Electronics_Cover_Fan_Module.3mf rename to 3mf/base/Electronics_Cover_Fan_Module_[x2].3mf index 7b142f8..263d5ef 100644 Binary files a/3mf/base/Electronics_Cover_Fan_Module.3mf and b/3mf/base/Electronics_Cover_Fan_Module_[x2].3mf differ diff --git a/3mf/base/Electronics_Cover_Short.3mf b/3mf/base/Electronics_Cover_Short.3mf deleted file mode 100644 index 6c2e263..0000000 Binary files a/3mf/base/Electronics_Cover_Short.3mf and /dev/null differ diff --git a/3mf/base/Electronics_Cover_Top.3mf b/3mf/base/Electronics_Cover_Top.3mf deleted file mode 100644 index 80cbe1c..0000000 Binary files a/3mf/base/Electronics_Cover_Top.3mf and /dev/null differ diff --git a/3mf/base/Electronics_Cover_Top_[x1].3mf b/3mf/base/Electronics_Cover_Top_[x1].3mf new file mode 100644 index 0000000..1161db1 Binary files /dev/null and b/3mf/base/Electronics_Cover_Top_[x1].3mf differ diff --git a/3mf/base/Electronics_DIN_Rail_Holder_[x6].3mf b/3mf/base/Electronics_DIN_Rail_Holder_[x6].3mf new file mode 100644 index 0000000..2e304ee Binary files /dev/null and b/3mf/base/Electronics_DIN_Rail_Holder_[x6].3mf differ diff --git a/3mf/base/Electronics_Display_Back_[x1].3mf b/3mf/base/Electronics_Display_Back_[x1].3mf new file mode 100644 index 0000000..fc943c0 Binary files /dev/null and b/3mf/base/Electronics_Display_Back_[x1].3mf differ diff --git a/3mf/base/Electronics_Display_Frame_[x1].3mf b/3mf/base/Electronics_Display_Frame_[x1].3mf new file mode 100644 index 0000000..54063d6 Binary files /dev/null and b/3mf/base/Electronics_Display_Frame_[x1].3mf differ diff --git a/3mf/base/Frame_Bearing_Holder.3mf b/3mf/base/Frame_Bearing_Holder_[x1].3mf similarity index 98% rename from 3mf/base/Frame_Bearing_Holder.3mf rename to 3mf/base/Frame_Bearing_Holder_[x1].3mf index 81ed85b..d288b3b 100644 Binary files a/3mf/base/Frame_Bearing_Holder.3mf and b/3mf/base/Frame_Bearing_Holder_[x1].3mf differ diff --git a/3mf/base/Frame_Handle_[x1].3mf b/3mf/base/Frame_Handle_[x1].3mf new file mode 100644 index 0000000..8062340 Binary files /dev/null and b/3mf/base/Frame_Handle_[x1].3mf differ diff --git a/3mf/base/Frame_Motor_Frame.3mf b/3mf/base/Frame_Motor_Frame.3mf deleted file mode 100644 index d5620db..0000000 Binary files a/3mf/base/Frame_Motor_Frame.3mf and /dev/null differ diff --git a/3mf/base/Frame_Motor_Mount.3mf b/3mf/base/Frame_Motor_Mount_[x1].3mf similarity index 99% rename from 3mf/base/Frame_Motor_Mount.3mf rename to 3mf/base/Frame_Motor_Mount_[x1].3mf index 9876189..15dceaa 100644 Binary files a/3mf/base/Frame_Motor_Mount.3mf and b/3mf/base/Frame_Motor_Mount_[x1].3mf differ diff --git a/3mf/base/Frame_Plate_Clamp_[x4].3mf b/3mf/base/Frame_Plate_Clamp_[x4].3mf new file mode 100644 index 0000000..9511401 Binary files /dev/null and b/3mf/base/Frame_Plate_Clamp_[x4].3mf differ diff --git a/3mf/base/Frame_Plate_Side_Clamp.3mf b/3mf/base/Frame_Plate_Side_Clamp.3mf deleted file mode 100644 index 832580c..0000000 Binary files a/3mf/base/Frame_Plate_Side_Clamp.3mf and /dev/null differ diff --git a/3mf/base/Frame_Plate_Side_Left.3mf b/3mf/base/Frame_Plate_Side_Left.3mf deleted file mode 100644 index 9c2df38..0000000 Binary files a/3mf/base/Frame_Plate_Side_Left.3mf and /dev/null differ diff --git a/3mf/base/Frame_Plate_Side_Left_[x2].3mf b/3mf/base/Frame_Plate_Side_Left_[x2].3mf new file mode 100644 index 0000000..65b2f50 Binary files /dev/null and b/3mf/base/Frame_Plate_Side_Left_[x2].3mf differ diff --git a/3mf/base/Frame_Plate_Side_Right.3mf b/3mf/base/Frame_Plate_Side_Right.3mf deleted file mode 100644 index a3e9472..0000000 Binary files a/3mf/base/Frame_Plate_Side_Right.3mf and /dev/null differ diff --git a/3mf/base/Frame_Plate_Side_Right_[x2].3mf b/3mf/base/Frame_Plate_Side_Right_[x2].3mf new file mode 100644 index 0000000..154fafd Binary files /dev/null and b/3mf/base/Frame_Plate_Side_Right_[x2].3mf differ diff --git a/3mf/base/Frame_Tip.3mf b/3mf/base/Frame_Tip.3mf deleted file mode 100644 index 33e02b8..0000000 Binary files a/3mf/base/Frame_Tip.3mf and /dev/null differ diff --git a/3mf/base/Frame_Tip_Bottom.3mf b/3mf/base/Frame_Tip_Bottom_[x1].3mf similarity index 99% rename from 3mf/base/Frame_Tip_Bottom.3mf rename to 3mf/base/Frame_Tip_Bottom_[x1].3mf index db4c3b6..8b7c463 100644 Binary files a/3mf/base/Frame_Tip_Bottom.3mf and b/3mf/base/Frame_Tip_Bottom_[x1].3mf differ diff --git a/3mf/base/Frame_Tip_Top.3mf b/3mf/base/Frame_Tip_Top_[x1].3mf similarity index 99% rename from 3mf/base/Frame_Tip_Top.3mf rename to 3mf/base/Frame_Tip_Top_[x1].3mf index 5daaf06..28d376f 100644 Binary files a/3mf/base/Frame_Tip_Top.3mf and b/3mf/base/Frame_Tip_Top_[x1].3mf differ diff --git a/cad/Frame_Assembly.FCStd b/cad/Frame_Assembly.FCStd index d85108c..67dea35 100644 Binary files a/cad/Frame_Assembly.FCStd and b/cad/Frame_Assembly.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Bottom.FCStd b/cad/printed/base/Electronics_Cover_Bottom.FCStd index d4d030f..b9f29c2 100644 Binary files a/cad/printed/base/Electronics_Cover_Bottom.FCStd and b/cad/printed/base/Electronics_Cover_Bottom.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Center_Module.FCStd b/cad/printed/base/Electronics_Cover_Center_Module.FCStd index c17fdc0..f548f27 100644 Binary files a/cad/printed/base/Electronics_Cover_Center_Module.FCStd and b/cad/printed/base/Electronics_Cover_Center_Module.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Connectors_Module.FCStd b/cad/printed/base/Electronics_Cover_Connectors_Module.FCStd index c4e5c15..7e7c855 100644 Binary files a/cad/printed/base/Electronics_Cover_Connectors_Module.FCStd and b/cad/printed/base/Electronics_Cover_Connectors_Module.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Display_Module.FCStd b/cad/printed/base/Electronics_Cover_Display_Module.FCStd index e180de3..0edca5a 100644 Binary files a/cad/printed/base/Electronics_Cover_Display_Module.FCStd and b/cad/printed/base/Electronics_Cover_Display_Module.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Empty_Module.FCStd b/cad/printed/base/Electronics_Cover_Empty_Module.FCStd index f93484c..e45b065 100644 Binary files a/cad/printed/base/Electronics_Cover_Empty_Module.FCStd and b/cad/printed/base/Electronics_Cover_Empty_Module.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Fan_Module.FCStd b/cad/printed/base/Electronics_Cover_Fan_Module.FCStd index dba78e7..5edd342 100644 Binary files a/cad/printed/base/Electronics_Cover_Fan_Module.FCStd and b/cad/printed/base/Electronics_Cover_Fan_Module.FCStd differ diff --git a/cad/printed/base/Electronics_Cover_Top.FCStd b/cad/printed/base/Electronics_Cover_Top.FCStd index 082ba40..37a7a74 100644 Binary files a/cad/printed/base/Electronics_Cover_Top.FCStd and b/cad/printed/base/Electronics_Cover_Top.FCStd differ diff --git a/cad/printed/base/Electronics_DIN_Rail_Holder.FCStd b/cad/printed/base/Electronics_DIN_Rail_Holder.FCStd new file mode 100644 index 0000000..afc1e43 Binary files /dev/null and b/cad/printed/base/Electronics_DIN_Rail_Holder.FCStd differ diff --git a/cad/printed/base/Electronics_Display.FCStd b/cad/printed/base/Electronics_Display.FCStd new file mode 100644 index 0000000..cb9dfed Binary files /dev/null and b/cad/printed/base/Electronics_Display.FCStd differ diff --git a/cad/printed/base/Frame_Bearing_Holder.FCStd b/cad/printed/base/Frame_Bearing_Holder.FCStd index ee0bd71..65f46c0 100644 Binary files a/cad/printed/base/Frame_Bearing_Holder.FCStd and b/cad/printed/base/Frame_Bearing_Holder.FCStd differ diff --git a/cad/printed/base/Frame_Handle.FCStd b/cad/printed/base/Frame_Handle.FCStd new file mode 100644 index 0000000..0cfe126 Binary files /dev/null and b/cad/printed/base/Frame_Handle.FCStd differ diff --git a/cad/printed/base/Frame_Motor_Frame.FCStd b/cad/printed/base/Frame_Motor_Frame.FCStd deleted file mode 100644 index c0ccbd6..0000000 Binary files a/cad/printed/base/Frame_Motor_Frame.FCStd and /dev/null differ diff --git a/cad/printed/base/Frame_Motor_Mount.FCStd b/cad/printed/base/Frame_Motor_Mount.FCStd index c9eaca0..d4e8af4 100644 Binary files a/cad/printed/base/Frame_Motor_Mount.FCStd and b/cad/printed/base/Frame_Motor_Mount.FCStd differ diff --git a/cad/printed/base/Frame_Plate_Side_Left.FCStd b/cad/printed/base/Frame_Plate_Side_Left.FCStd index 8a08d74..9d75dcf 100644 Binary files a/cad/printed/base/Frame_Plate_Side_Left.FCStd and b/cad/printed/base/Frame_Plate_Side_Left.FCStd differ diff --git a/cad/printed/base/Frame_Plate_Side_Right.FCStd b/cad/printed/base/Frame_Plate_Side_Right.FCStd index a8aec6c..4d1d313 100644 Binary files a/cad/printed/base/Frame_Plate_Side_Right.FCStd and b/cad/printed/base/Frame_Plate_Side_Right.FCStd differ diff --git a/cad/printed/base/Frame_Tip_Bottom.FCStd b/cad/printed/base/Frame_Tip_Bottom.FCStd index 31433a5..71d9877 100644 Binary files a/cad/printed/base/Frame_Tip_Bottom.FCStd and b/cad/printed/base/Frame_Tip_Bottom.FCStd differ diff --git a/cad/printed/base/Frame_Tip_Top.FCStd b/cad/printed/base/Frame_Tip_Top.FCStd index d13aba4..569fe04 100644 Binary files a/cad/printed/base/Frame_Tip_Top.FCStd and b/cad/printed/base/Frame_Tip_Top.FCStd differ diff --git a/cad/sourced/DIN_Rail_130mm.FCStd b/cad/sourced/DIN_Rail_130mm.FCStd index 84abdc7..f5914e7 100644 Binary files a/cad/sourced/DIN_Rail_130mm.FCStd and b/cad/sourced/DIN_Rail_130mm.FCStd differ diff --git a/cad/sourced/Electronics_Cover.FCStd b/cad/sourced/Electronics_Cover.FCStd index 361a331..4d2e18c 100644 Binary files a/cad/sourced/Electronics_Cover.FCStd and b/cad/sourced/Electronics_Cover.FCStd differ diff --git a/cad/sourced/Electronics_Separator.FCStd b/cad/sourced/Electronics_Separator.FCStd index bc0cfc3..d4420bc 100644 Binary files a/cad/sourced/Electronics_Separator.FCStd and b/cad/sourced/Electronics_Separator.FCStd differ diff --git a/cad/sourced/Profile-20x20-130.FCStd b/cad/sourced/Profile-20x20-130.FCStd index 688ad91..c9c6198 100644 Binary files a/cad/sourced/Profile-20x20-130.FCStd and b/cad/sourced/Profile-20x20-130.FCStd differ diff --git a/cad/sourced/Profile-20x20-60.FCStd b/cad/sourced/Profile-20x20-60.FCStd index edfc87b..0e5a494 100644 Binary files a/cad/sourced/Profile-20x20-60.FCStd and b/cad/sourced/Profile-20x20-60.FCStd differ diff --git a/cad/sourced/Profile-20x40-300.FCStd b/cad/sourced/Profile-20x40-300.FCStd index b667767..36d538d 100644 Binary files a/cad/sourced/Profile-20x40-300.FCStd and b/cad/sourced/Profile-20x40-300.FCStd differ diff --git a/cad/sourced/Rapsberry_Pi_3B_Plus.FCStd b/cad/sourced/Rapsberry_Pi_3B_Plus.FCStd index 56950a8..4d3ea53 100644 Binary files a/cad/sourced/Rapsberry_Pi_3B_Plus.FCStd and b/cad/sourced/Rapsberry_Pi_3B_Plus.FCStd differ diff --git a/cad/sourced/Rod_8_300.FCStd b/cad/sourced/Rod_8_300.FCStd index fdadbac..ac69dbd 100644 Binary files a/cad/sourced/Rod_8_300.FCStd and b/cad/sourced/Rod_8_300.FCStd differ diff --git a/cad/sourced/UHP-200A.FCStd b/cad/sourced/UHP-200A.FCStd index 1898f96..41b8ce9 100644 Binary files a/cad/sourced/UHP-200A.FCStd and b/cad/sourced/UHP-200A.FCStd differ diff --git a/cad/sourced/WAGO_2002-1201.FCStd b/cad/sourced/WAGO_2002-1201.FCStd new file mode 100644 index 0000000..4505908 Binary files /dev/null and b/cad/sourced/WAGO_2002-1201.FCStd differ diff --git a/scripts/generate_3mf_files.py b/scripts/generate_3mf_files.py index 1ce3f75..9e47491 100755 --- a/scripts/generate_3mf_files.py +++ b/scripts/generate_3mf_files.py @@ -5,14 +5,15 @@ import FreeCAD # type: ignore import Mesh # type: ignore # Define the project root directory -project_root = os.path.abspath( - os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir) -) +project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) # Define the directories for CAD files and 3MF export files printed_cad_dir = os.path.join(project_root, "cad", "printed") printed_3mf_dir = os.path.join(project_root, "3mf") +# Create the 3mf directory if it doesn't exist +os.makedirs(printed_3mf_dir, exist_ok=True) + # List to keep track of files that failed to export failed_files = [] @@ -23,43 +24,39 @@ for root, dirs, files in os.walk(printed_cad_dir): # Absolute path of the CAD file file_path = os.path.join(root, file) - # Abslute path for the exported 3MF file - output_path = os.path.join( - printed_3mf_dir, os.path.relpath(file_path, printed_cad_dir) - ).replace(".FCStd", ".3mf") + FreeCAD.Console.PrintMessage(f"\nProcessing {file_path}\n") - # Create the output directory if it doesn't already exist - os.makedirs(os.path.dirname(output_path), exist_ok=True) - - FreeCAD.Console.PrintMessage(f"\nExporting {file_path}\n") - - # Open the FreeCAD document and recompute it + # Open the FreeCAD document doc = FreeCAD.openDocument(file_path) FreeCAD.setActiveDocument(doc.Name) FreeCAD.ActiveDocument.recompute() - # Get the body object from the document - body = doc.getObject("Body") - if body is None: - FreeCAD.Console.PrintError(f"No 'Body' found in {file}\n") - FreeCAD.closeDocument(doc.Name) - failed_files.append(file_path) - continue + # Iterate over all objects in the document + for obj in doc.Objects: + # Check if the object is Std_Part + if obj.TypeId == 'App::Part': + # Construct the output path for the 3MF file using the label + output_path = os.path.join( + printed_3mf_dir, os.path.relpath(root, printed_cad_dir), f"{obj.Label}.3mf" + ) + # Create the output directory if it doesn't already exist + os.makedirs(os.path.dirname(output_path), exist_ok=True) - # Try to export the body to a 3MF file - try: - Mesh.export([body], output_path) - except Exception as e: - FreeCAD.Console.PrintError(f"Error exporting {file}: {e}\n") - failed_files.append(file_path) + try: + # Export the part to a 3MF file + Mesh.export([obj], output_path) + FreeCAD.Console.PrintMessage(f"Exported {obj.Label} to {output_path}\n") + except Exception as e: + FreeCAD.Console.PrintError(f"Error exporting {obj.Label}: {e}\n") + failed_files.append(file_path) # Close the FreeCAD document FreeCAD.closeDocument(doc.Name) -# Print the result of the export and the files that failed +# Print the result of the export process if failed_files: FreeCAD.Console.PrintError("\nThe following files failed to export:\n") for file in failed_files: FreeCAD.Console.PrintError(f" - {file}\n") else: - FreeCAD.Console.PrintMessage("\nAll files have been exported successfully.\n") + FreeCAD.Console.PrintMessage("\nAll files have been exported successfully.\n") \ No newline at end of file