# 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_globals = globals().copy() exec_globals["__file__"] = init_file exec_globals["__name__"] = name exec(compile(f.read(), init_file, "exec"), exec_globals) 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")