from cgitb import text
from posixpath import split
import bpy
import pathlib
import os
import mathutils
from math import radians, degrees
file_path = bpy.data.filepath
folder_path = os.path.dirname(file_path)
folder=os.path.abspath(folder_path)
class VIEW3D_PT_cavycon_mount(bpy.types.Panel):
bl_label = "Mount"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
@classmethod
def poll(self, context):
scene = context.scene
return scene.Log_in.panel_type is not True
def draw(self, context):
step= bpy.context.scene.menu_steps
layout = self.layout
if step == 0:
col = layout.column(align=True)
col.label(text='1. Please select a FOLDER and press "Import Models"')
col.prop(context.scene, 'stl_import', text='Import Models',)
col.operator('import_scene.dental_models', icon='MESH_DATA')
row= self.layout.row()
row.operator('import_scene.inverse', icon='FILE_REFRESH', text='Inverse')
row.operator('models.rotate', icon='LOOP_BACK', text='').rotation=1.5708
row.operator('models.rotate', icon='LOOP_FORWARDS', text='').rotation=-1.5708
col = layout.column(align=False)
col.label(text='What type of mounting do you like?')
row = layout.row(align=False)
row.operator("cavyp.skip", text="CBCT").direction=1
row.operator("object.start_bonwill_alignment", text="Average")
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save')
row.label(text="")
row.separator_spacer()
elif step==1:
col = layout.column(align=True)
col.label(text='2. Please select a FOLDER and press "Import DICOM"')
col.prop(context.scene, 'dcm_import', text='File Location',)
col.operator("dicom.dcm_load", text="Import DICOM")
col = layout.column(align=False)
row = layout.row(align=False)
row= self.layout.row()
row.operator("ed.undo", text="", icon="TRIA_LEFT")
row.label(text="")
row.operator("cavyp.skip", text="", icon="TRIA_RIGHT").direction=+1
elif step==2:
col = layout.column(align=True)
col.label(text='3. Please select a FILE and press "Import"')
col.prop(context.scene, 'dicom_import', text='File Location',)
col.operator("import_scene.cbct", icon='BONE_DATA', text='Import CBCT Segmentation')
col = layout.column(align=False)
row = layout.row(align=False)
row= self.layout.row()
row.operator("cavyp.skip", text="", icon="TRIA_LEFT").direction=-1
row.label(text="")
elif step==3:
col = layout.column(align=True)
col.label(text='Please Rename or Parent your segmentation')
row = layout.row(align=True)
row.operator("object.rename_skull", text="Rename Skull")
row.operator("object.rename_mand", text="Rename Mandible")
row.operator("object.parent_other", text="Parent")
row = layout.row(align=True)
if bpy.context.active_object != None:
if len(bpy.context.active_object.modifiers)>0 and bpy.context.active_object.name =='Skull' or len(bpy.context.active_object.modifiers)>0 and bpy.context.active_object.name =='Mandible':
row.prop(context.active_object.modifiers['Reduce'], 'ratio',)
row.operator("object.decimate_accept", text="Accept")
col = layout.column(align=False)
row = layout.row(align=False)
row.label(text="")
row.operator("object.split_operator", text="", icon="TRIA_RIGHT")
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Start.blend"
row.label(text="")
row.separator_spacer()
elif step==4:
col= self.layout.column()
col.label(text='5. MAXILLA - Mark 3 Points on each side')
row= self.layout.row()
row.operator("object.align_operator", text='Mark',)
row.operator("object.model_alignment", text='Fine Tune Alignment',)
col= self.layout.column()
col= self.layout.column()
box = layout.box()
col = box.column()
col.label(text='Manual Alignment (OPTIONAL)')
row= box.row()
row.operator("object.manual_alignment", text='Select Vertices',)
row.operator("object.manual_icp_alignment", text='Accept',)
col = layout.column(align=False)
row = layout.row(align=False)
row.label(text="")
row.operator("object.mandible_alignment", text="", icon="TRIA_RIGHT")
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Upper_Alignment.blend"
row.label(text="")
row.separator_spacer()
elif step==5:
col= self.layout.column()
col.label(text='6. MANDIBLE - Align if necessary')
row= self.layout.row()
row.operator("object.lower_icp", text='Fine Tune Alignment',)
col= self.layout.column()
box = layout.box()
col = box.column()
col.label(text='Manual Alignment (OPTIONAL)')
row= box.row()
row.operator("object.manual_alignment", text='Select Vertices',)
row.operator("object.manual_icp_alignment", text='Accept',)
col = layout.column(align=False)
row = layout.row(align=False)
row.label(text="")
row.operator("object.show_skull", text="", icon="TRIA_RIGHT")
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Lower_Alignment.blend"
row.label(text="")
row.separator_spacer()
elif step==6:
box = layout.box()
row = box.row()
row.label(text='7. Volume Orientation', icon='HIDE_OFF')
row.prop(context.scene, 'free_mode',)
if bpy.context.scene.free_mode:
row = box.row()
vert=bpy.data.objects['Vert']
row.prop(vert, 'rotation_euler', text='Rotation')
row = box.row()
row.prop(vert, 'location', text='Traslation')
if bpy.context.active_object:
ob = context.object
if ob.type == 'EMPTY':
#col = layout.column(align=False, heading="Opacity")
#col.use_property_decorate = False
#col.label(text='')
row = box.row(align=False, heading="Opacity")
row.prop(ob, "use_empty_image_alpha", text="")
row.active = ob.use_empty_image_alpha
row.prop(ob, "color", text="", index=3, slider=True)
else:
col = layout.column(align=True)
row= self.layout.row()
row.label(text='Place corresponding point')
if bpy.context.scene.count < 2:
row.operator('object.ceph_points',text='Po', )
elif bpy.context.scene.count < 5:
row.operator('object.ceph_points',text='Ob', )
else:
row.operator('object.ceph_points',text='too many caphalometric points')
row.operator('object.ceph_points_del',text='Delete', )
lista = str(list(bpy.data.objects))
row= self.layout.row()
col = layout.column(align=True)
col.label(text='Clic "Mount Case" to import Articulator')
row= self.layout.row()
row.operator("import_scene.articulator",text='Mount Case',)
row.operator("clear_parenting.articulator", text='Accept',)
col = layout.column(align=True)
col.label(text='3. Extract Articulation surfaces')
col.operator('object.art_extract', text='Extract',)
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Volume_Orientation.blend"
row.label(text="")
row.separator_spacer()
elif step==7:
obj = str(list(bpy.data.objects))
if "bpy.data.objects['Inclination']" in obj:
dat=bpy.data.objects['Inclination'].rotation_euler[0]
else:
dat=0
layout = self.layout
col = layout.column(align=True)
row = self.layout.row()
row.label(text='Eminence Inclination')
row.label(text=f"Angle: {round(degrees(dat),1)}")
row = self.layout.row()
row.operator("object.rcond_inclination", text='Measure Right',)
row.operator("object.lcond_inclination", text='Measure Left',)
row = self.layout.row()
row.operator("object.accept_inclination", text='Accept',)
row= self.layout.row()
row.label(text="")
row.operator("cavyp.skip", text="", icon="TRIA_RIGHT").direction=+1
elif step==8:
col = layout.column(align=True)
col.label(text='Articulator Settings')
row = self.layout.row()
row.prop(context.scene, 'R_Condile', text='Right Condylar inclination',)
row.prop(context.scene, 'L_Condile', text='Left Condylar inclination',)
row = self.layout.row()
row.prop(context.scene, 'R_Bennett', text='Right Bennett Movement',)
row.prop(context.scene, 'L_Bennett', text='Left Bennet Movement',)
col = layout.column(align=True)
lista = str(list(bpy.data.collections))
if "bpy.data.collections['Dynamics']" in lista:
col.operator("object.bennett_operator", text='Apply',)
else:
col.operator("object.condile_operator", text='Show Handle',)
row= self.layout.row()
row.operator("cavyp.skip", text="", icon="TRIA_LEFT").direction=-1
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Dynamics.blend"
row.label(text="")
row.separator_spacer()
elif step==9:
col = layout.column(align=True)
col.label(text='2. Mark 3 points for Occlusal Plane')
row = self.layout.row()
row.label(text='Place corresponding point')
if bpy.context.scene.count < 2:
row.operator('object.model_points',text='Right Molar', )
row.operator('object.model_points',text='Left Molar', )
elif bpy.context.scene.count < 5:
row.operator('object.model_points',text='Incisors', )
row.operator('object.ceph_points_del',text='Delete', )
row= self.layout.row()
row.label(text="")
row.operator("object.models_bonwill", text="", icon="TRIA_RIGHT")
elif step==10:
material=bpy.data.materials
obj = str(list(bpy.data.objects))
col = layout.column(align=True)
if "bpy.data.objects['Bonwill']" in obj:
col = layout.column(align=False)
row = col.row()
row.prop(material['UModel_color'], 'diffuse_color', text="Upper transparency", index=3)
row.prop(material['LModel_color'], 'diffuse_color', text="Lower transparency", index=3)
row.prop(bpy.data.objects['Bonwill'], 'hide_viewport', text="B.Triangle",)
row = col.row()
row.prop(bpy.data.objects['lower'], 'rotation_euler', text="Rotation")
#image opacity
if bpy.context.active_object:
ob = context.object
if ob.type == 'EMPTY':
col = layout.column(align=False, heading="Opacity")
col.use_property_decorate = False
col.label(text='')
row = row= self.layout.row(align=False, heading="Opacity")
row.prop(ob, "use_empty_image_alpha", text="")
row.active = ob.use_empty_image_alpha
row.prop(ob, "color", text="", index=3, slider=True)
col = layout.column(align=True)
col.label(text='3. Fine tune lower and ACCEPT')
col.operator("object.models_bonwill_accept", text='Accept',)
col = layout.column(align=True)
col.label(text='4. Import Generic skull')
col.operator("object.import_default_skull", text='Import',)
class VIEW3D_PT_cavycon_panel(bpy.types.Panel):
bl_label = "Import"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
@classmethod
def poll(self, context):
scene = context.scene
return scene.Log_in.panel_type
def draw(self, context):
layout = self.layout
box = layout.box()
box.label(text='Camera')
row = box.row()
row.operator("view3d.view_axis", text="Right").type='LEFT'
row.operator("view3d.view_axis", text="Front").type='FRONT'
row.operator("view3d.view_axis", text="Left").type='RIGHT'
row = box.row()
row.operator("view3d.view_axis", text="Up").type='TOP'
row.operator("view3d.view_axis", text="Down").type='BOTTOM'
col = layout.column(align=True)
col.label(text='1. Please select a FOLDER and press "Import Models"')
col.prop(context.scene, 'stl_import', text='Import Models',)
col.operator('import_scene.dental_models', icon='MESH_DATA')
row= self.layout.row()
row= self.layout.row()
row.operator('import_scene.inverse', icon='FILE_REFRESH', text='Inverse')
row.operator('models.rotate', icon='LOOP_BACK', text='').rotation=1.5708
row.operator('models.rotate', icon='LOOP_FORWARDS', text='').rotation=-1.5708
row= self.layout.row()
row.operator('object.rename_dental_models', icon='GREASEPENCIL', text='Rename Selected')
row.operator('object.parent_to_models', icon='DECORATE_LINKED', text='Parent')
col = layout.column(align=True)
col.label(text='2. Please select a FOLDER and press "Import DICOM"')
col.prop(context.scene, 'dcm_import', text='File Location',)
col.operator("dicom.dcm_load", text="Import DICOM")
col = layout.column(align=True)
col.label(text='3. Please select a FILE and press "Import"')
col.prop(context.scene, 'dicom_import', text='File Location',)
col.operator("import_scene.cbct", icon='BONE_DATA', text='Import CBCT')
row = layout.row(align=True)
row.operator("object.rename_skull", text="Rename Skull")
row.operator("object.rename_mand", text="Rename Mandible")
row.operator("object.parent_other", text="Parent")
row = layout.row(align=True)
if bpy.context.active_object != None:
if len(bpy.context.active_object.modifiers)>0 and bpy.context.active_object.name =='Skull' or len(bpy.context.active_object.modifiers)>0 and bpy.context.active_object.name =='Mandible':
row.prop(context.active_object.modifiers['Reduce'], 'ratio',)
row.operator("object.decimate_accept", text="Accept")
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save')
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_dicom_panel(bpy.types.Panel):
bl_label = "Dicom operators"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
@classmethod
def poll(self, context):
lista = str(list(bpy.data.collections))
objs=str(list(bpy.data.objects))
return "bpy.data.collections['DICOM']" in lista and "bpy.data.objects['Empty']" in objs
def draw(self, context):
layout = self.layout
row= self.layout.row()
row.label(text='Patient Name:')
row.label(text=context.scene.my_array.Patien_Name)
row= self.layout.row()
row.label(text='Study Date:')
row.label(text=context.scene.my_array.Study_date)
row.operator("dicom.reload", text="Reload", icon='RECOVER_LAST')
row= self.layout.row()
row.prop(context.scene, 'dicom_width', text='Width', slider=True, icon='IMAGE_RGB_ALPHA')
row.prop(context.scene, 'dicom_level', text='level', slider=True, icon='IMAGE_RGB_ALPHA')
dicom=bpy.context.scene.view_layers[0].layer_collection.children['DICOM']
row.prop(dicom, 'hide_viewport',icon='HIDE_OFF', text='', toggle=1)
row= self.layout.row()
objects=bpy.data.objects
row.label(text='Axial')
row.label(text='Coronal')
row.label(text='Sagital')
row= self.layout.row()
row.prop( objects['Axial'], 'position', text='',)
row.prop( objects['Coronal'], 'position_cor', text='',)
row.prop( objects['Sagital'], 'position_sag', text='',)
row= self.layout.row()
row.prop( objects['Axial'], 'zoom', text='',)
row.prop( objects['Coronal'], 'zoom_cor', text='',)
row.prop( objects['Sagital'], 'zoom_sag', text='',)
row= self.layout.row()
row.operator("dicom.modal_axial", text="Panning")
row.operator("dicom.modal_coronal", text="Panning")
row.operator("dicom.modal_sagital", text="Panning")
col = layout.column(align=True)
col.operator("dicom.reset_all", text="Reset All")
class VIEW3D_PT_Alignment_panel(bpy.types.Panel):
bl_label = "Alignment"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
@classmethod
def poll(self, context):
scene = context.scene
return scene.Log_in.panel_type
def draw(self, context):
layout = self.layout
box = layout.box()
box.label(text='Camera')
row = box.row()
row.operator("view3d.view_axis", text="Right").type='LEFT'
row.operator("view3d.view_axis", text="Front").type='FRONT'
row.operator("view3d.view_axis", text="Left").type='RIGHT'
layout = self.layout
col= self.layout.column()
col.operator("object.split_operator", text="Start", icon="MOD_TRIANGULATE")
col.label(text='1. MAXILLA - Mark 3 Points per side')
row= self.layout.row()
row.operator("object.align_operator", text='Mark',)
row.operator("object.model_alignment", text='Fine Tune Alignment',)
col= self.layout.column()
col.label(text='2. MANDIBLE - Press "Show" and align if necessary')
row= self.layout.row()
row.operator("object.mandible_alignment", text='Show',)
row.operator("object.lower_icp", text='Fine Tune Alignment',)
col= self.layout.column()
box = layout.box()
col = box.column()
col.label(text='3. Manual Alignment (OPTIONAL)')
row= box.row()
row.operator("object.manual_alignment", text='Select Vertices',)
row.operator("object.manual_icp_alignment", text='Accept',)
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Alignment.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_panel2(bpy.types.Panel):
bl_label = "CBCT Articulator"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
scene = context.scene
return scene.Log_in.panel_type
def draw(self, context):
self.free=True
layout = self.layout
box = layout.box()
row = box.row()
row.label(text='Volume Orientation', icon='HIDE_OFF')
row.operator('object.show_skull', text='Start' )
row.prop(context.scene, 'free_mode',)
if bpy.context.scene.free_mode:
row = box.row()
vert=bpy.data.objects['Vert']
row.prop(vert, 'rotation_euler', text='Rotation')
row = box.row()
row.prop(vert, 'location', text='Traslation')
if bpy.context.active_object:
ob = context.object
if ob.type == 'EMPTY':
row = box.row(align=False, heading="Opacity")
row.prop(ob, "use_empty_image_alpha", text="")
row.active = ob.use_empty_image_alpha
row.prop(ob, "color", text="", index=3, slider=True)
else:
col = layout.column(align=True)
row= self.layout.row()
row.label(text='1. Place corresponding point')
if bpy.context.scene.count < 2:
row.operator('object.ceph_points',text='Po', )
elif bpy.context.scene.count < 5:
row.operator('object.ceph_points',text='Ob', )
else:
row.operator('object.ceph_points',text='too many caphalometric points')
row.operator('object.ceph_points_del',text='Delete', )
col = layout.column(align=True)
col.label(text='2. Clic "Mount Case" to import Articulator')
row= self.layout.row()
row.operator("import_scene.articulator",text='Mount Case',)
row.operator("clear_parenting.articulator", text='Accept',)
collec = bpy.data.collections
lista = str(list(bpy.data.collections))
col = layout.column(align=True)
if "bpy.data.collections['Articulator']" in lista:
col.prop(collec['Articulator'], 'hide_viewport' ,text='Show/Hide Articulator')
col = layout.column(align=True)
col.label(text='3. Extract Articulation surfaces')
col.operator('object.art_extract', text='Extract',)
else:
pass
box = layout.box()
box.label(text='Camera')
row = box.row()
row.operator("view3d.view_axis", text="Right").type='LEFT'
row.operator("view3d.view_axis", text="Front").type='FRONT'
row.operator("view3d.view_axis", text="Left").type='RIGHT'
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Volume_Orientation.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_panel3(bpy.types.Panel):
bl_label = "Default Articulator"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
scene = context.scene
return scene.Log_in.panel_type
def draw(self, context):
material=bpy.data.materials
obj = str(list(bpy.data.objects))
layout = self.layout
col = layout.column(align=True)
row = self.layout.row()
row.label(text='1. Lower model alignment')
row.operator("object.start_bonwill_alignment", icon='PIVOT_CURSOR', text='Start',)
col = layout.column(align=True)
col.label(text='2. Mark 3 points for Occlusal Plane')
row = self.layout.row()
row.label(text='Place corresponding point')
if bpy.context.scene.count < 2:
row.operator('object.model_points',text='Right Molar', )
row.operator('object.model_points',text='Left Molar', )
elif bpy.context.scene.count < 5:
row.operator('object.model_points',text='Incisors', )
row.operator('object.ceph_points_del',text='Delete', )
row = self.layout.row()
row.prop(bpy.data.objects['lower'], 'rotation_euler', text="Rotation")
if bpy.context.active_object:
ob = context.object
if ob.type == 'EMPTY':
col = layout.column(align=False, heading="Opacity")
col.use_property_decorate = False
col.label(text='')
row = row= self.layout.row(align=False, heading="Opacity")
row.prop(ob, "use_empty_image_alpha", text="")
row.active = ob.use_empty_image_alpha
row.prop(ob, "color", text="", index=3, slider=True)
col = layout.column(align=True)
col.label(text='3. Press "Align" to center model')
if "bpy.data.objects['Bonwill']" in obj:
row = self.layout.row()
row.prop(material['UModel_color'], 'diffuse_color', text="Upper transparency", index=3)
row.prop(material['LModel_color'], 'diffuse_color', text="Lower transparency", index=3)
row.prop(bpy.data.objects['Bonwill'], 'hide_viewport', text="B.Triangle",)
row = self.layout.row()
row.operator("object.models_bonwill", text='Align',)
row.operator("object.models_bonwill_accept", text='Accept',)
col = layout.column(align=True)
col.label(text='4. Import Generic skull')
col.operator("object.import_default_skull", text='Import',)
col = layout.column(align=True)
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Default.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_Dynamics(bpy.types.Panel):
bl_label = "Dynamics"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
scene = context.scene
return scene.Log_in.panel_type
def draw(self, context):
scene = context.scene
obj = str(list(bpy.data.objects))
if "bpy.data.objects['Inclination']" in obj:
dat=bpy.data.objects['Inclination'].rotation_euler[0]
else:
dat=0
layout = self.layout
col = layout.column(align=True)
row = self.layout.row()
row.label(text='Eminence Inclination')
row.label(text=f"Angle: {round(degrees(dat),1)}")
row = self.layout.row()
row.operator("object.rcond_inclination", text='Measure Right',)
row.operator("object.lcond_inclination", text='Measure Left',)
row = self.layout.row()
row.operator("object.accept_inclination", text='Accept',)
col = layout.column(align=True)
col.label(text='Articulator Settings')
row = self.layout.row()
row.prop(context.scene, 'R_Condile', text='Right Condylar inclination',)
row.prop(context.scene, 'L_Condile', text='Left Condylar inclination',)
row = self.layout.row()
row.prop(context.scene, 'R_Bennett', text='Right Bennett Movement',)
row.prop(context.scene, 'L_Bennett', text='Left Bennet Movement',)
col = layout.column(align=True)
lista = str(list(bpy.data.collections))
if "bpy.data.collections['Dynamics']" in lista:
col.operator("object.bennett_operator", text='Apply',)
else:
col.operator("object.condile_operator", text='Show Handle',)
col = layout.column(align=False)
box = layout.box()
col = box.column()
col.label(text='Elements to shows', icon='HIDE_OFF')
row = box.row()
collec = bpy.data.collections
if "bpy.data.collections['Articulator']" in lista:
row = box.row()
row.prop(collec['Models'], 'hide_viewport', icon='HIDE_OFF', text='Models')
row.prop(collec['Bones'], 'hide_viewport', icon='HIDE_OFF', text='Bones')
col = box.column(align=True)
col.prop(collec['Articulator'], 'hide_viewport' ,text='Show/Hide Articulator')
else:
col.label(text=' No Articulator Available ')
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Dynamics.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_excursives(bpy.types.Panel):
bl_label = "Import Bites"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
objs=str(list(bpy.data.objects))
return "bpy.data.objects['Empty']" in objs
def draw(self, context):
layout = self.layout
scene = context.scene
bite = scene.bite_import
col = layout.column(align=True)
row = layout.row(align=True)
split = row.split(factor=0.3, align=True)
split.label(text='1. Import', icon='IMPORT')
split.prop(bite, "Select_bite_to_import", text='Select bite')
row = layout.row(align=True)
row.prop(scene, 'dicom_import', text='Select Model',)
if bite.Select_bite_to_import == 'P_bite':
row.operator("object.protrusive", text="Accept")
elif bite.Select_bite_to_import == 'R_bite':
row.operator("object.right_excursive", text="Accept")
elif bite.Select_bite_to_import == 'Centric':
row.operator("object.centric", text="Accept")
else:
row.operator("object.left_excursive", text="Accept")
layout = self.layout
box = layout.box()
box.label(text='Camera')
row = box.row()
row.operator("view3d.view_axis", text="Rigth").type='LEFT'
row.operator("view3d.view_axis", text="Front").type='FRONT'
row.operator("view3d.view_axis", text="Left").type='RIGHT'
row = box.row()
row.operator("view3d.view_axis", text="Occlusal").type='BOTTOM'
layout = self.layout
col = layout.column(align=True)
if "bpy.data.collections['Bites']" in str(list(bpy.data.collections)):
if bpy.data.objects['upper'] in bpy.context.visible_objects:
col.label(text='2. Align to Upper', icon='ALIGN_TOP')
row = layout.row(align=True)
if bite.Select_bite_to_import == 'P_bite':
if bpy.context.scene.count == 0:
row.operator('align.protrusive_bite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinmentu', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.protrusive_bite', text="Accept", icon='CHECKMARK')
elif bite.Select_bite_to_import == 'R_bite':
if bpy.context.scene.count == 0:
row.operator('align.right_bite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinmentu', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.right_bite', text="Accept", icon='CHECKMARK')
elif bite.Select_bite_to_import == 'Centric':
if bpy.context.scene.count == 0:
row.operator('align.centric', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinmentu', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.centric_bite', text="Accept", icon='CHECKMARK')
else:
if bpy.context.scene.count == 0:
row.operator('align.left_bite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinmentu', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.left_bite', text="Accept", icon='CHECKMARK')
elif bpy.data.objects['lower'] in bpy.context.visible_objects:
col = layout.column(align=True)
col.label(text='3. Align Lower', icon='ALIGN_BOTTOM')
row = layout.row(align=True)
if bite.Select_bite_to_import == 'P_bite':
if bpy.context.scene.count == 0:
row.operator('align.lower_to_bite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinment', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.lower_to_bite', text="Accept", icon='CHECKMARK')
elif bite.Select_bite_to_import == 'R_bite':
if bpy.context.scene.count == 0:
row.operator('align.lower_to_right_bite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinment', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.lower_to_right_bite', text="Accept", icon='CHECKMARK')
elif bite.Select_bite_to_import == 'Centric':
if bpy.context.scene.count == 0:
row.operator('align.lower_to_cbite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinment', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.lower_to_cbite', text="Accept", icon='CHECKMARK')
else:
if bpy.context.scene.count == 0:
row.operator('align.lower_to_left_bite', text="Auto", icon='ZOOM_SELECTED').ICP = 15
else:
row.operator('align.refinment', text="Refine", icon='ZOOM_SELECTED')
row.operator('accept.lower_to_left_bite', text="Accept", icon='CHECKMARK')
else:
pass
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Extra_bites.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_Quantification(bpy.types.Panel):
bl_label = "Quantification"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
objs=str(list(bpy.data.objects))
return "bpy.data.objects['Empty']" in objs
def draw(self, context):
layout = self.layout
col = layout.column(align=False)
row= col.row(align=False)
row.label(text='')
row.label(text='TMJ Quantification',)
row.label(text='')
if bpy.context.active_object==None:
pass
elif bpy.context.active_object.mode == 'WEIGHT_PAINT' and bpy.context.active_object.name.endswith('Condile'):
modifiers=[]
for m in bpy.context.active_object.modifiers:
modifiers.append(m.name)
if 'Map' in modifiers:
col = layout.column(align=False)
row= col.row(align=False)
row.prop(context.active_object.modifiers['Map'], 'min_dist', text="Tickness")
row.prop(context.area.spaces[0].shading, 'xray_alpha', text="Transparency")
col = layout.column(align=False)
col.operator("object.exit_map",text='Exit')
else:
col = layout.column(align=False, heading='head')
col.label(text='Color Map', icon='COLORSET_02_VEC')
row= col.row(align=False)
row.operator("object.map_right", text='Right TMJ')
row.operator("object.map_left", text='Left TMJ')
col = layout.column(align=True)
col.label(text='Condyles', icon='MOD_SHRINKWRAP')
row= col.row(align=False)
left= bpy.data.objects['Left Condile']
right= bpy.data.objects['Right Condile']
#Right side
if right.MeasureGenerator.items():
if len(right.MeasureGenerator[0].measureit_segments.items()) > 2:
if context.window_manager.measureit_run_opengl:
row.operator("object.meassure_delete", depress=True, text='Meassure Right condyles').side='Right'
else:
row.operator("measureit.runopengl", text='Meassure Right condyles')
else:
row.operator("object.meassure_right", text='Meassure Right condyles')
else:
row.operator("object.meassure_right", text='Meassure Right condyles')
#Left side
if left.MeasureGenerator.items():
if len(left.MeasureGenerator[0].measureit_segments.items()) > 2:
if context.window_manager.measureit_run_opengl:
row.operator("object.meassure_delete", depress=True, text='Meassure Left condyles').side='Left'
else:
row.operator("measureit.runopengl", text='Meassure Left condyles')
else:
row.operator("object.meassure_left", text='Meassure Left condyles')
else:
row.operator("object.meassure_left", text='Meassure Left condyles')
if context.window_manager.measureit_run_opengl is False:
icon = 'PLAY'
txt = 'Show'
else:
icon = "PAUSE"
txt = 'Hide'
row= col.row(align=False)
row.operator("measureit.runopengl", text=txt, icon=icon)
col = layout.column(align=True)
col.label(text='Condile Correction', icon='TRACKER_DATA')
row = layout.row(align=False)
split = row.split(factor=0.6, align=False)
split.prop(context.scene.bite_import, "Select_condile_direction", text='Direction')
split.prop(context.scene.bite_import, 'Condile_movemente', text='Distance')
if context.scene.bite_import.Select_condile_direction == 'Right':
row = layout.row(align=False)
row.label(text='')
row.operator("object.movercz", icon='SORT_DESC', text='').distance = bpy.context.scene.bite_import.Condile_movemente
row.label(text='')
row = layout.row(align=False)
row.label(text='')
row.operator("object.movercy", icon='BACK', text='').distance = bpy.context.scene.bite_import.Condile_movemente
row.operator("object.movercz", icon='SORT_ASC', text='').distance = -bpy.context.scene.bite_import.Condile_movemente
row.operator("object.movercy", icon='FORWARD', text='').distance = -bpy.context.scene.bite_import.Condile_movemente
row.label(text='')
elif context.scene.bite_import.Select_condile_direction == 'Left':
row = layout.row(align=False)
row.label(text='')
row.operator("object.movelcz", icon='SORT_DESC', text='').distance = -bpy.context.scene.bite_import.Condile_movemente
row.label(text='')
row = layout.row(align=False)
row.label(text='')
row.operator("object.movelcy", icon='BACK', text='').distance = -bpy.context.scene.bite_import.Condile_movemente
row.operator("object.movelcz", icon='SORT_ASC', text='').distance = bpy.context.scene.bite_import.Condile_movemente
row.operator("object.movelcy", icon='FORWARD', text='').distance = bpy.context.scene.bite_import.Condile_movemente
row.label(text='')
else:
row = layout.row(align=False)
row.label(text='Mandible')
row.operator("object.movecx", icon='BACK', text='').distance = -bpy.context.scene.bite_import.Condile_movemente
row.operator("object.movecx", icon='FORWARD', text='').distance = bpy.context.scene.bite_import.Condile_movemente
row.label(text="")
row = layout.row(align=False)
row.operator("object.condile_reset", text='Reset')
row.operator("object.condile_save", icon='TEMP', text='')
row.operator("object.condile_new", text='New')
col = layout.column(align=False)
col.label(text='',)
row= col.row(align=False)
row.label(text='')
row.label(text='Model Quantification',)
row.label(text='')
if bpy.context.active_object==None:
pass
elif bpy.context.active_object.mode == 'WEIGHT_PAINT' and bpy.context.active_object.name == 'upper' or bpy.context.active_object.name == 'lower':
modifiers=[]
for m in bpy.context.active_object.modifiers:
modifiers.append(m.name)
if 'Map' in modifiers:
col = layout.column(align=False)
row= col.row(align=False)
row.prop(context.active_object.modifiers['Map'], 'min_dist', text="Tickness")
row.prop(context.area.spaces[0].shading, 'xray_alpha', text="Transparency")
col = layout.column(align=False)
col.operator("object.exit_map",text='Exit')
else:
col = layout.column(align=True)
row= col.row(align=False)
row.label(text='Color Map', icon='COLORSET_04_VEC')
row.operator("object.map_upper",text='Upper')
row.operator("object.map_lower",text='Lower')
col.separator(factor=1.0)
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Quantification.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_panel4(bpy.types.Panel):
bl_label = "Movements"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
objs=str(list(bpy.data.objects))
return "bpy.data.objects['Empty']" in objs
def draw(self, context):
lista = str(list(bpy.data.collections))
layout = self.layout
if "bpy.data.collections['Articulator']" in lista:
col = layout.column(align=True)
box = layout.box()
col = box.column()
col.label(text='Elements to shows', icon='HIDE_OFF')
collec = bpy.data.collections
ob = bpy.data.objects
col = box.column(align=True)
col.prop(collec['Models'], 'hide_viewport', text='Models')
row = box.row()
try:
row.prop(ob['upper'], 'hide_viewport', icon='HIDE_OFF', text='upper')
except KeyError:
row.label(text='Incorrect names')
try:
row.prop(ob['lower'], 'hide_viewport', icon='HIDE_OFF', text='lower')
except KeyError:
row.label(text='Incorrect names')
row.prop(bpy.data.collections['Models'], 'hide_select', icon='PINNED', text='Selection')
row = box.row()
try:
row.prop(ob['Working'], 'hide_viewport', icon='HIDE_OFF', text='Working')
except KeyError:
pass
try:
row.prop(collec['T2_models'], 'hide_viewport', text='T2 Model')
except KeyError:
pass
col = box.column(align=True)
col.prop(collec['Articulator'], 'hide_viewport' ,text='Show/Hide Articulator')
row = box.row()
row.prop(collec['Bones'], 'hide_viewport', icon='HIDE_OFF', text='Bones')
row.prop(collec['TMJ'], 'hide_viewport', icon='HIDE_OFF', text='TMJ')
try:
dicom=bpy.context.scene.view_layers[0].layer_collection.children['DICOM']
row.prop(dicom, 'hide_viewport', icon='HIDE_OFF' , text='DICOM')
except KeyError:
pass
else:
col = layout.column(align=True)
col.label(text=' No Articulator Available ')
col = layout.column(align=False)
col.label(text='Config animation', icon='ANIM')
row = layout.row(align=True)
split = layout.split(factor=0.15)
col= split.column(align=True)
Vertical=-bpy.data.objects['Empty'].location[2]
col.operator("object.handle", text="", icon='SORT_DESC').handle = Vertical -0.5
col.operator("object.handle", text="", icon='SORT_ASC').handle = Vertical + 0.5
col = split.column()
split = col.split(factor=0.3)
col = split.column(align=True)
col.label(text='Bite oppening')
col.prop(context.scene, "biteopenning", text="")
col = split.column(align=True)
row= col.row(align=False)
row.operator("handle.key",text='Sets', icon='KEYINGSET')
row= col.row(align=True)
row.scale_x = 2.5
row.operator("screen.frame_jump", text="", icon='REW').end = False
if not context.screen.is_animation_playing:
row.operator("screen.animation_play", text="", icon='PLAY_REVERSE').reverse = True
row.operator("screen.animation_play", text="", icon='PLAY')
else:
row.operator("screen.animation_play", text="", icon='PAUSE')
row.operator("screen.frame_jump", text="", icon='FF').end = True
row.prop(context.scene.render, "fps", text="Speed")
col = layout.column(align=False)
row= col.row(align=False)
row.operator("object.wmodel_operator", text="Working Model", icon='TOOL_SETTINGS')
row.operator("object.distance", text="Distance", icon='DRIVER_DISTANCE')
row.prop(context.scene.bite_import, "dist", text='', emboss=False)
row= col.row(align=False)
row.operator("object.contacts_operator", text="Find first contact", icon='BORDERMOVE').frame = bpy.context.scene.frame_current
row.operator("object.occlusal_scheme", text="Automatic Occlusion", icon='SHADERFX')
col = layout.column(align=False)
box = layout.box()
box.label(text='NAVIGATE',)
row = box.row()
row.operator("scene.bite",text='Right Excursive' ).frame = 21
if "bpy.data.collections['Bites']" in str(list(bpy.data.collections)):
row.operator("scene.bite",text='RC',).frame = 1
row.operator("scene.bite",text='OC',).frame = 10
else:
row.operator("scene.bite",text='Centric',).frame = 1
row.operator("scene.bite",text='Left Excursive' ).frame = 41
row.operator("scene.bite",text='Protrusive' ).frame = 61
collec = bpy.data.collections
if "bpy.data.collections['Bites']" in str(list(bpy.data.collections)):
col = layout.column(align=False)
row = col.row(align=True)
if "bpy.data.collections['Condile Position']" in str(list(bpy.data.collections)):
row.operator("object.de_condile_movement",text='Delete Condiles' )
row.prop(collec['Condile Position'], 'hide_viewport' ,text='S/H RC Condiles')
row.operator("object.hide_condile", text='S/H OC Condiles', icon='RESTRICT_VIEW_OFF')
else:
row.operator("object.condile_movement",text='See Condilar Position' )
col = layout.column(align=False)
row= col.row(align=False)
row.operator("use.centric_bite",text='Use RC' )
row.operator("use.mic_bite",text='Use OC' )
area = bpy.context.area
col = layout.column(align=False)
row= col.row(align=True)
row.operator("object.screenshots",text='Capture Screen' , icon='RESTRICT_RENDER_OFF')
row.prop(area.spaces[0].shading, 'background_color')
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath= folder + "/Movement.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_Cuts(bpy.types.Panel):
bl_label = "Cuts"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
objs=str(list(bpy.data.objects))
return "bpy.data.objects['Empty']" in objs
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.label(text='Clean Models and Create Bases', icon='GP_CAPS_FLAT')
row= self.layout.row()
row.operator('object.clean_border', icon='TRIA_UP_BAR', text='Clean Upper')
row.operator('object.delete_border', icon='ALIGN_BOTTOM', text='Upper Base')
row= self.layout.row()
row.operator('object.clean_lborder', icon='TRIA_DOWN_BAR', text='Clean Lower')
row.operator('object.delete_lborder', icon='ALIGN_TOP', text='Lower Base')
col = layout.column(align=False)
col.label(text='Dynamic Cuts', icon='BRUSH_CURVES_GROW_SHRINK')
col.label(text='1. Select objects to animate')
col.operator("object.animate",text='Animate Object')
col = layout.column(align=False)
col.label(text='2. Select meshes and choose tool (Object to cut last)')
row= col.row(align=False)
row.operator("object.rbool_tool",text='Cut Right')
row.operator("object.fbool_tool",text='Cut Front')
row.operator("object.lbool_tool",text='Cut Left')
col = layout.column(align=False)
col.label(text='3. Remesh objects to export')
row= col.row(align=False)
mod=[]
if bpy.context.active_object:
for m in bpy.context.active_object.modifiers:
mod.append(m.name)
if "Clean" not in mod:
row.operator("object.remesh",text='Remesh')
else:
row.prop(context.active_object.modifiers['Clean'], 'voxel_size',)
row.operator("object.modifier_apply").modifier="Clean"
if bpy.context.active_object:
if bpy.context.active_object.mode=='OBJECT':
row.operator("object.smooth",text='Smooth')
elif bpy.context.active_object.mode=='SCULPT':
row.operator("object.mode_set",text='Smooth',depress=True).mode='OBJECT'
#save
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/Cuts.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_panel5(bpy.types.Panel):
bl_label = "3D Printing"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
objs=str(list(bpy.data.objects))
return "bpy.data.objects['Empty']" in objs
def draw(self, context):
layout = self.layout
col = layout.column(align=False)
col.label(text='1. Adjust Printable Articulator')
row = col.row(align=True)
row.operator("object.u_plate",text='Adjust Upper Plate', icon='TRIA_UP_BAR')
row.operator("object.plate_accept",text='Accept Upper')
row = col.row(align=True)
row.operator("object.l_plate",text='Adjust Lower Plate', icon='TRIA_DOWN_BAR')
row.operator("object.plate_accept",text='Accept Lower')
col = layout.column(align=False)
row = col.row(align=False)
row.operator("object.rbool_cutter",text='Trim Right', icon='LOOP_BACK')
row.operator("object.fbool_cutter",text='Trim Forward', icon='IMPORT')
row.operator("object.lbool_cutter",text='Trim Left', icon='LOOP_FORWARDS')
col = layout.column(align=False)
col.operator("object.obool_cutter",text='Trim Open', icon='PROP_CON')
col = layout.column(align=False)
col.operator("object.reset_guides",text='RESET', icon='GPBRUSH_ERASE_HARD')
col = layout.column(align=True)
col.label(text='2. Export files for 3D Printing')
col.prop(context.scene, 'stl_import', text='Save Files',)
col.operator("object.export_detachables",text='Export Guides', icon='ORIENTATION_GLOBAL')
col = layout.column(align=False)
col.operator("object.export_art",text='Export Articulator', icon='FOLDER_REDIRECT')
col = layout.column(align=False)
col.operator("object.export_models",text='Export Models (Ctrl E)', icon='DESKTOP')
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath= folder + "/Print.blend"
row.label(text="")
row.separator_spacer()
class VIEW3D_PT_cavycon_remount(bpy.types.Panel):
bl_label = "T2 Mount"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "CAVY"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
objs=str(list(bpy.data.objects))
return "bpy.data.objects['Empty']" in objs
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.label(text='1. Please select a FOLDER and press "Import T2 Models"')
col.prop(context.scene, 'stl_import', text='T2 Models Folder',)
row= col.row(align=False)
row.operator('object.newbite', icon='MESH_DATA', text='Import T2 Models')
row.operator('new_bite.inverse', icon='FILE_REFRESH', text='Inverse')
col = layout.column(align=True)
box = layout.box()
box.label(text='Camera')
row = box.row()
row.operator("view3d.view_axis", text="Rigth").type='LEFT'
row.operator("view3d.view_axis", text="Front").type='FRONT'
row.operator("view3d.view_axis", text="Left").type='RIGHT'
split = box.split(factor=0.95)
col = split.column()
row = col.row()
row.operator("view3d.view_axis", text="Occlusal Upper").type='BOTTOM'
row.operator("view3d.view_axis", text="Occlusal Lower").type='TOP'
col = split.column()
row = col.row()
if bpy.context.space_data.shading.show_xray:
dep = True
else:
dep = False
row.operator("view3d.toggle_xray", text = '', icon='MOD_WIREFRAME', depress=dep)
try:
if bpy.data.objects['New upper'].visible_get():
col = layout.column(align=True)
col.label(text='UPPER')
col = layout.column(align=True)
col.label(text='2. Align models and click "Mesh" to select reference')
row= col.row(align=False)
row.operator('new_bite.mesh', icon='VIEWZOOM', text='Mesh')
row.operator('mesh.select_all', icon='OUTLINER_DATA_POINTCLOUD', text='Clean').action='DESELECT'
if bpy.context.scene.count == 0:
row.operator('new_bite.alignu', text='Accept')
else:
row.operator('new_bite.realign', text='Refine')
col.operator('new_bite.lower', icon='IMPORT', text='Show Lower')
elif bpy.data.objects['T2_Lower'].visible_get() and "bpy.data.objects['New lower']" in str(list(bpy.data.collections['New Records'].objects)):
col = layout.column(align=True)
col.label(text='LOWER')
col = layout.column(align=True)
col.label(text='3. Show Lower and align, click "Mesh" to select reference')
row= col.row(align=False)
row.operator('new_bite.mesh', icon='VIEWZOOM', text='Mesh')
row.operator('mesh.select_all', icon='OUTLINER_DATA_POINTCLOUD', text='Clean').action='DESELECT'
if bpy.context.scene.count == 0:
row.operator('new_bite.alignl', text='Accept')
else:
row.operator('new_bite.realign', text='Refine')
col.operator('new_bite.finish', icon='SHADERFX', text='Finish')
else:
col = layout.column(align=True)
col.operator('new_bite.reset', icon='RECOVER_LAST', text='RESET')
except KeyError:
pass
col = layout.column(align=True)
row = layout.row(align=False)
row.separator_spacer()
row.label(text="")
row.operator("wm.save_mainfile", icon='BLENDER', text='Save').filepath=folder + "/T2.blend"
row.label(text="")
row.separator_spacer()
Classes =[
VIEW3D_PT_cavycon_mount,
VIEW3D_PT_cavycon_panel,
VIEW3D_PT_Alignment_panel,
VIEW3D_PT_cavycon_panel2,
VIEW3D_PT_cavycon_panel3,
VIEW3D_PT_cavycon_Dynamics,
VIEW3D_PT_cavycon_panel4,
VIEW3D_PT_dicom_panel,
VIEW3D_PT_cavycon_Quantification,
VIEW3D_PT_cavycon_excursives,
VIEW3D_PT_cavycon_Cuts,
VIEW3D_PT_cavycon_panel5,
VIEW3D_PT_cavycon_remount,
]
def free(self, context):
if self.free_mode==True:
#parenting
bpy.ops.mesh.primitive_plane_add(size=1, location=bpy.data.objects['Skull'].location)
Fk = bpy.context.active_object
Fk.name='Vert'
Amodels = bpy.data.objects['Skull'],bpy.data.objects['Mandible'], bpy.data.objects['upper'], bpy.data.objects['lower']
for a in Amodels:
a.parent=Fk
a.matrix_parent_inverse = Fk.matrix_world.inverted()
bpy.ops.view3d.view_axis(type='FRONT')
skull = bpy.data.objects['Skull']
#prepare scene
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.view3d.view_axis(type='FRONT')
#create reference planes
bpy.ops.mesh.primitive_plane_add(size=200, enter_editmode=False, align='WORLD', scale=(1, 1, 1), location=(0.0, 40.451480865478516, 44.672584533691406))
horizontal=bpy.context.active_object
vertical=bpy.ops.mesh.primitive_plane_add(size=200, enter_editmode=False, align='WORLD', rotation=(0, 1.5708, 0), scale=(1, 1, 1), location=(0.0, 40.451480865478516, 44.672584533691406))
vertical=bpy.context.active_object
horizontal.name='H_Plane'
vertical.name='V_Plane'
hwrf=horizontal.modifiers.new('wrfF', type='WIREFRAME')
vwrf=vertical.modifiers.new('wrf', type='WIREFRAME')
hwrf.thickness=1
vwrf.thickness=1
if "bpy.data.materials['Vertical_color']" in str(list(bpy.data.materials)):
vcolor = bpy.data.materials['Vertical_color']
hcolor = bpy.data.materials['Horizontal_color']
else:
vcolor = bpy.data.materials.new(name="Vertical_color")
hcolor = bpy.data.materials.new(name="Horizontal_color")
vcolor.diffuse_color=[0.07441884279251099, 1.0, 0.10245930403470993, 1.0]
hcolor.diffuse_color=[0.014878911897540092, 0.41101691126823425, 1.0, 1.0]
horizontal.active_material=hcolor
vertical.active_material=vcolor
horizontal.color=hcolor.diffuse_color
vertical.color=vcolor.diffuse_color
horizontal.lock_location[0]=True
horizontal.lock_location[1]=True
horizontal.lock_rotation[0]=True
horizontal.lock_rotation[1]=True
horizontal.lock_rotation[2]=True
vertical.lock_location[0]=True
vertical.lock_location[1]=True
vertical.lock_rotation[0]=True
vertical.lock_rotation[1]=True
vertical.lock_rotation[2]=True
horizontal.hide_select=True
vertical.hide_select=True
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects['Vert'].select_set(True)
bpy.context.view_layer.objects.active = bpy.data.objects['Vert']
for a in bpy.context.screen.areas:
if a.type=='VIEW_3D':
ar=a
reg={'region': ar.regions[5]}
bpy.ops.view3d.view_selected(reg, use_all_regions=True)
bpy.context.screen.areas[0].spaces[0].show_region_hud = False
bpy.ops.screen.area_split(direction='HORIZONTAL', factor=0.5)
bpy.ops.screen.area_split(direction='VERTICAL', factor=0.34)
bpy.context.screen.areas[-1].spaces[0].show_region_ui = False
bpy.context.screen.areas[-1].spaces[0].show_region_hud = False
bpy.context.screen.areas[-2].spaces[0].show_region_ui = False
bpy.context.screen.areas[-2].spaces[0].show_region_hud = False
bpy.ops.view3d.view_axis(type='RIGHT')
split ={'area': bpy.context.screen.areas[-1]}
bpy.ops.view3d.view_axis(split, type='LEFT')
regz={'region': bpy.context.screen.areas[-1].regions[5]}
regz2={'region': bpy.context.screen.areas[-2].regions[5]}
for a in range(24):
bpy.ops.view3d.zoom(regz, delta=-1)
for a in range(27):
bpy.ops.view3d.zoom(reg, delta=-1)
for a in range(29):
bpy.ops.view3d.zoom(regz2, delta=-1)
else:
bpy.data.objects.remove(bpy.data.objects['H_Plane'], do_unlink=True)
bpy.data.objects.remove(bpy.data.objects['V_Plane'], do_unlink=True)
spheres=[]
for o in bpy.data.objects:
if o.data.name.startswith('Sphere'):
spheres.append(o)
for s in spheres:
bpy.data.objects.remove(s, do_unlink=True)
bpy.ops.view3d.view_axis(type='RIGHT')
bpy.ops.wm.tool_set_by_id(name="builtin.cursor")
Amodels = bpy.data.objects['Skull'],bpy.data.objects['Mandible'], bpy.data.objects['upper'], bpy.data.objects['lower']
B=bpy.data.objects['Vert']
for a in Amodels:
copia = a.matrix_world.copy()
a.parent=None
a.matrix_world = copia
bpy.data.objects.remove(B, do_unlink=True)
areas=[]
width=[]
for a in bpy.data.screens['Layout'].areas:
if a.type == 'VIEW_3D':
if a.spaces[0].show_region_ui == False:
areas.append(a)
width.append(a.width)
minindex=width.index(min(width))
maxindex=width.index(max(width))
with context.temp_override(area=areas[minindex]):
bpy.ops.screen.area_close()
with context.temp_override(area=areas[maxindex]):
bpy.ops.screen.area_close()
bpy.context.screen.areas[0].spaces[0].show_region_hud = True
New_version=(5, 0, 2)
def draw(self, context):
layout=self.layout
layout.label(text="New Update available")
col = layout.column(align=False)
col.label(text=f"Do you want to update to Cavy {New_version}?")
row= col.row(align=True)
row.operator('object.update_cavy', text='Yes').url='https://articuladordigital.com/wp-content/uploads/2024/10/Articulador.zip'
row.operator('wm.swho_version', text='No')
def register():
for C in Classes:
bpy.utils.register_class(C)
bpy.types.Scene.free_mode = bpy.props.BoolProperty(name="Free mode", default=False, update=free,)
from Articulador import bl_info
if bl_info['version'] != New_version:
bpy.context.window_manager.popup_menu(draw, title = "Update", icon = 'INFO')
else:
print(bl_info['version'])
def unregister():
for C in Classes:
bpy.utils.unregister_class(C)
del bpy.types.Scene.free_mode
if __name__ == "__main__":
register()