Files
create/src/Mod/Create/Init.py
forbes dbac82e731 Fix silo loading and add integration enhancements
Fix the exec() calls in Create module's Init.py and InitGui.py to pass
__file__ and __name__ in the globals dict. The silo workbench code uses
__file__ to resolve icon paths, but exec() without explicit globals
does not provide it, causing 'name __file__ is not defined' errors.

Also add three silo integration enhancements to InitGui.py:
- First-startup check: launches Silo_Settings dialog if API URL is not
  configured on first run
- File menu injection: WorkbenchManipulator inserts Silo Open, Save,
  and Commit commands into the File menu across all workbenches
- Database activity panel: dock widget showing recent silo items,
  displayed on the right side of the main window
2026-01-29 20:57:39 -06:00

49 lines
1.7 KiB
Python

# 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")