diff --git a/resources/preferences/KindredCreate/KindredCreate.cfg b/resources/preferences/KindredCreate/KindredCreate.cfg index 5714f860f7..4601efe882 100644 --- a/resources/preferences/KindredCreate/KindredCreate.cfg +++ b/resources/preferences/KindredCreate/KindredCreate.cfg @@ -76,6 +76,9 @@ + + ZToolsWorkbench + KindredCreate.qss diff --git a/src/Mod/CMakeLists.txt b/src/Mod/CMakeLists.txt index e07921e12a..69f4066564 100644 --- a/src/Mod/CMakeLists.txt +++ b/src/Mod/CMakeLists.txt @@ -1,3 +1,7 @@ +# Kindred Create core module - always built +# Handles auto-loading of ztools and Silo addons +add_subdirectory(Create) + if(BUILD_ADDONMGR) if( NOT EXISTS "${CMAKE_SOURCE_DIR}/src/Mod/AddonManager/CMakeLists.txt" ) message(FATAL_ERROR "The Addon Manager has been moved into a git submodule. Please run diff --git a/src/Mod/Create/CMakeLists.txt b/src/Mod/Create/CMakeLists.txt new file mode 100644 index 0000000000..7a735433d4 --- /dev/null +++ b/src/Mod/Create/CMakeLists.txt @@ -0,0 +1,39 @@ +# Kindred Create core module +# Handles auto-loading of ztools and Silo addons + +# Install Python init files +install( + FILES + Init.py + InitGui.py + DESTINATION + Mod/Create +) + +# Install ztools addon +install( + DIRECTORY + ${CMAKE_SOURCE_DIR}/mods/ztools/ztools + DESTINATION + mods/ztools +) +install( + DIRECTORY + ${CMAKE_SOURCE_DIR}/mods/ztools/CatppuccinMocha + DESTINATION + mods/ztools +) +install( + FILES + ${CMAKE_SOURCE_DIR}/mods/ztools/package.xml + DESTINATION + mods/ztools +) + +# Install Silo addon +install( + DIRECTORY + ${CMAKE_SOURCE_DIR}/mods/silo/pkg/freecad/ + DESTINATION + mods/silo/pkg/freecad +) diff --git a/src/Mod/Create/Init.py b/src/Mod/Create/Init.py new file mode 100644 index 0000000000..deeab6d34e --- /dev/null +++ b/src/Mod/Create/Init.py @@ -0,0 +1,45 @@ +# Kindred Create - Core Module +# Console initialization - loads ztools and Silo addons + +import os +import sys + +import FreeCAD + + +def setup_kindred_addons(): + """Add Kindred Create addon paths and load their Init.py files.""" + # Get the FreeCAD home directory (where src/Mod/Create is installed) + home = FreeCAD.getHomePath() + mods_dir = os.path.join(home, "mods") + + # Define built-in addons with their paths relative to mods/ + addons = [ + ("ztools", "ztools/ztools"), # mods/ztools/ztools/ + ("silo", "silo/pkg/freecad"), # mods/silo/pkg/freecad/ + ] + + for name, subpath in addons: + addon_path = os.path.join(mods_dir, subpath) + if os.path.isdir(addon_path): + # Add to sys.path if not already present + if addon_path not in sys.path: + sys.path.insert(0, addon_path) + + # Execute Init.py if it exists + init_file = os.path.join(addon_path, "Init.py") + if os.path.isfile(init_file): + try: + with open(init_file) as f: + exec(compile(f.read(), init_file, "exec")) + FreeCAD.Console.PrintLog(f"Create: Loaded {name} Init.py\n") + except Exception as e: + FreeCAD.Console.PrintWarning( + f"Create: Failed to load {name}: {e}\n" + ) + else: + FreeCAD.Console.PrintLog(f"Create: Addon path not found: {addon_path}\n") + + +setup_kindred_addons() +FreeCAD.Console.PrintLog("Create module initialized\n") diff --git a/src/Mod/Create/InitGui.py b/src/Mod/Create/InitGui.py new file mode 100644 index 0000000000..d5ac7ab0d8 --- /dev/null +++ b/src/Mod/Create/InitGui.py @@ -0,0 +1,42 @@ +# Kindred Create - Core Module +# GUI initialization - loads ztools and Silo workbenches + +import os +import sys + +import FreeCAD +import FreeCADGui + + +def setup_kindred_workbenches(): + """Load Kindred Create addon workbenches.""" + home = FreeCAD.getHomePath() + mods_dir = os.path.join(home, "mods") + + addons = [ + ("ztools", "ztools/ztools"), + ("silo", "silo/pkg/freecad"), + ] + + for name, subpath in addons: + addon_path = os.path.join(mods_dir, subpath) + if os.path.isdir(addon_path): + # Ensure path is in sys.path + if addon_path not in sys.path: + sys.path.insert(0, addon_path) + + # Execute InitGui.py if it exists + init_gui_file = os.path.join(addon_path, "InitGui.py") + if os.path.isfile(init_gui_file): + try: + with open(init_gui_file) as f: + exec(compile(f.read(), init_gui_file, "exec")) + FreeCAD.Console.PrintLog(f"Create: Loaded {name} workbench\n") + except Exception as e: + FreeCAD.Console.PrintWarning( + f"Create: Failed to load {name} GUI: {e}\n" + ) + + +setup_kindred_workbenches() +FreeCAD.Console.PrintLog("Create GUI module initialized\n")