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

Bugs chasing in model creation #332

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions jointscreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ def save_joints_base_file():
# --------------------------------------------------
current_joint_central_point = None

def create_current_joint_central_point():
global current_joint_central_point
mesh = bpy.data.meshes.new('Basic_Sphere')
current_joint_central_point = bpy.data.objects.new("Joint center", mesh)
bm = bmesh.new()
bmesh.ops.create_uvsphere(bm, u_segments=4, v_segments=4, diameter=0.004)
bm.to_mesh(mesh)
bm.free()
file_ops.link_to_collection(current_joint_central_point)
current_joint_central_point.hide_select = True


def show_central_point(hist):
global current_joints_base_file
global current_joint_central_point
Expand All @@ -240,14 +252,7 @@ def show_central_point(hist):
# Now we have all vertices, we compute the average center
central_point = algorithms.average_center(vertices)
if current_joint_central_point == None:
mesh = bpy.data.meshes.new('Basic_Sphere')
current_joint_central_point = bpy.data.objects.new("Joint center", mesh)
bm = bmesh.new()
bmesh.ops.create_uvsphere(bm, u_segments=4, v_segments=4, diameter=0.004)
bm.to_mesh(mesh)
bm.free()
file_ops.link_to_collection(current_joint_central_point)
current_joint_central_point.hide_select = True
create_current_joint_central_point()
current_joint_central_point.location = (central_point.x, central_point.y, central_point.z)

# --------------------------------------------------
Expand Down Expand Up @@ -346,6 +351,8 @@ def show_offset_point(hist):
if current_offset_point == None:
create_offset_point()
co = file[hist.name]
if current_joint_central_point == None: # It happens.
create_current_joint_central_point()
vect = current_joint_central_point.location
current_offset_point.location = (
vect.x + co[0],
Expand Down Expand Up @@ -407,6 +414,8 @@ def set_offset_point():
for key, item in current_joints_offset_file.items():
file = item
# Now we calculate de relative location of the offset
if current_joint_central_point == None: # Security.
create_current_joint_central_point()
center_point = current_joint_central_point.location
offset_point = current_offset_point.location
file[hist.name] = [
Expand Down
4 changes: 2 additions & 2 deletions measurescreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_two_points(direction=0):
two_points_index += 1
if two_points_index >= len(measures_parts_points):
two_points_index = 0
if two_points_index >= measures_parts_points: # It happens
if two_points_index >= len(measures_parts_points): # It happens
two_points_index = len(measures_parts_points)-1
measure_name = measures_parts_points[two_points_index]
# Now we seek and keep the values in the MeshHandling.
Expand Down Expand Up @@ -428,7 +428,7 @@ def get_girth(direction=0):
girth_index += 1
if girth_index >= len(measures_parts_girths):
girth_index = 0
if girth_index >= measures_parts_girths: # It happens
if girth_index >= len(measures_parts_girths): # It happens
girth_index = len(measures_parts_girths)-1
measure_name = measures_parts_girths[girth_index]
# Now we seek and keep the values in the MeshHandling.
Expand Down