Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed typo in icp_align polling function #25

Open
wants to merge 7 commits into
base: b_280
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions lib/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class ObjectAlignmentPreferences(AddonPreferences):
name="Use Target",
description="Calc alignment stats at each iteration to assess convergence. SLower per step, may result in less steps",
default=True)
take_m_with = BoolProperty(
name="Take m_ Objects with",
description="Applies the same Transformation Matrix to all Objects which start with 'm_'",
default=False)
align_methods =['RIGID','ROT_LOC_SCALE']#,'AFFINE']
align_items = []
for index, item in enumerate(align_methods):
Expand Down Expand Up @@ -104,6 +108,7 @@ def draw(self, context):
layout.prop(self, "use_target")
layout.prop(self, "target_d")
layout.prop(self, "align_meth")
layout.prop(self, "take_m_with")

# updater draw function
addon_updater_ops.update_settings_ui(self,context)
8 changes: 8 additions & 0 deletions operators/align_pick_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def align_obj(self,context):
#test new method
settings = get_addon_preferences()
align_meth = settings.align_meth
take_m_with = settings.take_m_with

if align_meth == '0': #rigid transform
M = affine_matrix_from_points(A, B, shear=False, scale=False, usesvd=True)
Expand All @@ -437,6 +438,13 @@ def align_obj(self,context):
#because we calced transform in local space
#it's this easy to update the obj...
self.obj_align.matrix_world = self.obj_align.matrix_world @ new_mat
print(f"Final Transformation Matrix is: {new_mat}")
if take_m_with == True:
for obj in bpy.context.scene.objects:
if obj.name[:2] == "m_":
obj.matrix_world = obj.matrix_world @ new_mat
obj.update_tag()


self.obj_align.update_tag()
context.view_layer.update()
12 changes: 10 additions & 2 deletions operators/icp_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class OBJECT_OT_icp_align(Operator):
@classmethod
def poll(cls, context):
condition_1 = len(context.selected_objects) == 2
conidion_2 = context.object.type == 'MESH'
return condition_1 and condition_1
condition_2 = context.object.type == 'MESH'
return condition_1 and condition_2

def execute(self, context):
settings = get_addon_preferences()
Expand Down Expand Up @@ -85,6 +85,7 @@ def execute(self, context):
iters = settings.icp_iterations
target_d = settings.target_d
use_target = settings.use_target
take_m_with = settings.take_m_with
factor = round(1/sample)

n = 0
Expand All @@ -109,6 +110,13 @@ def execute(self, context):
new_mat[y][z] = M[y][z]

align_obj.matrix_world = align_obj.matrix_world @ new_mat
print(f"Final Transformation Matrix is: {new_mat}")
if take_m_with == True:
for obj in bpy.context.scene.objects:
if obj.name[:2] == "m_":
obj.matrix_world = obj.matrix_world @ new_mat
obj.update_tag()

trans = new_mat.to_translation()
quat = new_mat.to_quaternion()

Expand Down
19 changes: 17 additions & 2 deletions operators/icp_align_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def invoke(self,context, event):
self.iters = settings.icp_iterations
self.target_d = settings.target_d
self.use_target = settings.use_target
self.take_m_with = settings.take_m_with
self.sample_factor = round(1/self.sample_fraction)
self.redraw_frequency = settings.redraw_frequency

Expand Down Expand Up @@ -123,8 +124,8 @@ def modal(self, context, event):
@classmethod
def poll(cls, context):
condition_1 = len(context.selected_objects) == 2
conidion_2 = context.object.type == 'MESH'
return condition_1 and condition_1
condition_2 = context.object.type == 'MESH'
return condition_1 and condition_2

def execute(self, context):
settings = get_addon_preferences()
Expand Down Expand Up @@ -167,6 +168,7 @@ def execute(self, context):
iters = settings.icp_iterations
target_d = settings.target_d
use_target = settings.use_target
take_m_with = settings.take_m_with
factor = round(1/sample)

n = 0
Expand All @@ -191,6 +193,13 @@ def execute(self, context):
new_mat[y][z] = M[y][z]

align_obj.matrix_world = align_obj.matrix_world @ new_mat
print(f"Final Transformation Matrix is: {new_mat}")
if take_m_with == True:
for obj in bpy.context.scene.objects:
if obj.name[:2] == "m_":
obj.matrix_world = obj.matrix_world @ new_mat
obj.update_tag()

trans = new_mat.to_translation()
quat = new_mat.to_quaternion()

Expand Down Expand Up @@ -254,6 +263,12 @@ def iterate(self,context):
new_mat[y][z] = M[y][z]

self.align_obj.matrix_world = self.align_obj.matrix_world @ new_mat

if take_m_with == True:
for obj in bpy.context.scene.objects:
if obj.name[:2] == "m_":
obj.matrix_world = obj.matrix_world @ new_mat
obj.update_tag()
trans = new_mat.to_translation()
quat = new_mat.to_quaternion()

Expand Down
5 changes: 5 additions & 0 deletions ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def draw(self, context):
row.operator("object.align_exclude")
row.operator("object.align_exclude_clear", icon="X", text="")

row = layout.row()
row.label(text="General Alignment")
row = layout.row()
row.prop(settings, "take_m_with")

row = layout.row()
row.label(text="Initial Alignment")
row = layout.row()
Expand Down