pyjallib 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,358 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from pymxs import runtime as rt
5
+
6
+ from PySide2 import QtWidgets, QtCore, QtGui
7
+ import gc # Import garbage collector
8
+
9
+ class BoneNameDialog(QtWidgets.QDialog):
10
+ def __init__(self, parent=QtWidgets.QWidget.find(rt.windows.getMAXHWND())):
11
+ super().__init__(parent)
12
+ self.boneNameSetted = False
13
+ self.baseName = ""
14
+ self.sideName = ""
15
+ self.frontBackName = ""
16
+ self.RealName = ""
17
+ self.filteringChar = " "
18
+ self.boneName = ""
19
+
20
+ self.setWindowTitle("Bone Name")
21
+ self.setMinimumWidth(300)
22
+
23
+ # Layouts
24
+ main_layout = QtWidgets.QVBoxLayout(self)
25
+ grid_layout = QtWidgets.QGridLayout()
26
+ radio_button_layout = QtWidgets.QHBoxLayout()
27
+ button_layout = QtWidgets.QHBoxLayout()
28
+
29
+ # Widgets
30
+ # Base Name
31
+ base_name_label = QtWidgets.QLabel("Base Name:")
32
+ self.base_name_edit = QtWidgets.QLineEdit("Bip001")
33
+ self.base_name_edit.setReadOnly(True)
34
+ self.base_name_combo = QtWidgets.QComboBox() # Placeholder for dropdown
35
+ comboItems = jal.name.get_name_part_predefined_values("Base")
36
+ comboItems.insert(0, "")
37
+ self.base_name_combo.addItems(comboItems)
38
+ self.base_name_combo.setCurrentIndex(2) # Set default index to 0
39
+
40
+ # Name
41
+ name_label = QtWidgets.QLabel("Name:")
42
+ self.name_edit = QtWidgets.QLineEdit("TempBone")
43
+
44
+ # Side Radio Buttons
45
+ side_group = QtWidgets.QGroupBox("Side:")
46
+ side_layout = QtWidgets.QVBoxLayout()
47
+ self.side_none_radio = QtWidgets.QRadioButton("(None)")
48
+ self.side_l_radio = QtWidgets.QRadioButton("L")
49
+ self.side_r_radio = QtWidgets.QRadioButton("R")
50
+ self.side_none_radio.setChecked(True)
51
+ side_layout.addWidget(self.side_none_radio)
52
+ side_layout.addWidget(self.side_l_radio)
53
+ side_layout.addWidget(self.side_r_radio)
54
+ side_group.setLayout(side_layout)
55
+
56
+ # Front Radio Buttons
57
+ front_group = QtWidgets.QGroupBox("Front:")
58
+ front_layout = QtWidgets.QVBoxLayout()
59
+ self.front_none_radio = QtWidgets.QRadioButton("(None)")
60
+ self.front_f_radio = QtWidgets.QRadioButton("F")
61
+ self.front_b_radio = QtWidgets.QRadioButton("B")
62
+ self.front_none_radio.setChecked(True)
63
+ front_layout.addWidget(self.front_none_radio)
64
+ front_layout.addWidget(self.front_f_radio)
65
+ front_layout.addWidget(self.front_b_radio)
66
+ front_group.setLayout(front_layout)
67
+
68
+ # Filtering Radio Buttons
69
+ filtering_group = QtWidgets.QGroupBox("Filtering:")
70
+ filtering_layout = QtWidgets.QVBoxLayout()
71
+ self.filter_blank_radio = QtWidgets.QRadioButton("(Blank)")
72
+ self.filter_underBar_radio = QtWidgets.QRadioButton("_")
73
+ self.filter_blank_radio.setChecked(True)
74
+ filtering_layout.addWidget(self.filter_blank_radio)
75
+ filtering_layout.addWidget(self.filter_underBar_radio)
76
+ filtering_group.setLayout(filtering_layout)
77
+
78
+ # Result
79
+ result_label = QtWidgets.QLabel("Result:")
80
+ self.result_edit = QtWidgets.QLineEdit("Bip001 TempBone 0")
81
+ self.result_edit.setReadOnly(True) # Make result read-only
82
+
83
+ # OK/Cancel Buttons
84
+ self.ok_button = QtWidgets.QPushButton("OK")
85
+ self.cancel_button = QtWidgets.QPushButton("Cancel")
86
+
87
+ # Arrange Widgets in Grid Layout
88
+ grid_layout.addWidget(base_name_label, 0, 0)
89
+ grid_layout.addWidget(self.base_name_edit, 0, 1)
90
+ grid_layout.addWidget(self.base_name_combo, 1, 1) # Dropdown below Base Name
91
+ grid_layout.addWidget(name_label, 2, 0)
92
+ grid_layout.addWidget(self.name_edit, 2, 1)
93
+
94
+ # Arrange Radio Button Groups
95
+ radio_button_layout.addWidget(side_group)
96
+ radio_button_layout.addWidget(front_group)
97
+ radio_button_layout.addWidget(filtering_group)
98
+
99
+ # Arrange Buttons
100
+ button_layout.addStretch()
101
+ button_layout.addWidget(self.ok_button)
102
+ button_layout.addWidget(self.cancel_button)
103
+
104
+ # Add layouts to main layout
105
+ main_layout.addLayout(grid_layout)
106
+ main_layout.addLayout(radio_button_layout)
107
+ main_layout.addWidget(result_label)
108
+ main_layout.addWidget(self.result_edit)
109
+ main_layout.addStretch()
110
+ main_layout.addLayout(button_layout)
111
+
112
+ # Connect signals
113
+ self.ok_button.clicked.connect(self.ok_clicked)
114
+ self.cancel_button.clicked.connect(self.cancel_clicked)
115
+
116
+ # Connect all relevant UI changes to the update method
117
+ self.base_name_combo.currentTextChanged.connect(self.update_ui)
118
+ self.name_edit.textChanged.connect(self.update_ui)
119
+ self.side_none_radio.toggled.connect(self.update_ui)
120
+ self.side_l_radio.toggled.connect(self.update_ui)
121
+ self.side_r_radio.toggled.connect(self.update_ui)
122
+ self.front_none_radio.toggled.connect(self.update_ui)
123
+ self.front_f_radio.toggled.connect(self.update_ui)
124
+ self.front_b_radio.toggled.connect(self.update_ui)
125
+ self.filter_blank_radio.toggled.connect(self.update_ui)
126
+ self.filter_underBar_radio.toggled.connect(self.update_ui)
127
+
128
+ self.update_ui() # Initial update to set the result field
129
+
130
+ def update_ui(self):
131
+ self.base_name_edit.setText(self.base_name_combo.currentText())
132
+ self.baseName = self.base_name_edit.text()
133
+
134
+ if self.side_none_radio.isChecked():
135
+ self.sideName = ""
136
+ elif self.side_l_radio.isChecked():
137
+ self.sideName = "L"
138
+ elif self.side_r_radio.isChecked():
139
+ self.sideName = "R"
140
+
141
+ if self.front_none_radio.isChecked():
142
+ self.frontBackName = ""
143
+ elif self.front_f_radio.isChecked():
144
+ self.frontBackName = "F"
145
+ elif self.front_b_radio.isChecked():
146
+ self.frontBackName = "B"
147
+
148
+ RealName = self.name_edit.text() if self.name_edit.text() != "" else "TempBone"
149
+
150
+ if self.filter_blank_radio.isChecked():
151
+ self.filteringChar = " "
152
+ elif self.filter_underBar_radio.isChecked():
153
+ self.filteringChar = "_"
154
+
155
+ finalName = jal.name.combine(
156
+ inPartsDict={
157
+ "Base":self.baseName,
158
+ "Type":"",
159
+ "Side":self.sideName,
160
+ "FrontBack":self.frontBackName,
161
+ "RealName":RealName,
162
+ "Index":"00"
163
+ },
164
+ inFilChar=self.filteringChar
165
+ )
166
+ self.result_edit.setText(finalName)
167
+ self.boneName = finalName
168
+
169
+ def ok_clicked(self):
170
+ self.update_ui()
171
+
172
+ existingBoneNum = 0
173
+ nameCheckBoneArray = [item for item in rt.objects if rt.classOf(item) == rt.BoneGeometry]
174
+ namePattern = jal.name.get_string(self.boneName) + self.filteringChar
175
+ for item in nameCheckBoneArray:
176
+ if (item.name.startswith(namePattern)):
177
+ existingBoneNum += 1
178
+
179
+ if existingBoneNum > 0:
180
+ QtWidgets.QMessageBox.warning(None, "Warning", "Same Name Bone Exist!")
181
+ self.boneNameSetted = False
182
+ else:
183
+ self.boneNameSetted = True
184
+ self.accept()
185
+
186
+ def cancel_clicked(self):
187
+ self.boneNameSetted = False
188
+ self.reject()
189
+
190
+ def jal_bone_on():
191
+ jal.bone.set_bone_on_selection()
192
+
193
+ def jal_bone_off():
194
+ jal.bone.set_bone_off_selection()
195
+
196
+ def jal_bone_length_freeze_on():
197
+ jal.bone.set_freeze_length_on_selection()
198
+
199
+ def jal_bone_length_freeze_off():
200
+ jal.bone.set_freeze_length_off_selection()
201
+
202
+ def jal_bone_fin_on():
203
+ sel_array = rt.getCurrentSelection()
204
+ if len(sel_array) > 0:
205
+ for item in sel_array:
206
+ jal.bone.set_fin_on(item)
207
+
208
+ def jal_bone_fin_off():
209
+ sel_array = rt.getCurrentSelection()
210
+ if len(sel_array) > 0:
211
+ for item in sel_array:
212
+ jal.bone.set_fin_off(item)
213
+
214
+ def jal_bone_reset_scale():
215
+ sel_array = rt.getCurrentSelection()
216
+ for item in sel_array:
217
+ if rt.classOf(item) == rt.BoneGeometry:
218
+ if item.children.count == 1:
219
+ item.realignBoneToChild()
220
+ jal.bone.correct_negative_stretch(item, True)
221
+ item.ResetBoneStretch()
222
+
223
+ jal.bone.reset_scale_of_selected_bones(True)
224
+
225
+ def jal_bone_create():
226
+ selArray = rt.getCurrentSelection()
227
+ simpleBoneLength = 5
228
+
229
+ dialog = BoneNameDialog()
230
+ result = dialog.exec_()
231
+
232
+ # Store dialog values in external variables
233
+ boneNameSetted = dialog.boneNameSetted
234
+ boneName = dialog.boneName
235
+ filteringChar = dialog.filteringChar
236
+
237
+ # Now you can use boneNameSetted and boneName variables
238
+ if boneNameSetted:
239
+ if len(selArray) == 0 or len(selArray) == 1:
240
+ genBoneArray = jal.bone.create_simple_bone(simpleBoneLength, boneName)
241
+ for item in genBoneArray:
242
+ item.name = jal.name.replace_filtering_char(item.name, filteringChar)
243
+ if len(selArray) == 1:
244
+ genBoneArray[0].transform = selArray[0].transform
245
+ elif len(selArray) > 1:
246
+ genBoneArray = jal.bone.create_bone(selArray, boneName, delPoint=True)
247
+ for item in genBoneArray:
248
+ item.name = jal.name.replace_filtering_char(item.name, filteringChar)
249
+
250
+ # Explicitly delete the dialog and force garbage collection
251
+ dialog.deleteLater()
252
+ dialog = None
253
+ gc.collect() # Force garbage collection
254
+
255
+ def jal_bone_nub_create():
256
+ sel_array = rt.getCurrentSelection()
257
+ if len(sel_array) > 0:
258
+ last_bone_array = []
259
+ non_bone_array = []
260
+
261
+ for item in sel_array:
262
+ if rt.classOf(item) == rt.BoneGeometry:
263
+ last_bone_array.append(item)
264
+ else:
265
+ non_bone_array.append(item)
266
+
267
+ for item in last_bone_array:
268
+ if item.children.count == 0:
269
+ jal.bone.create_end_bone(item)
270
+
271
+ for item in non_bone_array:
272
+ jal.bone.create_nub_bone_on_obj(item)
273
+ else:
274
+ jal.bone.create_nub_bone("Temp Nub", 2)
275
+
276
+ # Register macroscripts
277
+ macroScript_Category = "jalTools"
278
+
279
+ rt.jal_bone_on = jal_bone_on
280
+ rt.macros.new(
281
+ macroScript_Category,
282
+ "jal_boneOn",
283
+ "Bone On Selection",
284
+ "Bone On Selection",
285
+ "jal_bone_on()"
286
+ )
287
+
288
+ rt.jal_bone_off = jal_bone_off
289
+ rt.macros.new(
290
+ macroScript_Category,
291
+ "jal_boneOff",
292
+ "Bone Off Selection",
293
+ "Bone Off Selection",
294
+ "jal_bone_off()"
295
+ )
296
+
297
+ rt.jal_bone_length_freeze_on = jal_bone_length_freeze_on
298
+ rt.macros.new(
299
+ macroScript_Category,
300
+ "jal_boneLengthFreezeOn",
301
+ "Bone Length Freeze On Selection",
302
+ "Bone Length Freeze On Selectionn",
303
+ "jal_bone_length_freeze_on()"
304
+ )
305
+
306
+ rt.jal_bone_length_freeze_off = jal_bone_length_freeze_off
307
+ rt.macros.new(
308
+ macroScript_Category,
309
+ "jal_boneLengthFreezeOff",
310
+ "Bone Length Freeze Off Selection",
311
+ "Bone Length Freeze Off Selection",
312
+ "jal_bone_length_freeze_off()"
313
+ )
314
+
315
+ rt.jal_bone_fin_on = jal_bone_fin_on
316
+ rt.macros.new(
317
+ macroScript_Category,
318
+ "jal_boneFinOn",
319
+ "Bone Fin On",
320
+ "Bone Fin On",
321
+ "jal_bone_fin_on()"
322
+ )
323
+
324
+ rt.jal_bone_fin_off = jal_bone_fin_off
325
+ rt.macros.new(
326
+ macroScript_Category,
327
+ "jal_boneFinOff",
328
+ "Bone Fin Off",
329
+ "Bone Fin Off",
330
+ "jal_bone_fin_off()"
331
+ )
332
+
333
+ rt.jal_bone_reset_scale = jal_bone_reset_scale
334
+ rt.macros.new(
335
+ macroScript_Category,
336
+ "jal_boneResetScale",
337
+ "Bone Reset Scale",
338
+ "Bone Reset Scale",
339
+ "jal_bone_reset_scale()"
340
+ )
341
+
342
+ rt.jal_bone_create = jal_bone_create
343
+ rt.macros.new(
344
+ macroScript_Category,
345
+ "jal_boneCreate",
346
+ "Bone Create",
347
+ "Bone Create",
348
+ "jal_bone_create()"
349
+ )
350
+
351
+ rt.jal_bone_nub_create = jal_bone_nub_create
352
+ rt.macros.new(
353
+ macroScript_Category,
354
+ "jal_boneNubCreate",
355
+ "Bone Nub Create",
356
+ "Bone Nub Create",
357
+ "jal_bone_nub_create()"
358
+ )
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from pymxs import runtime as rt
5
+
6
+ def jal_collapse_const():
7
+ if rt.selection.count > 0:
8
+ selArray = rt.getCurrentSelection()
9
+ for selObj in selArray:
10
+ jal.constraint.collapse(selObj)
11
+
12
+ def jal_pos_const():
13
+ if rt.selection.count > 1:
14
+ selArray = rt.getCurrentSelection()
15
+ oriObj = selArray[0] # Python uses 0-based indexing
16
+ targetObjArray = []
17
+
18
+ # Add all objects except the first one to targetObjArray
19
+ for i in range(1, len(selArray)):
20
+ targetObjArray.append(selArray[i])
21
+
22
+ jal.constraint.assign_pos_const_multi(oriObj, targetObjArray)
23
+
24
+ def jal_ori_const():
25
+ if rt.selection.count > 1:
26
+ selArray = rt.getCurrentSelection()
27
+ oriObj = selArray[0] # Python uses 0-based indexing
28
+ targetObjArray = []
29
+
30
+ # Add all objects except the first one to targetObjArray
31
+ for i in range(1, len(selArray)):
32
+ targetObjArray.append(selArray[i])
33
+
34
+ jal.constraint.assign_rot_const_multi(oriObj, targetObjArray)
35
+
36
+ def jal_rot_script_const():
37
+ if rt.selection.count == 2:
38
+ selArray = rt.getCurrentSelection()
39
+ oriObj = selArray[0]
40
+ targetObj = selArray[1]
41
+
42
+ jal.constraint.assign_rot_const_scripted(oriObj, targetObj)
43
+
44
+ def jal_lookat_const():
45
+ if rt.selection.count > 1:
46
+ selArray = rt.getCurrentSelection()
47
+ oriObj = selArray[0] # Python uses 0-based indexing
48
+ targetObjArray = []
49
+
50
+ # Add all objects except the first one to targetObjArray
51
+ for i in range(1, len(selArray)):
52
+ targetObjArray.append(selArray[i])
53
+
54
+ jal.constraint.assign_lookat_multi(oriObj, targetObjArray)
55
+
56
+ def jal_lookat_flipless_const():
57
+ if rt.selection.count == 2:
58
+ selArray = rt.getCurrentSelection()
59
+ oriObj = selArray[0]
60
+ targetObj = selArray[1]
61
+
62
+ jal.constraint.assign_lookat_flipless(oriObj, targetObj)
63
+
64
+ def jal_lookat_script_const():
65
+ if rt.selection.count > 1:
66
+ selArray = rt.getCurrentSelection()
67
+ oriObj = selArray[0] # Python uses 0-based indexing
68
+ targetObjArray = []
69
+
70
+ # Add all objects except the first one to targetObjArray
71
+ for i in range(1, len(selArray)):
72
+ targetObjArray.append(selArray[i])
73
+
74
+ jal.constraint.assign_scripted_lookat(oriObj, targetObjArray)
75
+
76
+ # Register macroscripts
77
+ macroScript_Category = "jalTools"
78
+
79
+ rt.jal_collapse_const = jal_collapse_const
80
+ rt.macros.new(
81
+ macroScript_Category,
82
+ "jal_collapse_const",
83
+ "Collapse Constraints",
84
+ "Collapse Constraints",
85
+ "jal_collapse_const()"
86
+ )
87
+
88
+ rt.jal_pos_const = jal_pos_const
89
+ rt.macros.new(
90
+ macroScript_Category,
91
+ "jal_pos_const",
92
+ "Constraint Position",
93
+ "Constraint Position",
94
+ "jal_pos_const()"
95
+ )
96
+
97
+ rt.jal_ori_const = jal_ori_const
98
+ rt.macros.new(
99
+ macroScript_Category,
100
+ "jal_ori_const",
101
+ "Constraint Orientation",
102
+ "Constraint Orientation",
103
+ "jal_ori_const()"
104
+ )
105
+
106
+ rt.jal_rot_script_const = jal_rot_script_const
107
+ rt.macros.new(
108
+ macroScript_Category,
109
+ "jal_rot_script_const",
110
+ "Constraint Rotation Script",
111
+ "Constraint Rotation Script",
112
+ "jal_rot_script_const()"
113
+ )
114
+
115
+ rt.jal_lookat_const = jal_lookat_const
116
+ rt.macros.new(
117
+ macroScript_Category,
118
+ "jal_lookat_const",
119
+ "Constraint LookAt",
120
+ "Constraint LookAt",
121
+ "jal_lookat_const()"
122
+ )
123
+
124
+ rt.jal_lookat_flipless_const = jal_lookat_flipless_const
125
+ rt.macros.new(
126
+ macroScript_Category,
127
+ "jal_lookat_flipless_const",
128
+ "Constraint LookAt Flipless",
129
+ "Constraint LookAt Flipless",
130
+ "jal_lookat_flipless_const()"
131
+ )
132
+
133
+ rt.jal_lookat_script_const = jal_lookat_script_const
134
+ rt.macros.new(
135
+ macroScript_Category,
136
+ "jal_lookat_script_const",
137
+ "Constraint LookAt Script",
138
+ "Constraint LookAt Script",
139
+ "jal_lookat_script_const()"
140
+ )