-
Notifications
You must be signed in to change notification settings - Fork 3
/
VEX CAD Library.py
143 lines (122 loc) · 4.89 KB
/
VEX CAD Library.py
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import os
import sys
import adsk.core
import traceback
app_path = os.path.dirname(__file__)
sys.path.insert(0, app_path)
sys.path.insert(0, os.path.join(app_path, 'apper'))
# Set to True to use beta and development features
developmentFeatures = True
unreleasedFeatures = False
# Set to True to display various useful messages when debugging
debug = False
# global addin
try:
import config
import apper
from .commands.ModifyPart import ModifyPart
from .commands.ModifyPart import ModifyPartExternalCommandStarted
from .commands.ModifyPart import ModifyPartExternalCommandEnded
from .commands.SimpleJoint import SimpleJoint
from .commands.SetAttributes import SetAttributes
from .commands.ViewAttributes import ViewAttributes
from .commands.ShowJointOriginsByBoundingBox import ShowJointOriginsByBoundingBox
from .commands.PointsToJointOrigins import PointsToJointOrigins
app = adsk.core.Application.cast(adsk.core.Application.get())
ui = app.userInterface
# Create addin definition object
# global addin
addin = apper.FusionApp('VEX CAD Library', 'VEX CAD', False)
addin.add_command(
'Modify Part',
ModifyPart,
{
'cmd_description': 'Modify parametric parts from the VEX CAD Library.\n\nSelect part component and change parameters.',
'cmd_id': 'modify_part',
'workspace': 'FusionSolidEnvironment',
'toolbar_panel_id': 'Modify',
'cmd_resources': 'command_icons/press_pull',
'command_visible': True,
'command_promoted': True,
}
)
addin.add_command_event("FusionImportCommandStartedEvent", app.userInterface.commandStarting, ModifyPartExternalCommandStarted)
addin.add_command_event("FusionMoveCommandEndedEvent", app.userInterface.commandTerminated, ModifyPartExternalCommandEnded)
if developmentFeatures:
addin.add_command(
'Set Attributes',
SetAttributes,
{
'cmd_description': 'Set custom attributes for parts from the VEX CAD Library.\n\nSelect part component and input valid JSON string.',
'cmd_id': 'set_attributes',
'workspace': 'FusionSolidEnvironment',
'toolbar_panel_id': 'Development',
'cmd_resources': 'command_icons/edit',
'command_visible': True,
'command_promoted': True,
}
)
addin.add_command(
'View Attributes',
ViewAttributes,
{
'cmd_description': 'View custom attributes for parts from the VEX CAD Library.',
'cmd_id': 'view_attributes',
'workspace': 'FusionSolidEnvironment',
'toolbar_panel_id': 'Development',
'cmd_resources': 'command_icons/attributes',
'command_visible': True,
'command_promoted': True,
}
)
if unreleasedFeatures:
addin.add_command(
'Simple Joint (beta)',
SimpleJoint,
{
'cmd_description': 'An easier to use joint tool for connecting VEX parts',
'cmd_id': 'simple_joint',
'workspace': 'FusionSolidEnvironment',
'toolbar_panel_id': 'Assemble',
'cmd_resources': 'command_icons/joint',
'command_visible': True,
'command_promoted': True,
}
)
addin.add_command(
'Points to Joint Origins',
PointsToJointOrigins,
{
'cmd_description': 'Set custom attributes for parts from the VEX CAD Library.\n\nSelect part component and input valid JSON string.',
'cmd_id': 'points_to_joint_origins',
'workspace': 'FusionSolidEnvironment',
'toolbar_panel_id': 'Advanced',
'cmd_resources': 'command_icons/joint_origin',
'command_visible': True,
'command_promoted': True,
}
)
addin.add_command(
'Show Joint Origins by Bounding Box',
ShowJointOriginsByBoundingBox,
{
'cmd_description': 'Set custom attributes for parts from the VEX CAD Library.\n\nSelect part component and input valid JSON string.',
'cmd_id': 'show_joint_origins_by_bounding_box',
'workspace': 'FusionSolidEnvironment',
'toolbar_panel_id': 'Modify',
'cmd_resources': 'command_icons/joint_origin',
'command_visible': True,
'command_promoted': True,
}
)
except:
app = adsk.core.Application.get()
ui = app.userInterface
if ui:
ui.messageBox('Initialization: {}'.format(traceback.format_exc()))
def run(context):
addin.run_app()
def stop(context):
addin.stop_app()
sys.path.pop(0)
sys.path.pop(0)