-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet_Path.py
More file actions
71 lines (54 loc) · 1.65 KB
/
Get_Path.py
File metadata and controls
71 lines (54 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2025-2026 <Jochen Zeitler>
"""
Simple helper functions for resource paths
"""
import os
import FreeCAD
def get_root():
"""Get the root directory of the workbench"""
return os.path.dirname(os.path.abspath(__file__))
def get_icon(name):
"""
Get icon path from resources/icons folder
Works from any subfolder
Args:
name: Icon filename (e.g., "Load GDS.png")
Returns:
Full path to icon file
"""
icon_path = os.path.join(get_root(), "resources", "icons", name)
if os.path.exists(icon_path):
return icon_path
else:
FreeCAD.Console.PrintWarning(f"Icon not found: {icon_path}\n")
return ""
def get_html(name):
"""
Get HTML file path from resources/html folder
Args:
name: HTML filename (e.g., "overview.html")
Returns:
Full path to HTML file
"""
html_path = os.path.join(get_root(), "resources", "html", name)
if os.path.exists(html_path):
return html_path
else:
FreeCAD.Console.PrintWarning(f"HTML file not found: {html_path}\n")
return ""
def get_resource(resource_type, name):
"""
Get any resource file path
Args:
resource_type: Subfolder in resources (e.g., "icons", "html")
name: Filename
Returns:
Full path to resource file
"""
resource_path = os.path.join(get_root(), "resources", resource_type, name)
if os.path.exists(resource_path):
return resource_path
else:
FreeCAD.Console.PrintWarning(f"Resource not found: {resource_path}\n")
return ""