Skip to content
This repository was archived by the owner on Jul 21, 2024. It is now read-only.

Commit 09f0349

Browse files
Bugs chasing in model creation
Thanks to @regulus_Fen for pointing them out while trying to create his own model.
1 parent 6e5979f commit 09f0349

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

jointscreator.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ def save_joints_base_file():
224224
# --------------------------------------------------
225225
current_joint_central_point = None
226226

227+
def create_current_joint_central_point():
228+
global current_joint_central_point
229+
mesh = bpy.data.meshes.new('Basic_Sphere')
230+
current_joint_central_point = bpy.data.objects.new("Joint center", mesh)
231+
bm = bmesh.new()
232+
bmesh.ops.create_uvsphere(bm, u_segments=4, v_segments=4, diameter=0.004)
233+
bm.to_mesh(mesh)
234+
bm.free()
235+
file_ops.link_to_collection(current_joint_central_point)
236+
current_joint_central_point.hide_select = True
237+
238+
227239
def show_central_point(hist):
228240
global current_joints_base_file
229241
global current_joint_central_point
@@ -240,14 +252,7 @@ def show_central_point(hist):
240252
# Now we have all vertices, we compute the average center
241253
central_point = algorithms.average_center(vertices)
242254
if current_joint_central_point == None:
243-
mesh = bpy.data.meshes.new('Basic_Sphere')
244-
current_joint_central_point = bpy.data.objects.new("Joint center", mesh)
245-
bm = bmesh.new()
246-
bmesh.ops.create_uvsphere(bm, u_segments=4, v_segments=4, diameter=0.004)
247-
bm.to_mesh(mesh)
248-
bm.free()
249-
file_ops.link_to_collection(current_joint_central_point)
250-
current_joint_central_point.hide_select = True
255+
create_current_joint_central_point()
251256
current_joint_central_point.location = (central_point.x, central_point.y, central_point.z)
252257

253258
# --------------------------------------------------
@@ -346,6 +351,8 @@ def show_offset_point(hist):
346351
if current_offset_point == None:
347352
create_offset_point()
348353
co = file[hist.name]
354+
if current_joint_central_point == None: # It happens.
355+
create_current_joint_central_point()
349356
vect = current_joint_central_point.location
350357
current_offset_point.location = (
351358
vect.x + co[0],
@@ -407,6 +414,8 @@ def set_offset_point():
407414
for key, item in current_joints_offset_file.items():
408415
file = item
409416
# Now we calculate de relative location of the offset
417+
if current_joint_central_point == None: # Security.
418+
create_current_joint_central_point()
410419
center_point = current_joint_central_point.location
411420
offset_point = current_offset_point.location
412421
file[hist.name] = [

measurescreator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def get_two_points(direction=0):
393393
two_points_index += 1
394394
if two_points_index >= len(measures_parts_points):
395395
two_points_index = 0
396-
if two_points_index >= measures_parts_points: # It happens
396+
if two_points_index >= len(measures_parts_points): # It happens
397397
two_points_index = len(measures_parts_points)-1
398398
measure_name = measures_parts_points[two_points_index]
399399
# Now we seek and keep the values in the MeshHandling.
@@ -428,7 +428,7 @@ def get_girth(direction=0):
428428
girth_index += 1
429429
if girth_index >= len(measures_parts_girths):
430430
girth_index = 0
431-
if girth_index >= measures_parts_girths: # It happens
431+
if girth_index >= len(measures_parts_girths): # It happens
432432
girth_index = len(measures_parts_girths)-1
433433
measure_name = measures_parts_girths[girth_index]
434434
# Now we seek and keep the values in the MeshHandling.

0 commit comments

Comments
 (0)