Repository: cogitas3d/OrtogOnBlender Branch: master Commit: 881e93f5beb2 Files: 47 Total size: 1.1 MB Directory structure: gitextract_2f2snxll/ ├── AjustaTomo.py ├── AlinhaObjetos.py ├── AlinhaRedimensiona.py ├── AtualizaScript.py ├── BooleanaOsteo.py ├── CalculaPontos.py ├── Cefalometria.py ├── CompareOnBlender.py ├── CompareTools.py ├── ConfOsteotomiaAuto.py ├── CortaOssoFibula.py ├── CriaSplint.py ├── DesenhaGuia.py ├── DesenhaObjetos.py ├── DinamicaMole.py ├── FerrFisica.py ├── FerrImgTomo.py ├── FerrMalhas.py ├── FerrMedidas.py ├── FerrSegmentacao.py ├── ForensicObj.blend ├── ForensicOnBlender.py ├── ForensicTools.py ├── FotogrametriaMeshroom.py ├── FotogrametriaOpenMVG.py ├── FotogrametriaOpenMVGWinWSL.py ├── FotogrametriaSMVS.py ├── GeraModelosTomo.py ├── GeraRelatorio.py ├── ImportaObjMat.py ├── ListaArquivos.txt ├── MicrosGenerate3D.mlx ├── NomePaciente.py ├── OrtogMeshes.py ├── OtherOnBlender.py ├── Poisson.py ├── PontosAnatomicos.py ├── README.md ├── RelatorioAnimacao.py ├── RhinOnBlender.py ├── RhinOpenGL.py ├── RhinTools.py ├── SegmentaImagens.py ├── TomoReconsRapida.py ├── Version.py ├── __init__.py └── objetos.blend ================================================ FILE CONTENTS ================================================ ================================================ FILE: AjustaTomo.py ================================================ import bpy import os import os.path import json import re import shutil # from datetime import datetime import tempfile import os import platform import subprocess import pydicom as dicom import csv import fnmatch from os.path import expanduser from .GeraModelosTomo import * if platform.system() == "Darwin" or platform.system() == "Linux": import pyexifinfo as p def AjustaTomoDef(self, context): scn = context.scene #Cria diretorios temporarios e copia o conteudo para um deles #os.chdir('DEL') # scene = context.scene # rd = scene.render if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: tmpdirCopy = tempfile.mkdtemp() tmpdirTomo = tempfile.mkdtemp() shutil.copytree(scn.my_tool.path, tmpdirCopy+'COPY') # Lista os arquivos e salva arquivo de texto # Testa se existe e remove if os.path.exists('ListaArquivos.txt'): os.remove('ListaArquivos.txt') #for dirname, dirnames, filenames in os.walk('.'): for dirname, dirnames, filenames in os.walk(tmpdirCopy+'COPY'): # print path to all subdirectories first. # for subdirname in dirnames: # print(os.path.join(dirname, subdirname)) for filename in filenames: #print(os.path.join(dirname, filename)) ArquivosListados = os.path.join(dirname, filename)+'\n' with open("ListaArquivos.txt", "a") as arq: arq.write(ArquivosListados) arq.close() # Conta linhas do arquivo def obter_n_linhas (nomeDoArquivo): arquivo = open(nomeDoArquivo, "r") n_linhas = sum(1 for linha in arquivo) arquivo.close() return n_linhas def InstanceNumber(Arquivo): try: ds = dicom.dcmread(Arquivo, force=True) # Diretório e arquivo concatenados #ds = dicom.dcmread(Arquivo, force=True) # Diretório e arquivo concatenados instance_number = ds.data_element("InstanceNumber") instanceLimpa1 = str(instance_number).split('IS: ') instanceLimpa2 = str(instanceLimpa1[1]).strip('"') except: print("Não rolou leitura do DICOM!") instanceLimpa2 = "Error" return instanceLimpa2 NumeroLinhas = obter_n_linhas ('ListaArquivos.txt') #----------------------------------------------------------- # Le arquivo e cria pastas #ContadorLinhas = 0 with open('ListaArquivos.txt','r') as f: ListaArquivos=f.readlines() print("Criado Lista Arquivo1") DCMNum = 0 for x in range(NumeroLinhas): ArquivoAtual = ListaArquivos[x].strip('\n') # mostra linha 1 sem o caractere de quebra de linha # print(ArquivoAtual) DCMInstanceNumber = InstanceNumber(ArquivoAtual) os.chdir(tmpdirTomo) shutil.copy(ArquivoAtual, "Copy-"+DCMInstanceNumber.zfill(5)+"-"+str(DCMNum)) print("Copiado de: ", ArquivoAtual, " Para: ", "Copy-"+DCMInstanceNumber+"-"+str(DCMNum)) # shutil.copy(ArquivoAtual, str(datetime.now()).replace(":","").replace(".","").replace(" ","").replace("-","")) # print("Copiado de: ", ArquivoAtual, " Para: ", str(datetime.now()).replace(":","").replace(".","").replace(" ","").replace("-","")) # os.chdir('..') DCMNum += 1 # Lista os arquivos e salva arquivo de texto # Testa se existe e remove if os.path.exists('ListaArquivos.txt'): os.remove('ListaArquivos.txt') print("Apagado ListaArquivo") #for dirname, dirnames, filenames in os.walk('.'): for dirname, dirnames, filenames in os.walk(tmpdirTomo): # print path to all subdirectories first. # for subdirname in dirnames: # print(os.path.join(dirname, subdirname)) for filename in filenames: #print(os.path.join(dirname, filename)) ArquivosListados = os.path.join(dirname, filename)+'\n' with open('ListaArquivos.txt', "a") as arq: print("Criado ListaArquivo 2") arq.write(ArquivosListados) arq.close() # Conta linhas do arquivo def obter_n_linhas (nomeDoArquivo): arquivo = open(nomeDoArquivo, "r") n_linhas = sum(1 for linha in arquivo) arquivo.close() return n_linhas NumeroLinhas = obter_n_linhas ('ListaArquivos.txt') # Le arquivo e cria pastas #ContadorLinhas = 0 with open('ListaArquivos.txt','r') as f: ListaArquivos=f.readlines() # PYEXIFINFO if platform.system() == "Darwin" or platform.system() == "Linux": print("EH MAC E LIN") for x in range(NumeroLinhas): ArquivoAtual = ListaArquivos[x].strip('\n') # mostra linha 1 sem o caractere de quebra de linha # print(ArquivoAtual) data = p.get_json(ArquivoAtual) data2 = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')) with open("deletar.txt", "a") as arq: arq.write(data2) arq.close() palavra = "SeriesNumber" for line in open("deletar.txt"): if palavra in line: SeriesRaw = line SeriesLimpa1 = SeriesRaw.strip('"DICOM:SeriesNumber": "') SeriesLimpa2 = SeriesLimpa1.strip('",'+'\n') SeriesLimpo = SeriesLimpa2.strip(" ") print("SERIES", SeriesLimpo) if SeriesLimpo != '': if not os.path.exists(SeriesLimpo): os.mkdir(SeriesLimpo) if SeriesLimpo != '': shutil.copy(ArquivoAtual, SeriesLimpo) print("Copiado de: ", ArquivoAtual, " Para: ", SeriesLimpo) os.remove(ArquivoAtual) os.remove('deletar.txt') # PYTHON DICOM if platform.system() == "Windows": print("EH WIN") for x in range(NumeroLinhas): ArquivoAtual = ListaArquivos[x].strip('\n') # mostra linha 1 sem o caractere de quebra de linha print("AQUIVO ATUAL: "+ArquivoAtual) try: ds = dicom.dcmread(ArquivoAtual) series_number = ds.data_element("SeriesNumber") SeriesLimpa1 = str(series_number).strip('(0020, 0011) Series Number IS:') SeriesLimpo2 = SeriesLimpa1.strip('"') SeriesLimpo = SeriesLimpo2.strip(" ") except: print("Não rolou leitura do DICOM!") SeriesLimpo = "Error" if not os.path.exists(SeriesLimpo): os.mkdir(SeriesLimpo) print("Diretorio "+SeriesLimpo+" criado") #os.chdir(tmpdirTomo) shutil.copy(ArquivoAtual, SeriesLimpo) print("Copiado de: ", ArquivoAtual, " Para: ", SeriesLimpo) os.remove(ArquivoAtual) #os.remove('deletar.txt') # os.remove('deletar.txt') try: shutil.rmtree(tmpdirCopy+'COPY') shutil.rmtree(tmpdirCopy) except: print("Erro de permissão ao apagar os diretório do TMP!") print("CT-SCAN ready!") # Lista diretórios e arquivos try: tmpdirCSV = tempfile.mkdtemp() diretorio = tmpdirTomo+"/" lista_compara = [] lista = [ name for name in os.listdir(diretorio) if os.path.isdir(os.path.join(diretorio, name)) ] #print(lista) try: for i in lista: # print("\n") # print("Directory:", i) # print(os.listdir(diretorio+i)[0]) # print("Number of files:", len(os.listdir(diretorio+i))) ArquivoAtual = os.listdir(diretorio+i)[0] # print(diretorio+i+"/"+ArquivoAtual) ds = dicom.dcmread(diretorio+i+"/"+ArquivoAtual, force=True) if ds.data_element("SeriesDescription"): SeriesDescription = ds.data_element("SeriesDescription") SeriesDescriptionLimpa1 = str(SeriesDescription).split('LO: ') SeriesDescriptionLimpa2 = str(SeriesDescriptionLimpa1[1]).strip('"') # print(SeriesDescriptionLimpa2) # print("Directory:", i, "|| Number of files:", len(os.listdir(diretorio+i)), "||", SeriesDescriptionLimpa2, "\n") lista_compara.append([len(os.listdir(diretorio+i)), i, SeriesDescriptionLimpa2]) lista_compara.sort(reverse = True) #print("LISTA COMPARA!!!") #print(lista_compara) if not ds.data_element("SeriesDescription"): SeriesDescriptionLimpa2 = ("Erro O!") # print(SeriesDescriptionLimpa2) # print("Directory:", i, "|| Number of files:", len(os.listdir(diretorio+i)), "||", SeriesDescriptionLimpa2, "\n") lista_compara.append([len(os.listdir(diretorio+i)), i, SeriesDescriptionLimpa2]) lista_compara.sort(reverse = True) except: print("Erro no SeriesDescription") try: SeriesDescriptionLimpa2 = ("Erro 1!") # print(SeriesDescriptionLimpa2) # print("Directory:", i, "|| Number of files:", len(os.listdir(diretorio+i)), "||", SeriesDescriptionLimpa2, "\n") lista_compara.append([len(os.listdir(diretorio+i)), i, SeriesDescriptionLimpa2]) lista_compara.sort(reverse = True) except: print("Problema ao inserir o SeriesDescription!") lista_diretorios_mole = [] print("LISTA COMPARA MOLE", lista_compara) try: print("lista compara:",lista_compara) for i in lista_compara: print("Comecou a comparar!") print("i Atual:", i) if fnmatch.fnmatchcase(str(i[2]), "*PM*") or fnmatch.fnmatchcase(str(i[2]), "*P/M*") or fnmatch.fnmatchcase(str(i[2]), "*Soft*") or fnmatch.fnmatchcase(str(i[2]), "*Sft Tissue*") or fnmatch.fnmatchcase(str(i[2]), "*STD*") or fnmatch.fnmatchcase(str(i[2]), "*PARTES MOLES*") or fnmatch.fnmatchcase(str(i[2]), "*Head*") or fnmatch.fnmatchcase(str(i[2]), "*SEM CONTRASTE*") or fnmatch.fnmatchcase(str(i[2]), "*FACE*") or fnmatch.fnmatchcase(str(i[2]), "*Recon 3*") or fnmatch.fnmatchcase(str(i[2]), "*ARQUIVO*") or fnmatch.fnmatchcase(str(i[2]), "*RECON*") or fnmatch.fnmatchcase(str(i[2]), "*Cranio*") or fnmatch.fnmatchcase(str(i[2]), "*VOLUME STD*") or fnmatch.fnmatchcase(str(i[2]), "*VOL*") or fnmatch.fnmatchcase(str(i[2]), "*Imagens Processadas*"): print("Encontrou!") lista_diretorios_mole.append(i[1]) else: print("Não encontrou!") global diretorio_final_reconstruir_mole try: print("Diretorio final:", lista_diretorios_mole[0] ) print("Comparou!") diretorio_final_reconstruir_mole = lista_diretorios_mole[0] except: print("Diretorio final:", lista_diretorios_mole ) # Não sei pq!!! Se coloco index dá erro! print("Comparou!") diretorio_final_reconstruir_mole = lista_diretorios_mole except: print("Problema para encontrar diretório com tecido mole na tomo!") with open(tmpdirCSV+'/C-Scan_DATA.csv', mode='w') as centroid_file: report_writer = csv.writer(centroid_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) report_writer.writerow(['DIRECTORY', 'NUMBER OF FILES', 'DESCRIPTION']) if lista_compara == []: report_writer.writerow(["No data", "No data", "No data"]) if lista_compara != []: for linha in lista_compara: report_writer.writerow([linha[1],linha[0],linha[2]]) print("Directory:", linha[1], "|| Number of files", linha[0], "|| Description:", linha[2]) try: if platform.system() == "Linux": # abrir_diretorio(tmpdir) subprocess.Popen("libreoffice "+tmpdirCSV+"/C-Scan_DATA.csv", shell=True) if platform.system() == "Windows": # abrir_diretorio(tmpdir) subprocess.Popen('cd "C:/Program Files/LibreOffice/program/" & dir & soffice.bin '+tmpdirCSV+"/C-Scan_DATA.csv", shell=True) if platform.system() == "Darwin": # abrir_diretorio(tmpdir) subprocess.Popen('/Applications/LibreOffice.app/Contents/MacOS/soffice '+tmpdirCSV+"/C-Scan_DATA.csv", shell=True) except: print("Não há programa atribuído ao CSV!") except: print("Algum problema aconteceu com a leitura dos dados do tomógrafo.") try: with open(tmpdirCSV+'/C-Scan_DATA.csv', mode='w') as centroid_file: report_writer = csv.writer(centroid_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) report_writer.writerow(['DIRECTORY', 'NUMBER OF FILES', 'DESCRIPTION']) if lista_compara == []: report_writer.writerow(["No data", "No data", "No data"]) if lista_compara != []: for linha in lista_compara: report_writer.writerow([linha[1],linha[0],linha[2]]) print("Directory:", linha[1], "|| Number of files", linha[0], "|| Description:", linha[2]) try: if platform.system() == "Linux": # abrir_diretorio(tmpdir) subprocess.Popen("libreoffice "+tmpdirCSV+"/C-Scan_DATA.csv", shell=True) if platform.system() == "Windows": # abrir_diretorio(tmpdir) subprocess.Popen('cd "C:/Program Files/LibreOffice/program/" & dir & soffice.bin '+tmpdirCSV+"/C-Scan_DATA.csv", shell=True) if platform.system() == "Darwin": # abrir_diretorio(tmpdir) subprocess.Popen('/Applications/LibreOffice.app/Contents/MacOS/soffice '+tmpdirCSV+"/C-Scan_DATA.csv", shell=True) except: print("Não há programa atribuído ao CSV!") except: print("Problemas com o CSV!") # Atualiza path # abrir_diretorio(tmpdirTomo) scn.my_tool.path = tmpdirTomo+"/" try: with open(tmpdirTomo+'/AUTOEXPDIR.txt', "a") as arq: if diretorio_final_reconstruir_mole: arq.write(tmpdirTomo+"/"+diretorio_final_reconstruir_mole) if not diretorio_final_reconstruir_mole: arq.write(tmpdirTomo+"/") arq.close() except: print("Algum problema com a variável global do tecido mole!") class AjustaTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.ajusta_tomo" bl_label = "Ajusta Tomo" def execute(self, context): AjustaTomoDef(self, context) return {'FINISHED'} # --------------------------------------- def abrir_diretorio(path): if platform.system() == "Windows": os.startfile(path) elif platform.system() == "Darwin": subprocess.Popen(["open", path]) else: subprocess.Popen(["xdg-open", path]) def AbreTMPDef(self, context): scn = context.scene tmpdir = tempfile.gettempdir() abrir_diretorio(tmpdir) def CorrigeDicomDef(self, context): scn = context.scene homeall = expanduser("~") if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: # scene = context.scene # rd = scene.render tmpdirFIXED = tempfile.mkdtemp() # Cria arquivo com o nome do diretorio FIXED para ser acessado DirTemporario = tempfile.gettempdir() if os.path.isfile(DirTemporario+"/tmpdirFIXED.txt"): print("Apagando tmpdirFIXED.txt!") os.remove(DirTemporario+"/tmpdirFIXED.txt") if not os.path.isfile(DirTemporario+"/tmpdirFIXED.txt"): with open(DirTemporario+"/tmpdirFIXED.txt", 'w') as arquivo: arquivo.write(str(tmpdirFIXED)) print("DIRETÓRIO CORREÇÂO:", tmpdirFIXED) os.chdir(scn.my_tool.path) dirDICOM = scn.my_tool.path #os.makedirs("FIXED") if platform.system() == "Linux": os.system("dicomtodicom -o "+tmpdirFIXED+" *") # os.system("for i in *; do gdcmconv -X $i FIXED/$i; done") # print("TOMO AJUSTADA PELO GDCM") if platform.system() == "Darwin": os.system(homeall+"/Programs/OrtogOnBlender/vtk-dicom/./dicomtodicom --verbose -o "+tmpdirFIXED+" *") print("DICOM FIXED") if platform.system() == "Windows": os.chdir(scn.my_tool.path) os.system("C:\\OrtogOnBlender\\dicomtools\\dicomtodicom --verbose -o "+tmpdirFIXED+" *") print("C:\\OrtogOnBlender\\dicomtools\\dicomtodicom --verbose -o "+tmpdirFIXED+" *") a = os.path.isfile(tmpdirFIXED+"\\"+"IM-0001-0001.dcm") print("teste", a) print("Diretorio FIXED: ", tmpdirFIXED+"\\"+"IM-0001-0001.dcm") #print("DICOM FIXED") if os.path.isfile(tmpdirFIXED+"\\"+"IM-0001-0001.dcm"): print("EXISTE O ARQUIVO EM FIXED!") scn.my_tool.path = tmpdirFIXED return tmpdirFIXED if not os.path.isfile(tmpdirFIXED+"\\"+"IM-0001-0001.dcm"): tmpdirFIXED2 = tempfile.mkdtemp() print("TENTA WSL FIXED!!!") tmpdirFIXEDAtual = str(tmpdirFIXED2).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") #dirDICOMAtual = str(dirDICOM).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") os.chdir(dirDICOM) #print("wsl \"dicomtodicom\" -o \""+tmpdirFIXEDAtual+"\" \""+dirDICOMAtual+"\"") #print("wsl \"dicomtodicom\" -o \""+tmpdirFIXEDAtual+"\" *") #subprocess.call("wsl \"dicomtodicom\" -o \""+tmpdirFIXEDAtual+"\" \""+dirDICOMAtual+"\"", shell=True) subprocess.call("wsl \"dicomtodicom\" -o \""+tmpdirFIXEDAtual+"\" *", shell=True) scn.my_tool.path = tmpdirFIXED2 class CorrigeDicom(bpy.types.Operator): """Tooltip""" bl_idname = "object.corrige_dicom" bl_label = "Corrige DICOM" def execute(self, context): CorrigeDicomDef(self, context) return {'FINISHED'} ================================================ FILE: AlinhaObjetos.py ================================================ import bpy import math from .FerrMalhas import * # MENSAGENS class MessageSelecioneObjAlinhar(bpy.types.Operator): bl_idname = "object.dialog_operator_selecione_alinhar" bl_label = "Please, select the object to be aligned!" def execute(self, context): message = ("Please, select an object before!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageSelecioneObjAlinhar) class MessageFaltaPontoObj(bpy.types.Operator): bl_idname = "object.dialog_operator_falta_ponto_obj" bl_label = "Doesn't have one or more points or object!" def execute(self, context): message = ("Doesn't have one or more points or object!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageFaltaPontoObj) class MessageFaltaPonto(bpy.types.Operator): bl_idname = "object.dialog_operator_falta_ponto" bl_label = "Doesn't have one or more point!" def execute(self, context): message = ("Doesn't have one or more points!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageFaltaPonto) # Origin def EMP1aDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.empty_add(type='PLAIN_AXES') bpy.context.object.name = "EMP1a" #bpy.context.object.empty_draw_size = 3 bpy.context.object.empty_display_size = 3 class EMP1a(bpy.types.Operator): """Tooltip""" bl_idname = "object.emp1a" bl_label = "EMP1a" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'EMP1a' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): context = bpy.context obj = context.object if bpy.context.selected_objects == []: bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') return {'FINISHED'} else: EMP1aDef(self, context) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj return {'FINISHED'} def EMP2aDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.empty_add(type='PLAIN_AXES') bpy.context.object.name = "EMP2a" #bpy.context.object.empty_draw_size = 3 bpy.context.object.empty_display_size = 3 class EMP2a(bpy.types.Operator): """Tooltip""" bl_idname = "object.emp2a" bl_label = "EMP2a" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'EMP2a' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): context = bpy.context obj = context.object if bpy.context.selected_objects == []: bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') return {'FINISHED'} else: EMP2aDef(self, context) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj return {'FINISHED'} def EMP3aDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.empty_add(type='PLAIN_AXES') bpy.context.object.name = "EMP3a" #bpy.context.object.empty_draw_size = 3 bpy.context.object.empty_display_size = 3 class EMP3a(bpy.types.Operator): """Tooltip""" bl_idname = "object.emp3a" bl_label = "EMP3a" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'EMP3a' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): context = bpy.context obj = context.object if bpy.context.selected_objects == []: bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') return {'FINISHED'} else: EMP3aDef(self, context) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj return {'FINISHED'} # Align def EMP1bDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.empty_add(type='PLAIN_AXES') bpy.context.object.name = "EMP1b" #bpy.context.object.empty_draw_size = 3 bpy.context.object.empty_display_size = 3 class EMP1b(bpy.types.Operator): """Tooltip""" bl_idname = "object.emp1b" bl_label = "EMP1b" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'EMP1b' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): context = bpy.context obj = context.object if bpy.context.selected_objects == []: bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') return {'FINISHED'} else: EMP1bDef(self, context) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj return {'FINISHED'} def EMP2bDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.empty_add(type='PLAIN_AXES') bpy.context.object.name = "EMP2b" #bpy.context.object.empty_draw_size = 3 bpy.context.object.empty_display_size = 3 class EMP2b(bpy.types.Operator): """Tooltip""" bl_idname = "object.emp2b" bl_label = "EMP2b" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'EMP2b' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): context = bpy.context obj = context.object if bpy.context.selected_objects == []: bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') return {'FINISHED'} else: EMP2bDef(self, context) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj return {'FINISHED'} def EMP3bDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.empty_add(type='PLAIN_AXES') bpy.context.object.name = "EMP3b" #bpy.context.object.empty_draw_size = 3 bpy.context.object.empty_display_size = 3 class EMP3b(bpy.types.Operator): """Tooltip""" bl_idname = "object.emp3b" bl_label = "EMP3b" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'EMP3b' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): context = bpy.context obj = context.object if bpy.context.selected_objects == []: bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') return {'FINISHED'} else: EMP3bDef(self, context) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj return {'FINISHED'} def AlinhaTresPontosDef(self, context): context = bpy.context objAlinhar = context.active_object # if bpy.context.selected_objects == []: # bpy.ops.object.dialog_operator_selecione_alinhar('INVOKE_DEFAULT') # return {'FINISHED'} if bpy.data.objects.get('EMP1a') and bpy.data.objects.get('EMP2a') and bpy.data.objects.get('EMP3a') and bpy.data.objects.get('EMP1b') and bpy.data.objects.get('EMP2b') and bpy.data.objects.get('EMP3b'): # Adiciona plano Origem bpy.ops.mesh.add_mesh_alinha_origi() bpy.context.object.name = "MeshAlignOrigi" # Força nome para não dar erro # Seleciona pontos bpy.ops.object.mode_set(mode = 'OBJECT') obj = bpy.context.active_object bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.object.mode_set(mode = 'OBJECT') obj.data.vertices[0].select = True obj.data.vertices[1].select = True obj.data.vertices[2].select = True bpy.ops.object.mode_set(mode = 'EDIT') # Seleciona os pontos de rotação bpy.ops.maplus.quickalignplanesgrabdest() # Sai do modo de edição bpy.ops.object.mode_set(mode='OBJECT') # Adiciona plano a Alinhar bpy.ops.mesh.add_mesh_alinha_alinha() bpy.context.object.name = "MeshAlignAlign" # Força nome para não dar erro objMalhaAlinha = context.active_object # Seleciona os pontos bpy.ops.object.mode_set(mode = 'OBJECT') obj = bpy.context.active_object bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.object.mode_set(mode = 'OBJECT') obj.data.vertices[0].select = True obj.data.vertices[1].select = True obj.data.vertices[2].select = True bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.object.mode_set(mode='OBJECT') # Sai do modo de edição bpy.ops.object.select_all(action='DESELECT') objAlinhar.select_set(True) objMalhaAlinha.select_set(True) bpy.context.view_layer.objects.active = objMalhaAlinha # Agrupa malha e objeto bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') objMalhaAlinha.select_set(True) bpy.context.view_layer.objects.active = objMalhaAlinha # Alinha planos bpy.ops.maplus.quickalignplanesobject() # Desparenteia rotacionado bpy.ops.object.select_all(action='DESELECT') objAlinhar.select_set(True) bpy.context.view_layer.objects.active = objAlinhar bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') # Apaga objetos bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['EMP1a'].select_set(True) bpy.data.objects['EMP2a'].select_set(True) bpy.data.objects['EMP3a'].select_set(True) bpy.data.objects['EMP1b'].select_set(True) bpy.data.objects['EMP2b'].select_set(True) bpy.data.objects['EMP3b'].select_set(True) bpy.data.objects['MeshAlignOrigi'].select_set(True) bpy.data.objects['MeshAlignAlign'].select_set(True) bpy.context.view_layer.objects.active = objMalhaAlinha bpy.ops.object.delete(use_global=False) # Seleciona objeto alinhado bpy.ops.object.select_all(action='DESELECT') objAlinhar.select_set(True) bpy.context.view_layer.objects.active = objAlinhar else: bpy.ops.object.dialog_operator_falta_ponto('INVOKE_DEFAULT') ''' context = bpy.context ObjAlinha = context.object EMP1a = bpy.data.objects['EMP1a'] EMP2a = bpy.data.objects['EMP2a'] EMP3a = bpy.data.objects['EMP3a'] # EMP4a bpy.ops.object.empty_add(type='SPHERE', location=((EMP2a.location[0]+EMP3a.location[0])/2, (EMP2a.location[1]+EMP3a.location[1])/2, (EMP2a.location[2]+EMP3a.location[2])/2)) bpy.context.object.name = "EMP4a" EMP4a = bpy.data.objects['EMP4a'] EMP1b = bpy.data.objects['EMP1b'] EMP2b = bpy.data.objects['EMP2b'] EMP3b = bpy.data.objects['EMP3b'] bpy.ops.object.empty_add(type='SPHERE', location=((EMP2b.location[0]+EMP3b.location[0])/2, (EMP2b.location[1]+EMP3b.location[1])/2, (EMP2b.location[2]+EMP3b.location[2])/2)) bpy.context.object.name = "EMP4b" EMP4b = bpy.data.objects['EMP4b'] # Alinha no molde EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) bpy.ops.object.parent_set() # Alinha com o EMP4b ao EMP4a bpy.ops.object.select_all(action='DESELECT') EMP4b.select_set(True) context.view_layer.objects.active = EMP4b bpy.context.object.location = EMP4a.location bpy.ops.object.select_all(action='DESELECT') EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') # Calcula grau A = math.sqrt((EMP2b.location[0] - EMP4a.location[0])**2 + (EMP2b.location[2] - EMP4a.location[2])**2) B = math.sqrt((EMP2b.location[0] - EMP2a.location[0])**2 + (EMP2b.location[2] - EMP2a.location[2])**2) C = math.sqrt((EMP2a.location[0] - EMP4a.location[0])**2 + (EMP2a.location[2] - EMP4a.location[2])**2) AngEMP4ab = (C**2 + A**2 - B**2) / (2 * C * A) # Parênteses importantes!!! # Radianos RotacaoY = math.acos(AngEMP4ab) # Ângulo math.acos(AngEMP4ab)* 180/math.pi bpy.ops.object.select_all(action='DESELECT') EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) EMP4b.select_set(True) context.view_layer.objects.active = EMP4b bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') EMP4b.select_set(True) context.view_layer.objects.active = EMP4b # Rotação Y if EMP2a.location[2] < EMP2b.location[2]: bpy.ops.transform.rotate(value=RotacaoY, orient_axis='Y', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) if EMP2a.location[2] > EMP2b.location[2]: bpy.ops.transform.rotate(value=-abs(RotacaoY), orient_axis='Y', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) # Desagrupa para cálculo bpy.ops.object.select_all(action='DESELECT') EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') A = math.sqrt((EMP1b.location[1] - EMP4a.location[1])**2 + (EMP1b.location[2] - EMP4a.location[2])**2) B = math.sqrt((EMP1b.location[1] - EMP1a.location[1])**2 + (EMP1b.location[2] - EMP1a.location[2])**2) C = math.sqrt((EMP1a.location[1] - EMP4a.location[1])**2 + (EMP1a.location[2] - EMP4a.location[2])**2) AngEMP4ab = (C**2 + A**2 - B**2) / (2 * C * A) # Radianos RotacaoX = math.acos(AngEMP4ab) # Ângulo math.acos(AngEMP4ab)* 180/math.pi bpy.ops.object.select_all(action='DESELECT') EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) EMP4b.select_set(True) context.view_layer.objects.active = EMP4b bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') EMP4b.select_set(True) context.view_layer.objects.active = EMP4b if EMP1a.location[2] < EMP1b.location[2]: bpy.ops.transform.rotate(value=RotacaoX, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) if EMP1a.location[2] > EMP1b.location[2]: bpy.ops.transform.rotate(value=-abs(RotacaoX), orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) # Desagrupa para cálculo bpy.ops.object.select_all(action='DESELECT') EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') A = math.sqrt((EMP1b.location[0] - EMP4a.location[0])**2 + (EMP1b.location[1] - EMP4a.location[1])**2) B = math.sqrt((EMP1b.location[0] - EMP1a.location[0])**2 + (EMP1b.location[1] - EMP1a.location[1])**2) C = math.sqrt((EMP1a.location[0] - EMP4a.location[0])**2 + (EMP1a.location[1] - EMP4a.location[1])**2) AngEMP4ab = (C**2 + A**2 - B**2) / (2 * C * A) print("Angulo grosso", AngEMP4ab) # Radianos RotacaoZ = math.acos(AngEMP4ab) # Ângulo AnguloZ = math.acos(AngEMP4ab)* 180/math.pi bpy.ops.object.select_all(action='DESELECT') EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) ObjAlinha.select_set(True) EMP4b.select_set(True) context.view_layer.objects.active = EMP4b bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') EMP4b.select_set(True) context.view_layer.objects.active = EMP4b if EMP1a.location[0] > EMP1b.location[0]: bpy.ops.transform.rotate(value=RotacaoZ, orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) if EMP1a.location[0] < EMP1b.location[0]: bpy.ops.transform.rotate(value=-abs(RotacaoZ), orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) # Apaga referências bpy.ops.object.select_all(action='DESELECT') EMP1a.select_set(True) EMP2a.select_set(True) EMP3a.select_set(True) EMP4a.select_set(True) EMP1b.select_set(True) EMP2b.select_set(True) EMP3b.select_set(True) EMP4b.select_set(True) bpy.ops.object.delete() ''' class AlinhaTresPontos(bpy.types.Operator): """Tooltip""" bl_idname = "object.alinha_tres_pontos" bl_label = "Align 3 Points" @classmethod def poll(cls, context): if len(bpy.context.selected_objects) == 1: return True else: if len(bpy.context.selected_objects) != 1: return False def execute(self, context): AlinhaTresPontosDef(self, context) return {'FINISHED'} def AlinhaCranioFrankfurtDef(): context = bpy.context if bpy.data.objects.get('Bones') and bpy.data.objects.get('Orbital right') and bpy.data.objects.get('Orbital left') and bpy.data.objects.get('Po left') and bpy.data.objects.get('N point'): def CriaLinhaALinha(Obj1, Obj2, Nome): Ponto1 = bpy.data.objects[Obj1].location Ponto2 = bpy.data.objects[Obj2].location verts = [Ponto1, Ponto2, ] edges = [[0,1]] faces = [] mesh_data = bpy.data.meshes.new("Apaga") mesh_data.from_pydata(verts, edges, faces) mesh_data.update() obj = bpy.data.objects.new(Nome, mesh_data) context = bpy.context scene = bpy.context.scene #scene.objects.link(obj) bpy.context.collection.objects.link(obj) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj CriaLinhaALinha('Orbital right', 'Orbital left', 'LinhaOrbAlinha') ObjDestino = context.view_layer.objects.active print(ObjDestino.name) bpy.ops.mesh.add_linhabase(location=(0, 0, 0), rotation=(0, -1.5708, 0)) ObjOrigem = context.view_layer.objects.active print(ObjOrigem.name) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.maplus.quickalignlinesgrabdest() bpy.ops.object.mode_set(mode = 'OBJECT') # Parenteia objetos à Linha bpy.ops.object.select_all(action='DESELECT') ListaObjetos = ['Bones', 'Orbital right', 'Orbital left', 'Po left', 'N point'] for i in ListaObjetos: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) ObjDestino.select_set(True) context.view_layer.objects.active = ObjDestino bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ObjDestino.select_set(True) context.view_layer.objects.active = ObjDestino bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.maplus.quickalignlinesobject() bpy.ops.object.mode_set(mode = 'OBJECT') # Desagrupa for i in ListaObjetos: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.ops.object.select_all(action='DESELECT') ObjDestino.select_set(True) ObjOrigem.select_set(True) bpy.ops.object.delete(use_global=False) #LINHA LATERAL bpy.ops.mesh.add_linhabase(location=(200, 0, 0), rotation=(1.5708, 0, 0)) ObjOrigem2 = context.view_layer.objects.active print("Origem:", ObjOrigem2.name) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.maplus.quickalignlinesgrabdest() bpy.ops.object.mode_set(mode = 'OBJECT') CriaLinhaALinha('Orbital left', 'Po left', 'LinhaOrbAlinha2') ObjDestino2 = context.view_layer.objects.active print(ObjDestino2.name) bpy.ops.transform.resize(value=(0, 1, 1), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) # Parenteia objetos à Linha bpy.ops.object.select_all(action='DESELECT') ListaObjetos = ['Bones', 'Orbital right', 'Orbital left', 'Po left', 'N point'] for i in ListaObjetos: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) ObjDestino2.select_set(True) context.view_layer.objects.active = ObjDestino2 bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ObjDestino2.select_set(True) context.view_layer.objects.active = ObjDestino2 bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.maplus.quickalignlinesobject() bpy.ops.object.mode_set(mode = 'OBJECT') # Desagrupa for i in ListaObjetos: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.ops.object.select_all(action='DESELECT') ObjDestino2.select_set(True) ObjOrigem2.select_set(True) bpy.ops.object.delete(use_global=False) # MOVE AO CENTRO bpy.ops.object.select_all(action='DESELECT') ListaObjetos2 = ['Bones', 'Orbital right', 'Orbital left', 'Po left'] PontoCentral = bpy.data.objects['N point'] for i in ListaObjetos2: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) PontoCentral .select_set(True) context.view_layer.objects.active = PontoCentral bpy.ops.object.parent_set() PontoCentral = bpy.context.object.location = 0,0,0 # Desagrupa for i in ListaObjetos2: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') else: bpy.ops.object.dialog_operator_falta_ponto_obj('INVOKE_DEFAULT') class AlinhaCranioFrankfurt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alinha_cranio_frankfurt" bl_label = "Align 3 Points" def execute(self, context): AlinhaCranioFrankfurtDef() return {'FINISHED'} bpy.utils.register_class(AlinhaCranioFrankfurt) class OcultaMole(bpy.types.Operator): """Tooltip""" bl_idname = "object.oculta_mole" bl_label = "Hide Face" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): bpy.data.objects['SoftTissue'].hide_viewport=True return {'FINISHED'} bpy.utils.register_class(OcultaMole) def PreparaMandibulaCmDef(): SelecionaObjeto("cm") bpy.ops.object.duplicate() bpy.context.object.name = "cm_COPY" objeto = bpy.data.objects["cm_COPY"] objeto.animation_data_clear() bpy.data.objects["cm"].hide_viewport = True ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) for x in objeto.material_slots: objeto.active_material_index = 0 bpy.ops.object.material_slot_remove() if 'MatMandibulaAlinha' in ListaMateriais: activeObject = objeto mat = bpy.data.materials["MatMandibulaAlinha"] activeObject.data.materials.append(mat) bpy.context.object.active_material.diffuse_color = (0.19, 0.5, 0.8, 1) else: activeObject = objeto mat = bpy.data.materials.new(name="MatMandibulaAlinha") activeObject.data.materials.append(mat) bpy.context.object.active_material.diffuse_color = (0.19, 0.5, 0.8, 1) class PreparaMandibulaCm(bpy.types.Operator): """Tooltip""" bl_idname = "object.prepara_mandibula_cm" bl_label = "Prepare Mandible cm" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'cm_COPY' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): PreparaMandibulaCmDef() return {'FINISHED'} bpy.utils.register_class(PreparaMandibulaCm) def FinalizaMandibulaCmDef(): bpy.context.scene.frame_current = 100 bpy.data.objects["cm"].hide_viewport = False SelecionaObjeto("cm") cmCopyLoc = bpy.data.objects['cm_COPY'].location cmCopyRoc = bpy.data.objects['cm_COPY'].rotation_euler cm = bpy.data.objects['cm'] cm.location = cmCopyLoc cm.rotation_euler = cmCopyRoc bpy.ops.anim.ortog_loc_rot() SelecionaObjeto("cm_COPY") bpy.ops.object.delete(use_global=False) class FinalizaMandibulaCm(bpy.types.Operator): """Tooltip""" bl_idname = "object.finaliza_mandibula_cm" bl_label = "Finish Mandible cm" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): FinalizaMandibulaCmDef() return {'FINISHED'} bpy.utils.register_class(FinalizaMandibulaCm) ================================================ FILE: AlinhaRedimensiona.py ================================================ import bpy import math import fnmatch # MENSAGENS class MessageSelecioneObj(bpy.types.Operator): bl_idname = "object.dialog_operator_selecione" bl_label = "Please, select an object before!" def execute(self, context): message = ("Please, select an object before!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageSelecioneObj) class MessageColoqueValor(bpy.types.Operator): bl_idname = "object.dialog_operator_coloque_valor" bl_label = "Please, inform a value on Real Size!" def execute(self, context): message = ("Please, inform a value on Real Size!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageColoqueValor) # COMANDOS def CriaBaseOrigem(): bpy.ops.object.empty_add(type='PLAIN_AXES', view_align=False, location=(-1, 0, 1)) bpy.context.object.name = "EMP1a" bpy.ops.object.empty_add(type='PLAIN_AXES', view_align=False, location=(1, 0, 1)) bpy.context.object.name = "EMP2a" bpy.ops.object.empty_add(type='PLAIN_AXES', view_align=False, location=(0, 0, -1)) bpy.context.object.name = "EMP3a" bpy.ops.object.select_all(action='DESELECT') def Redimensiona(self, context): global EMP1EMP2, medidareal2 context = bpy.context FACE = context.active_object EMP1 = bpy.data.objects['EMP1b'] # Olho direito EMP2 = bpy.data.objects['EMP2b'] # Olho esquerdo EMP3 = bpy.data.objects['EMP3b'] # Ponto inferior bpy.ops.object.empty_add(type='SPHERE', location=((EMP1.location[0]+EMP2.location[0])/2, (EMP1.location[1]+EMP2.location[1])/2, (EMP1.location[2]+EMP2.location[2])/2)) bpy.context.object.name = "PT_Origem" EMP4 = bpy.data.objects['PT_Origem'] l = [] EMP1EMP2 = [EMP1, EMP2] for item in EMP1EMP2: l.append(item.location) medidaAtual2 = math.sqrt( (l[0][0] - l[1][0])**2 + (l[0][1] - l[1][1])**2 + (l[0][2] - l[1][2])**2) print(medidaAtual2) medidaReal2 = float(bpy.context.scene.medida_real2) # Redimensiona fatorEscala2 = medidaReal2 / medidaAtual2 bpy.ops.object.select_all(action='DESELECT') EMP1.select_set(True) EMP2.select_set(True) EMP3.select_set(True) EMP4.select_set(True) FACE.select_set(True) bpy.context.view_layer.objects.active = EMP4 bpy.ops.object.parent_set() EMP4.scale = ( fatorEscala2, fatorEscala2, fatorEscala2 ) # bpy.ops.object.select_all(action='DESELECT') # FACE.select = True # bpy.context.scene.objects.active = FACE # FACE.scale = ( fatorEscala2, fatorEscala2, fatorEscala2 ) print("Medida Atual:", medidaAtual2) print("Medida Real: ", medidaReal2) print("Fator de Escala: ", fatorEscala2) bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) bpy.ops.object.select_all(action='DESELECT') # EMP1.select_set(True) # EMP2.select_set(True) # EMP3.select_set(True) EMP4.select_set(True) bpy.context.view_layer.objects.active = EMP1 bpy.ops.object.delete(use_global=False) FACE.select_set(True) bpy.context.view_layer.objects.active = FACE bpy.ops.object.transform_apply() # É necessário colocar os () bpy.ops.view3d.view_axis(type='FRONT') # bpy.ops.view3d.viewnumpad(type='FRONT') bpy.ops.view3d.view_selected() #bpy.ops.view3d.view_all(center=True) # Centraliza zoom for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) class AlinhaForcaBtn(bpy.types.Operator): """Tooltip""" bl_idname = "object.alinha_forca" bl_label = "Cálculo de Alinhamento da Mandíbula" def execute(self, context): context = bpy.context obj = context.active_object scn = context.scene if bpy.context.scene.medida_real2 == "None": bpy.ops.object.dialog_operator_coloque_valor('INVOKE_DEFAULT') else: CriaBaseOrigem() print("OBJETOS CRIADOS!!!") obj.select_set(True) bpy.context.view_layer.objects.active = obj Redimensiona(self, context) bpy.ops.object.alinha_tres_pontos() bpy.context.object.location[0] = 0 bpy.context.object.location[1] = 0 bpy.context.object.location[2] = 0 bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) # Centraliza zoom for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) # ApagaPontosAlinhaDef() # ApagaPontosOrigemDef() # bpy.ops.object.transform_apply return {'FINISHED'} bpy.utils.register_class(AlinhaForcaBtn) # Alinhamento por ICP def ForceICPDef(self, context): # TESTA SE TEM MAIS DO QUE 200 K??? context = bpy.context if len(context.selected_objects) == 2: ativo_antigo = context.view_layer.objects.active.name # print("Objeto ativo:", ativo_antigo) for i in bpy.context.selected_objects: if i.name != ativo_antigo: context.view_layer.objects.active = i # print("Deu certo?", i.name) bpy.ops.object.align_icp() bpy.ops.object.align_icp() bpy.ops.object.align_icp() bpy.ops.object.align_icp() bpy.ops.object.align_icp() bpy.ops.object.align_icp() bpy.ops.object.align_icp() bpy.ops.object.align_icp() class ForceICP(bpy.types.Operator): """Tooltip""" bl_idname = "object.force_icp" bl_label = "Force_ICP" @classmethod def poll(cls, context): condition_1 = len(context.selected_objects) == 2 conidion_2 = context.object.type == 'MESH' return condition_1 and condition_1 def execute(self, context): ForceICPDef(self, context) return {'FINISHED'} bpy.utils.register_class(ForceICP) ================================================ FILE: AtualizaScript.py ================================================ import bpy import subprocess import platform from os.path import expanduser def AtualizaScriptDef(self, context): if platform.system() == "Windows": # subprocess.call('cd C:\OrtogOnBlender\Blender\2.78\scripts\addons\OrtogOnBlender-master && atualiza_ortog.bat', shell=True) arquivo = open('atualiza_ortog.bat', 'w+') arquivo.writelines("""cd C:/OrtogOnBlender/Blender280/2.80/scripts/addons && ^ rd /s /q OrtogOnBlender-master && ^ C:/OrtogOnBlender/Python27/python.exe -c "import urllib; urllib.urlretrieve ('http://www.ciceromoraes.com.br/downloads/OrtogOnBlender/addon/280/OrtogOnBlender-master.zip', 'OrtogOnBlender-master.zip')" && ^ C:/OrtogOnBlender/7-Zip/7z x OrtogOnBlender-master.zip && ^ del OrtogOnBlender-master.zip""") arquivo.close() subprocess.call('atualiza_ortog.bat', shell=True) if platform.system() == "Linux": home = expanduser("~") arquivo = open(home+'/Programs/OrtogOnBlender/Blender280/atualiza_ortog.sh', 'w+') arquivo.writelines("""cd $HOME/Downloads && rm -Rfv OrtogOnBlender-master* && \ if [ -f "OrtogOnBlender-master.zip" ]; then echo "tem arquivo" && rm OrtogOnBlender-master.zi*; fi && \ wget http://www.ciceromoraes.com.br/downloads/OrtogOnBlender/addon/280/OrtogOnBlender-master.zip && \ rm -Rfv $HOME/.config/blender/2.80/scripts/addons/OrtogOnBlender-master && \ unzip OrtogOnBlender-master.zip && \ cp -Rv OrtogOnBlender-master $HOME/.config/blender/2.80/scripts/addons/""") arquivo.close() subprocess.call('chmod +x '+home+'/Programs/OrtogOnBlender/Blender280/atualiza_ortog.sh && '+home+'/Programs/OrtogOnBlender/Blender280/atualiza_ortog.sh', shell=True) if platform.system() == "Darwin": arquivo = open('atualiza_ortog.sh', 'w+') arquivo.writelines("""cd $HOME/Downloads && rm -Rfv OrtogOnBlender-master* && \ if [ -f "OrtogOnBlender-master.zip" ]; then echo "tem arquivo" && rm OrtogOnBlender-master.zi*; fi && \ wget http://www.ciceromoraes.com.br/downloads/OrtogOnBlender/addon/280/OrtogOnBlender-master.zip && \ rm -Rfv $HOME/Library/Application\ Support/Blender/2.80/scripts/addons/OrtogOnBlender-master && \ unzip OrtogOnBlender-master.zip && \ mv OrtogOnBlender-master $HOME/Library/Application\ Support/Blender/2.80/scripts/addons/""") arquivo.close() subprocess.call('chmod +x atualiza_ortog.sh && ./atualiza_ortog.sh', shell=True) class AtualizaScript(bpy.types.Operator): """Tooltip""" bl_idname = "object.atualiza_script" bl_label = "Atualiza Script" def execute(self, context): AtualizaScriptDef(self, context) bpy.ops.wm.quit_blender() return {'FINISHED'} ================================================ FILE: BooleanaOsteo.py ================================================ import bpy import os import tempfile import subprocess import platform from os.path import expanduser class MessageErroCollection(bpy.types.Operator): bl_idname = "object.dialog_operator_erro_collection" bl_label = "All objects have to be in Colletion, use M!" def execute(self, context): message = ("All objects have to be in Colletion, use M!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageErroCollection) def BooleanaMandDef(self, context): context = bpy.context scn = context.scene tmpdir = tempfile.mkdtemp() #objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select ] A = bpy.data.objects['Bones'] B = context.active_object #objetos_selecionados[0] # Infla o objeto bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action = 'SELECT') bpy.ops.transform.shrink_fatten(value=-1.61748, use_even_offset=False, mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.mode_set(mode = 'OBJECT') bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 7 # Seleciona objeto A A.hide_viewport=False bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/A.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True # ---------------------- # Cria objeto B bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/B.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLETION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True # bpy.ops.object.move_to_layer(layers=(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False)) # ------------------- bpy.ops.object.select_all(action='DESELECT') # Booleana if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Skull.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Skull.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -isct '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Mandible.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Mandible.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Skull.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Skull.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -isct '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Mandible.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Mandible.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Darwin": homeall = expanduser("~") subprocess.call(homeall+'/Programs/OrtogOnBlender/Cork/./cork -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Skull.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Skull.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') subprocess.call(homeall+'/Programs/OrtogOnBlender/Cork/./cork -isct '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Mandible.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Mandible.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') Mandible = bpy.data.objects['Mandible'] bpy.ops.object.select_all(action='DESELECT') Mandible.select_set(True) bpy.context.view_layer.objects.active = Mandible bpy.ops.object.move_to_collection(collection_index=1) class BooleanaMand(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_mandib" bl_label = "Booleanas da mandíbula" def execute(self, context): BooleanaMandDef(self, context) return {'FINISHED'} def BooleanaOsteoDef(self, context): context = bpy.context # obj = context.active_object scn = context.scene objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] lista_colecoes = [] for i in objetos_selecionados: lista_colecoes.append(i.users_collection[0].name) lista_final = [] for i in lista_colecoes: if i != 'Collection': lista_final.append("FORA") if "FORA" in lista_final: bpy.ops.object.dialog_operator_erro_collection('INVOKE_DEFAULT') else: tmpdir = tempfile.mkdtemp() # objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] # A = objetos_selecionados[1] # B = objetos_selecionados[0] B = bpy.data.objects['Corte'] A = context.active_object #objetos_selecionados[0] # Cria objeto A bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/A.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True # Cria objeto B bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/B.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True bpy.ops.object.select_all(action='DESELECT') # Booleana if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Darwin": homeall = expanduser("~") subprocess.call(homeall+'/Programs/OrtogOnBlender/Cork/./cork -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # Result = context.active_object # Result = bpy.context.view_layer.objects.active objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] try: bpy.data.collections['Collection'].objects.link(objetos_selecionados[0]) except: print("O objeto já está na Collecion!") # obj = context.active_object bpy.ops.mesh.separate(type='LOOSE') objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] for i in objetos_selecionados: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.move_to_collection(collection_index=1) class BooleanaOsteoClass(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_osteo" bl_label = "Importa fatias de tomografia DICOM" def execute(self, context): BooleanaOsteoDef(self, context) # bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} def BooleanaOsteoGeralDef(self, context): context = bpy.context # obj = context.active_object scn = context.scene objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] lista_colecoes = [] for i in objetos_selecionados: lista_colecoes.append(i.users_collection[0].name) lista_final = [] for i in lista_colecoes: if i != 'Collection': lista_final.append("FORA") if "FORA" in lista_final: bpy.ops.object.dialog_operator_erro_collection('INVOKE_DEFAULT') else: tmpdir = tempfile.mkdtemp() B = bpy.context.view_layer.objects.active print("Objeto B:", B) for i in bpy.context.selected_objects: if i.name != B.name: A = i print("Objeto A:", A.name) # B = bpy.context.selected_objects[1] # B = bpy.data.objects['Corte'] # A = context.active_object #objetos_selecionados[0] # Remover vértices duplos bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A if A.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B if B.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") # Cria objeto A bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/A.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) else: obj = context.active_object bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) bpy.data.collections['Copied_Objects'].hide_viewport=True # Cria objeto B bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/B.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) else: obj = context.active_object bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True bpy.ops.object.select_all(action='DESELECT') # OCulta objetos originais A.hide_viewport=True B.hide_viewport=True # Booleana if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Darwin": homeall = expanduser("~") subprocess.call(homeall+'/Programs/OrtogOnBlender/Cork/./cork -diff '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # Result = context.active_object # Result = bpy.context.view_layer.objects.active # objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] # bpy.data.collections['Collection'].objects.link(objetos_selecionados[0]) # bpy.data.collections['Collection'].objects.link(bpy.context.selected_objects[0]) bpy.ops.mesh.separate(type='LOOSE') objetos_selecionados = [ o for o in bpy.context.selected_objects ] for i in objetos_selecionados: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.move_to_collection(collection_index=1) class BooleanaOsteoGeral(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_osteo_geral" bl_label = "Importa fatias de tomografia DICOM" def execute(self, context): BooleanaOsteoGeralDef(self, context) # bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} # Booleana Union def BooleanaOsteoUnionDef(self, context): context = bpy.context # obj = context.active_object scn = context.scene objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] lista_colecoes = [] for i in objetos_selecionados: lista_colecoes.append(i.users_collection[0].name) lista_final = [] for i in lista_colecoes: if i != 'Collection': lista_final.append("FORA") if "FORA" in lista_final: bpy.ops.object.dialog_operator_erro_collection('INVOKE_DEFAULT') else: tmpdir = tempfile.mkdtemp() B = bpy.context.view_layer.objects.active print("Objeto B:", B) for i in bpy.context.selected_objects: if i.name != B.name: A = i print("Objeto A:", A.name) # B = bpy.context.selected_objects[1] # B = bpy.data.objects['Corte'] # A = context.active_object #objetos_selecionados[0] # Remover vértices duplos bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A if A.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B if B.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") # Cria objeto A bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/A.off") bpy.ops.object.modifier_remove(modifier="Triangulate") # obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) else: obj = context.active_object bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) bpy.data.collections['Copied_Objects'].hide_viewport=True # Cria objeto B bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/B.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True bpy.ops.object.select_all(action='DESELECT') # OCulta objetos originais # A.hide_viewport=True # B.hide_viewport=True # Booleana if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -union '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -union '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Darwin": homeall = expanduser("~") subprocess.call(homeall+'/Programs/OrtogOnBlender/Cork/./cork -union '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # Result = context.active_object # Result = bpy.context.view_layer.objects.active # objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] # bpy.data.collections['Collection'].objects.link(objetos_selecionados[0]) # bpy.data.collections['Collection'].objects.link(bpy.context.selected_objects[0]) bpy.ops.mesh.separate(type='LOOSE') objetos_selecionados = [ o for o in bpy.context.selected_objects ] for i in objetos_selecionados: if i.visible_get() == True: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.move_to_collection(collection_index=1) class BooleanaOsteoUnion(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_osteo_union" bl_label = "Importa fatias de tomografia DICOM" def execute(self, context): BooleanaOsteoUnionDef(self, context) #g bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} bpy.utils.register_class(BooleanaOsteoUnion) # Booleana Intersect def BooleanaOsteoInterDef(self, context): context = bpy.context # obj = context.active_object scn = context.scene objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] lista_colecoes = [] for i in objetos_selecionados: lista_colecoes.append(i.users_collection[0].name) lista_final = [] for i in lista_colecoes: if i != 'Collection': lista_final.append("FORA") if "FORA" in lista_final: bpy.ops.object.dialog_operator_erro_collection('INVOKE_DEFAULT') else: tmpdir = tempfile.mkdtemp() B = bpy.context.view_layer.objects.active print("Objeto B:", B) for i in bpy.context.selected_objects: if i.name != B.name: A = i print("Objeto A:", A.name) # B = bpy.context.selected_objects[1] # B = bpy.data.objects['Corte'] # A = context.active_object #objetos_selecionados[0] # Remover vértices duplos bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A if A.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B if B.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") # Cria objeto A bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/A.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) else: obj = context.active_object bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) bpy.data.collections['Copied_Objects'].hide_viewport=True # Cria objeto B bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/B.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') try: bpy.data.collections['Collection'].objects.unlink(obj2) except: print("Não está no Collection!") bpy.data.collections['Copied_Objects'].hide_viewport=True bpy.ops.object.select_all(action='DESELECT') # OCulta objetos originais A.hide_viewport=True B.hide_viewport=True # Booleana if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -isct '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -isct '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Darwin": homeall = expanduser("~") subprocess.call(homeall+'/Programs//OrtogOnBlender/Cork/./cork -isct '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # Result = context.active_object # Result = bpy.context.view_layer.objects.active # objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] # bpy.data.collections['Collection'].objects.link(objetos_selecionados[0]) # bpy.data.collections['Collection'].objects.link(bpy.context.selected_objects[0]) bpy.ops.mesh.separate(type='LOOSE') objetos_selecionados = [ o for o in bpy.context.selected_objects ] ''' for i in objetos_selecionados: bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') ''' for i in objetos_selecionados: if i.visible_get() == True: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.move_to_collection(collection_index=1) class BooleanaOsteoInter(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_osteo_inter" bl_label = "Importa fatias de tomografia DICOM" def execute(self, context): BooleanaOsteoInterDef(self, context) # bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} bpy.utils.register_class(BooleanaOsteoInter) def BooleanaUnionSimplesDef(self, context): context = bpy.context # obj = context.active_object scn = context.scene objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] lista_colecoes = [] for i in objetos_selecionados: lista_colecoes.append(i.users_collection[0].name) lista_final = [] for i in lista_colecoes: if i != 'Collection': lista_final.append("FORA") if "FORA" in lista_final: bpy.ops.object.dialog_operator_erro_collection('INVOKE_DEFAULT') else: tmpdir = tempfile.mkdtemp() B = bpy.context.view_layer.objects.active print("Objeto B:", B) for i in bpy.context.selected_objects: if i.name != B.name: A = i print("Objeto A:", A.name) # B = bpy.context.selected_objects[1] # B = bpy.data.objects['Corte'] # A = context.active_object #objetos_selecionados[0] # Remover vértices duplos bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A if A.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B if B.type == 'MESH': bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.remove_doubles() bpy.ops.object.mode_set(mode='OBJECT') else: print("Não é malha!") bpy.ops.object.mode_set(mode='OBJECT') # Cria objeto A bpy.ops.object.select_all(action='DESELECT') A.select_set(True) bpy.context.view_layer.objects.active = A bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/A.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) else: obj = context.active_object bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj) bpy.data.collections['Copied_Objects'].hide_viewport=True # Cria objeto B bpy.ops.object.select_all(action='DESELECT') B.select_set(True) bpy.context.view_layer.objects.active = B bpy.ops.object.modifier_add(type='TRIANGULATE') bpy.ops.export_mesh.off(filepath=tmpdir+"/B.off") bpy.ops.object.modifier_remove(modifier="Triangulate") obj2 = bpy.context.view_layer.objects.active # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True bpy.ops.object.select_all(action='DESELECT') # OCulta objetos originais A.hide_viewport=True B.hide_viewport=True # Booleana if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Cork/./cork -union '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\Cork\wincork.exe -union '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') if platform.system() == "Darwin": homeall = expanduser("~") subprocess.call(homeall+'/Programs/OrtogOnBlender/Cork/./cork -union '+tmpdir+'/A.off '+tmpdir+'/B.off '+tmpdir+'/Result.off', shell=True) bpy.ops.import_mesh.off(filepath=tmpdir+"/Result.off") bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # Result = context.active_object # Result = bpy.context.view_layer.objects.active # objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] # bpy.data.collections['Collection'].objects.link(objetos_selecionados[0]) # bpy.data.collections['Collection'].objects.link(bpy.context.selected_objects[0]) # bpy.ops.mesh.separate(type='LOOSE') objetos_selecionados = [ o for o in bpy.context.selected_objects ] for i in objetos_selecionados: if i.visible_get() == True: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.move_to_collection(collection_index=1) class BooleanaUnionSimples(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_union_simples" bl_label = "Importa fatias de tomografia DICOM" def execute(self, context): BooleanaUnionSimplesDef(self, context) # bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} bpy.utils.register_class(BooleanaUnionSimples) # ------------------- def UnionMultiplaDef(self, context): objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] lista_colecoes = [] for i in objetos_selecionados: lista_colecoes.append(i.users_collection[0].name) lista_final = [] for i in lista_colecoes: if i != 'Collection': lista_final.append("FORA") if "FORA" in lista_final: bpy.ops.object.dialog_operator_erro_collection('INVOKE_DEFAULT') else: Objetos = [ o for o in bpy.context.selected_objects if o.select_get() == True ] #Results = [] Contador = int(len(Objetos)) while Contador > 1: bpy.ops.object.select_all(action='DESELECT') Objetos[0].select_set(True) Objetos[-1].select_set(True) bpy.context.view_layer.objects.active = Objetos[0] bpy.ops.object.booleana_union_simples() Objetos.remove(Objetos[0]) Objetos.remove(Objetos[-1]) Objetos.append(bpy.context.active_object) bpy.ops.object.collection_link(collection='Collection') Contador = int(len(Objetos)) print("Contador", Contador) class UnionMultipla(bpy.types.Operator): """Tooltip""" bl_idname = "object.booleana_union_multipla" bl_label = "Ortog multiple union boolean" def execute(self, context): UnionMultiplaDef(self, context) # bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} bpy.utils.register_class(UnionMultipla) ================================================ FILE: CalculaPontos.py ================================================ import bpy def capturaINI(ObjSelecionado): bpy.ops.object.select_all(action='DESELECT') Objeto = bpy.data.objects[ObjSelecionado] Objeto.select_set(True) bpy.context.view_layer.objects.active = Objeto print("Está no frame: ",bpy.context.scene.frame_current) bpy.ops.object.duplicate() bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.context.object.name = ObjSelecionado+".INI" def capturaFIN(ObjSelecionado): bpy.ops.object.select_all(action='DESELECT') Objeto = bpy.data.objects[ObjSelecionado] Objeto.select_set(True) bpy.context.view_layer.objects.active = Objeto print("Está no frame: ",bpy.context.scene.frame_current) bpy.ops.object.duplicate() bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.context.object.name = ObjSelecionado+".FIN" def apagaObjeto(ObjSelecionado): bpy.ops.object.select_all(action='DESELECT') Objeto = bpy.data.objects[ObjSelecionado] Objeto.select_set(True) bpy.ops.object.delete(use_global=False) def capturaINItodosDef(): # ATUALIZADO? ListaPontos = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left', 'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30'] ObjetosCena = bpy.data.objects for ob in ListaPontos: if ob in ObjetosCena: capturaINI(ob) def capturaFINtodosDef(): # ATUALIZADO? ListaPontos = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left', 'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30'] ObjetosCena = bpy.data.objects for ob in ListaPontos: if ob in ObjetosCena: capturaFIN(ob) def calculaDeslocamento(obj, obj1, obj2): objini = bpy.data.objects[obj1] objfin = bpy.data.objects[obj2] SRED = '\033[91m' SGREEN = '\033[92m' SBLUE = '\033[94m' BHEAD = '\033[95m' BEND = '\033[0m' # if bpy.data.objects.get(obj) is not None: Xdes = SRED + "X: " + str(round(objfin.location[0] - objini.location[0], 2)) + BEND Ydes = SGREEN + "Y: " + str(round(objfin.location[1] - objini.location[1], 2)) + BEND Zdes = SBLUE + "Z: " + str(round(objfin.location[2] - objini.location[2], 2)) + BEND a = '{} {} {} {} '.format(obj, Xdes, Ydes, Zdes) print(a) def obj_pre(frame): bpy.context.scene.frame_set(frame) print("frame:", frame) capturaINItodosDef() def obj_pos(frame): bpy.context.scene.frame_set(frame) print("frame:", frame) capturaFINtodosDef() def geraDeslocamentoTODOSDef(self, context): context = bpy.context obj = context.active_object scn = context.scene # Mostra resultados frame1 = bpy.data.scenes["Scene"].frame_start obj_pre(frame1) frame2 = bpy.data.scenes["Scene"].frame_end obj_pos(frame2) SYEL = '\33[45m' BOLD = '\033[1m' BEND = '\033[0m' print(" ") print(" ") print(BOLD + SYEL + "MAXILLA" + BEND) # ATUALIZADO? ListaPontos = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left', 'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30'] ObjetosCena = bpy.data.objects try: Collection_Head = bpy.data.collections['Anatomical Points - Head'].all_objects print(BOLD + SYEL + "HEAD" + BEND) for ob in ListaPontos: if ob in Collection_Head: calculaDeslocamento( ob+' : ', ob+'.INI', ob+'.FIN') except: print("Sem pontos da Cabeça.") try: Collection_Maxilla = bpy.data.collections['Anatomical Points - Maxilla'].all_objects print(" ") print(BOLD + SYEL + "MAXILLA" + BEND) for ob in ListaPontos: if ob in Collection_Maxilla: calculaDeslocamento( ob+' : ', ob+'.INI', ob+'.FIN') except: print("Sem pontos da Maxila.") try: Collection_Teeth = bpy.data.collections['Anatomical Points - Teeth'].all_objects print(" ") print(BOLD + SYEL + "TEETH" + BEND) for ob in ListaPontos: if ob in Collection_Teeth: calculaDeslocamento( ob+' : ', ob+'.INI', ob+'.FIN') except: print("Sem pontos dos Dentes.") try: Collection_Mandible = bpy.data.collections['Anatomical Points - Mandible'].all_objects print(" ") print(BOLD + SYEL + "MANDIBLE" + BEND) for ob in ListaPontos: if ob in Collection_Mandible: calculaDeslocamento( ob+' : ', ob+'.INI', ob+'.FIN') except: print("Sem pontos da Mandíbula.") try: Collection_SoftTissue = bpy.data.collections['Anatomical Points - Soft Tissue'].all_objects print(" ") print(BOLD + SYEL + "SOFT TISSUE" + BEND) for ob in ListaPontos: if ob in Collection_SoftTissue: calculaDeslocamento( ob+' : ', ob+'.INI', ob+'.FIN') except: print("Sem pontos do Tecido Mole.") ''' for ob in ListaPontos: if ob in ObjetosCena: calculaDeslocamento( ob+' : ', ob+'.INI', ob+'.FIN') ''' # Apaga try: for ob in ListaPontos: if ob in ObjetosCena: apagaObjeto(ob+'.INI') apagaObjeto(ob+'.FIN') except: print("Sem objetos INI e FIN na cena.") # Calcula Pontos ''' class capturaINItodos(bpy.types.Operator): """Tooltip""" bl_idname = "object.captura_ini_todos" bl_label = "Captura todos objetos inicio" def execute(self, context): capturaINItodosDef(self, context) return {'FINISHED'} class capturaFINtodos(bpy.types.Operator): """Tooltip""" bl_idname = "object.captura_fin_todos" bl_label = "Captura todos objetos final" def execute(self, context): capturaFINtodosDef(self, context) return {'FINISHED'} ''' class geraDeslocamentoTODOS(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_deslocamento_todos" bl_label = "Gera deslocamento de todos" def execute(self, context): geraDeslocamentoTODOSDef(self, context) return {'FINISHED'} bpy.utils.register_class(geraDeslocamentoTODOS) ================================================ FILE: Cefalometria.py ================================================ import bpy import math from .FerrMedidas import * def CursorToSelectedObj(objeto): context = bpy.context scn = context.scene bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[objeto].select_set(True) context.view_layer.objects.active = bpy.data.objects[objeto] for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break def CursorToSelectedObjs(objeto1, objeto2): context = bpy.context scn = context.scene bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[objeto1].select_set(True) bpy.data.objects[objeto2].select_set(True) context.view_layer.objects.active = bpy.data.objects[objeto1] for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break def ApagarObjeto(objeto): context = bpy.context scn = context.scene bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[objeto].select_set(True) context.view_layer.objects.active = bpy.data.objects[objeto] bpy.ops.object.delete(use_global=False) class CalculaTudoUSP(bpy.types.Operator): """Tooltip""" bl_idname = "object.calcula_tudo_usp" bl_label = "USP Calc All" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): bpy.ops.object.calcula_plano_oclusal_classico() CalculaSNADef() CalculaSNBDef() CalculaANBDef() CalculaPlanoMandibularDef() CalculaSNGoGnDef() CalculaSNGnDef() return {'FINISHED'} bpy.utils.register_class(CalculaTudoUSP) def CalculaSNGnDef(): FoundA = 'S point' in bpy.data.objects FoundN = 'N point' in bpy.data.objects FoundB = 'Gn point' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundA == True and FoundN == True and FoundB == True: print("SNGn - Todos os pontos anatômicos presentes!") CursorToSelectedObj("S point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoS" bpy.context.object.location[0] = 0 CursorToSelectedObj("N point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoN" bpy.context.object.location[0] = 0 CursorToSelectedObj("Gn point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoGn" bpy.context.object.location[0] = 0 bpy.data.objects["PontoS"].location[0] = 0 bpy.data.objects["PontoN"].location[0] = 0 bpy.data.objects["PontoGn"].location[0] = 0 AnguloSNGn = CalculaAngulo("PontoN", "PontoS", "PontoGn") print("Ângulo SNGn:", AnguloSNGn) bpy.types.Scene.angulo_sngn = bpy.props.StringProperty \ ( name = "SNGn Angle", description = "SNGn Angle", default = str(AnguloSNGn) ) ApagarObjeto("PontoS") ApagarObjeto("PontoN") ApagarObjeto("PontoGn") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloSNGn) else: bpy.types.Scene.angulo_sngn = bpy.props.StringProperty \ ( name = "SNGn Angle", description = "SNGn Angle", default = "NONE" ) print("Falta algum ponto anatômico (SNGn)!") def CalculaSNGoGnDef(): FoundS = 'S point' in bpy.data.objects FoundN = 'N point' in bpy.data.objects FoundGoright = 'Go right' in bpy.data.objects FoundGoleft = 'Go left' in bpy.data.objects FoundGnpoint = 'Gn point' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundS == True and FoundN == True and FoundGoright == True and FoundGoleft == True and FoundGnpoint == True: print("Todos os pontos anatômicos presentes!") CursorToSelectedObj("S point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoS" bpy.context.object.location[0] = 0 CursorToSelectedObj("N point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoN" bpy.context.object.location[0] = 0 CursorToSelectedObjs("Go left", "Go left") Cursor_Gonios = bpy.context.scene.cursor.location print(Cursor_Gonios) bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "Gonios" bpy.context.object.location[0] = 0 CursorToSelectedObj("Gn point") Cursor_Gn = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoGn" bpy.context.object.location[0] = 0 def line_intersection(line1, line2): xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0]) ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1]) def det(a, b): return a[0] * b[1] - a[1] * b[0] div = det(xdiff, ydiff) if div == 0: raise Exception('As linhas tê intersecção!') d = (det(*line1), det(*line2)) x = det(d, xdiff) / div y = det(d, ydiff) / div return x, y PontoS = bpy.data.objects['PontoS'] PontoN = bpy.data.objects['PontoN'] Gonios = bpy.data.objects['Gonios'] PontoGn = bpy.data.objects['PontoGn'] Linha1 = [(PontoS.location[1], PontoS.location[2]), (PontoN.location[1], PontoN.location[2])] Linha2 = [(Gonios.location[1], Gonios.location[2]), (PontoGn.location[1],PontoGn.location[2])] EncontroYZ = line_intersection(Linha1, Linha2) bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "ProjSNGoGn" bpy.context.object.location[0] = 0 bpy.context.object.location[1] = EncontroYZ[0] bpy.context.object.location[2] = EncontroYZ[1] AnguloSNGoGn = CalculaAngulo("PontoN", "ProjSNGoGn", "PontoGn") bpy.types.Scene.angulo_sngogn = bpy.props.StringProperty \ ( name = "SNGoGn Angle", description = "SNGoGn Angle", default = str(AnguloSNGoGn) ) ApagarObjeto("PontoS") ApagarObjeto("PontoN") ApagarObjeto("Gonios") ApagarObjeto("PontoGn") ApagarObjeto("ProjSNGoGn") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloSNGoGn) else: bpy.types.Scene.angulo_sngogn = bpy.props.StringProperty \ ( name = "SNGoGn Angle", description = "SNGoGn Angle", default = "NONE" ) print("Falta algum ponto anatômico (SNGoGn)!") def CalculaPlanoMaxilaClassicoDef(): FoundT3 = 'Tooth 3' in bpy.data.objects FoundT14 = 'Tooth 14' in bpy.data.objects FoundT8 = 'Tooth 8' in bpy.data.objects FoundT9 = 'Tooth 9' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundT3 == True and FoundT14 == True and FoundT8 == True and FoundT9 == True: print("Todos os pontos anatômicos presentes!") CursorToSelectedObjs("Tooth 14", "Tooth 3") Cursor_1626 = bpy.context.scene.cursor.location print(Cursor_1626) bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "1626" CursorToSelectedObjs("Tooth 9", "Tooth 8") Cursor_1121 = bpy.context.scene.cursor.location print(Cursor_1121) bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "1121" #PosicaoX = bpy.data.objects["1121"].location[0] #PosicaoY = bpy.data.objects["1626"].location[1] #PosicaoZ = bpy.data.objects["1121"].location[2] PosicaoX = bpy.data.objects["1121"].location[0] PosicaoY = bpy.data.objects["1121"].location[1] PosicaoZ = bpy.data.objects["1626"].location[2] print(PosicaoX) print(PosicaoY) print(PosicaoZ) bpy.ops.mesh.primitive_uv_sphere_add(radius=1, location=(PosicaoX, PosicaoY, PosicaoZ)) bpy.context.object.name = "Inter_1626_1121" bpy.data.objects["1121"].location[0] = 0 bpy.data.objects["1626"].location[0] = 0 bpy.data.objects["Inter_1626_1121"].location[0] = 0 AnguloOcluMaxClass = CalculaAngulo("1121", "1626", "Inter_1626_1121") bpy.types.Scene.plano_oclusal_maxila_classico = bpy.props.StringProperty \ ( name = "Maxillary Occlusal Angle", description = "Classic Max. Occl. Plane", default = str(AnguloOcluMaxClass) ) ApagarObjeto("1121") ApagarObjeto("1626") ApagarObjeto("Inter_1626_1121") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloOcluMaxClass) else: print("Falta algum ponto anatômico dos dentes!") def CalculaPlanoMandibularDef(): FoundGoleft = 'Go left' in bpy.data.objects FoundGoright = 'Go right' in bpy.data.objects FoundMepoint = 'Me point' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundGoleft == True and FoundGoright == True and FoundMepoint == True: print("Todos os pontos anatômicos presentes!") CursorToSelectedObjs("Go left", "Go left") Cursor_Gonios = bpy.context.scene.cursor.location print(Cursor_Gonios) bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "Gonios" CursorToSelectedObj("Me point") Cursor_Mepoint = bpy.context.scene.cursor.location print(Cursor_Mepoint) bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "Mepoint" PosicaoX = bpy.data.objects["Gonios"].location[0] PosicaoY = bpy.data.objects["Mepoint"].location[1] PosicaoZ = bpy.data.objects["Gonios"].location[2] print(PosicaoX) print(PosicaoY) print(PosicaoZ) bpy.ops.mesh.primitive_uv_sphere_add(radius=1, location=(PosicaoX, PosicaoY, PosicaoZ)) bpy.context.object.name = "Inter_Gonios_Me" bpy.data.objects["Gonios"].location[0] = 0 bpy.data.objects["Mepoint"].location[0] = 0 bpy.data.objects["Inter_Gonios_Me"].location[0] = 0 AnguloOcluMandUsp = CalculaAngulo("Inter_Gonios_Me", "Gonios", "Mepoint") bpy.types.Scene.plano_mandibula_usp = bpy.props.StringProperty \ ( name = "Mandibular Plane", description = "Mandibular Plane", default = str(AnguloOcluMandUsp) ) ApagarObjeto("Gonios") ApagarObjeto("Mepoint") ApagarObjeto("Inter_Gonios_Me") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloOcluMandUsp) else: print("Falta algum ponto anatômico na mandíbula!") def CalculaANBDef(): FoundA = 'A point' in bpy.data.objects FoundN = 'N point' in bpy.data.objects FoundB = 'B point' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundA == True and FoundN == True and FoundB == True: print("SNA - Todos os pontos anatômicos presentes!") CursorToSelectedObj("A point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoA" bpy.context.object.location[0] = 0 CursorToSelectedObj("N point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoN" bpy.context.object.location[0] = 0 CursorToSelectedObj("B point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoB" bpy.context.object.location[0] = 0 bpy.data.objects["PontoA"].location[0] = 0 bpy.data.objects["PontoN"].location[0] = 0 bpy.data.objects["PontoB"].location[0] = 0 AnguloANB = CalculaAngulo("PontoA", "PontoN", "PontoB") print("Ângulo ANB:", AnguloANB) bpy.types.Scene.angulo_anb = bpy.props.StringProperty \ ( name = "ANB Angle", description = "ANB Angle", default = str(AnguloANB) ) ApagarObjeto("PontoA") ApagarObjeto("PontoN") ApagarObjeto("PontoB") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloANB) else: bpy.types.Scene.angulo_anb = bpy.props.StringProperty \ ( name = "ANB Angle", description = "ANB Angle", default = "NONE" ) print("Falta algum ponto anatômico (ANB)!") def CalculaSNADef(): FoundS = 'S point' in bpy.data.objects FoundN = 'N point' in bpy.data.objects FoundA = 'A point' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundS == True and FoundN == True and FoundA == True: print("SNA - Todos os pontos anatômicos presentes!") CursorToSelectedObj("S point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoS" bpy.context.object.location[0] = 0 CursorToSelectedObj("N point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoN" bpy.context.object.location[0] = 0 CursorToSelectedObj("A point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoA" bpy.context.object.location[0] = 0 bpy.data.objects["PontoS"].location[0] = 0 bpy.data.objects["PontoN"].location[0] = 0 bpy.data.objects["PontoA"].location[0] = 0 AnguloSNA = CalculaAngulo("PontoS", "PontoN", "PontoA") print("Ângulo SNA:", AnguloSNA) bpy.types.Scene.angulo_sna = bpy.props.StringProperty \ ( name = "SNA Angle", description = "SNA Angle", default = str(AnguloSNA) ) ApagarObjeto("PontoS") ApagarObjeto("PontoN") ApagarObjeto("PontoA") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloSNA) else: bpy.types.Scene.angulo_sna = bpy.props.StringProperty \ ( name = "SNA Angle", description = "SNA Angle", default = "NONE" ) print("Falta algum ponto anatômico (SNA)!") def CalculaSNBDef(): FoundS = 'S point' in bpy.data.objects FoundN = 'N point' in bpy.data.objects FoundB = 'B point' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if FoundS == True and FoundN == True and FoundB == True: print("SNB - Todos os pontos anatômicos presentes!") CursorToSelectedObj("S point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoS" bpy.context.object.location[0] = 0 CursorToSelectedObj("N point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoN" bpy.context.object.location[0] = 0 CursorToSelectedObj("B point") Cursor_S = bpy.context.scene.cursor.location bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = "PontoB" bpy.context.object.location[0] = 0 bpy.data.objects["PontoS"].location[0] = 0 bpy.data.objects["PontoN"].location[0] = 0 bpy.data.objects["PontoB"].location[0] = 0 AnguloSNB = CalculaAngulo("PontoS", "PontoN", "PontoB") print("Ângulo SNB:", AnguloSNB) bpy.types.Scene.angulo_snb = bpy.props.StringProperty \ ( name = "SNB Angle", description = "SNB Angle", default = str(AnguloSNB) ) ApagarObjeto("PontoS") ApagarObjeto("PontoN") ApagarObjeto("PontoB") context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(AnguloSNB) else: bpy.types.Scene.angulo_snb = bpy.props.StringProperty \ ( name = "SNB Angle", description = "SNB Angle", default = "NONE" ) print("Falta algum ponto anatômico (SNB)!") class CalculaPlanoMaxilaClassico(bpy.types.Operator): """Tooltip""" bl_idname = "object.calcula_plano_oclusal_classico" bl_label = "Calc. Max. Occl. Plane Classic" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CalculaPlanoMaxilaClassicoDef() return {'FINISHED'} bpy.utils.register_class(CalculaPlanoMaxilaClassico) def CalculaAnguloOclusao(): found_U6_Oc = 'U6 Occlusal' in bpy.data.objects found_U1_Tp = 'U1 Tip' in bpy.data.objects context = bpy.context objInicial = context.object CursorInicial = [] for i in bpy.context.scene.cursor.location: CursorInicial.append(i) if found_U6_Oc == True and found_U1_Tp == True: print("U6 Occlusal e U1 Tip presentes!") PT_U6_Oc = bpy.data.objects['U6 Occlusal'] PT_U1_Tp = bpy.data.objects['U1 Tip'] Distancia1 = math.sqrt( (PT_U6_Oc.location[1] - PT_U1_Tp.location[1])**2 + (PT_U6_Oc.location[2] - PT_U1_Tp.location[2])**2 ) print("Distancia1:", Distancia1) Distancia2= ( math.sqrt( (PT_U1_Tp.location[1] - PT_U6_Oc.location[1])**2 + ((PT_U1_Tp.location[2]-Distancia1) - PT_U6_Oc.location[2])**2 ) )/2 print("Distancia2:", Distancia2) CosLinOc = (Distancia2 / Distancia1) Grau1 = float(round(math.degrees(math.acos(CosLinOc)),2)) GrauOclusao = 180 - (Grau1*2) print(GrauOclusao) bpy.types.Scene.plano_oclusal_maxila = bpy.props.StringProperty \ ( name = "Maxillary Occlusal Plane", description = "Maxillary Occlusal Plane", default = str(GrauOclusao)+"º" ) context.scene.cursor.location = CursorInicial if objInicial != None: bpy.ops.object.select_all(action='DESELECT') objInicial.select_set(True) context.view_layer.objects.active = objInicial return str(GrauOclusao)+"º" else: print("Veja se os pontos U6 Occlusal e U1 Tip foram adicionados corretamente.") def CalculaAnguloNasolabial(): found_Columella = 'Columella' in bpy.data.objects found_Subnasale = 'Subnasale' in bpy.data.objects found_UpperLip = 'Upper Lip' in bpy.data.objects if found_Columella == True and found_Subnasale == True and found_UpperLip == True: print("Columella, Subnasale e Upper Lip presentes!") # Copia os 3 Objetos = [bpy.data.objects['Columella'], bpy.data.objects['Subnasale'], bpy.data.objects['Upper Lip']] for item in Objetos: bpy.ops.object.select_all(action='DESELECT') item.select_set(True) bpy.context.view_layer.objects.active = item bpy.ops.object.duplicate_move() bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') # Calcula Columella = bpy.data.objects['Columella.001'] Subnasale = bpy.data.objects['Subnasale.001'] UpperLip = bpy.data.objects['Upper Lip.001'] SC = math.sqrt( (Columella.location[1] - Subnasale.location[1])**2 + (Columella.location[2] - Subnasale.location[2])**2 ) print("SC", SC) SU = math.sqrt( (UpperLip.location[1] - Subnasale.location[1])**2 + (UpperLip.location[2] - Subnasale.location[2])**2 ) print("SU", SU) UC = math.sqrt( (UpperLip.location[1] - Columella.location[1])**2 + (UpperLip.location[2] - Columella.location[2])**2 ) print("UC", UC) GrauNasolabial = (SC**2 + SU**2 - UC**2) / (2 * SC * SU) AnguloNasolabial = float(round(math.degrees(math.acos(GrauNasolabial)),2)) print("Ângulo Nasolabial:", AnguloNasolabial) bpy.types.Scene.angulo_nasolabial = bpy.props.StringProperty \ ( name = "Nasolabial Angle", description = "Nasolabial Angle", default = str(AnguloNasolabial)+"º" ) # Apaga objetos bpy.ops.object.select_all(action='DESELECT') ObjetosCopias = [bpy.data.objects['Columella.001'], bpy.data.objects['Subnasale.001'], bpy.data.objects['Upper Lip.001']] for item in ObjetosCopias: bpy.ops.object.select_all(action='DESELECT') item.select_set(True) bpy.ops.object.delete(use_global=False) return str(AnguloNasolabial)+"º" def CalculaAnguloGbSnPog(): found_ST_Glabella = 'ST Glabella' in bpy.data.objects found_Subnasale = 'Subnasale' in bpy.data.objects found_ST_Pogonion = 'ST Pogonion' in bpy.data.objects if found_ST_Glabella == True and found_Subnasale == True and found_ST_Pogonion == True: print("ST Glabella, Subnasale e ST Pogonion presentes!") AnguloBase = GeraAnguloViewX('Subnasale', 'ST Glabella', 'ST Pogonion') Gn = bpy.data.objects['ST Glabella'] Pog = bpy.data.objects['ST Pogonion'] Sn = bpy.data.objects['Subnasale'] # Acha posição do Y no meio entre Gn e Pog' PosicaoMeioY = (Gn.location[1] + Pog.location[1])/2 print("PosicaoMeioY", PosicaoMeioY) if PosicaoMeioY > Sn.location[1]: print("Maior! Valor:", AnguloBase) bpy.types.Scene.angulo_GbSnPog = bpy.props.StringProperty \ ( name = "Gb', Sn, Pog' Angle", description = "Gb', Sn, Pog' Angle", default = str(AnguloBase)+"º" ) if PosicaoMeioY < Sn.location[1]: print("Menor", 360 - AnguloBase) bpy.types.Scene.angulo_GbSnPog = bpy.props.StringProperty \ ( name = "Gb', Sn, Pog' Angle", description = "Gb', Sn, Pog' Angle", default = str(360 - AnguloBase)+"º" ) if PosicaoMeioY == Sn.location[1]: print("Igual", 180) bpy.types.Scene.angulo_GbSnPog = bpy.props.StringProperty \ ( name = "Gb', Sn, Pog' Angle", description = "Gb', Sn, Pog' Angle", default = '180º' ) def GeraAnguloViewX(Obj1, Obj2, Obj3): A = bpy.data.objects[Obj1] B = bpy.data.objects[Obj2] C = bpy.data.objects[Obj3] AB = math.sqrt( (B.location[1] - A.location[1])**2 + (B.location[2] - A.location[2])**2 ) print("AB", AB) AC = math.sqrt( (C.location[1] - A.location[1])**2 + (C.location[2] - A.location[2])**2 ) print("AC", AC) BC = math.sqrt( (C.location[1] - B.location[1])**2 + (C.location[2] - B.location[2])**2 ) print("BC", BC) AnguloCos = (AB**2 + AC**2 - BC**2) / (2 * AB * AC) AnguloGraus = float(round(math.degrees(math.acos(AnguloCos)),2)) print("Ângulo em graus:", AnguloGraus) return AnguloGraus #GeraAnguloViewX("U1 Tip", "U1 Root", "U6 Occlusal") #GeraAnguloViewX("L1 Tip", "L1 Root", "L6 Occlusal") #GeraAnguloViewX("Subnasale", "ST Glabella", "ST Pogonion") # G' SN POG' def DistanciaDupla(ObjDir, ObjEsq, ObjBase, Eixo): found_ObjDir = str(ObjDir) in bpy.data.objects found_ObjEsq = str(ObjEsq) in bpy.data.objects found_ObjBase = str(ObjBase) in bpy.data.objects if found_ObjDir == True and found_ObjEsq == True and found_ObjBase == True: def ApagaTudo(): bpy.ops.object.select_all(action='DESELECT') ObjetosCopias = [Direita , Esquerda, Base] for item in ObjetosCopias: bpy.ops.object.select_all(action='DESELECT') item.select_set(True) bpy.context.view_layer.objects.active = item bpy.ops.object.delete(use_global=False) # Copia os 3 Objetos = [bpy.data.objects[ObjDir], bpy.data.objects[ObjEsq], bpy.data.objects[ObjBase]] for item in Objetos: bpy.ops.object.select_all(action='DESELECT') item.select_set(True) bpy.ops.object.duplicate_move() bpy.context.view_layer.objects.active = item # Se não tiver dá erro! bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') Direita = bpy.data.objects[ObjDir+'.001'] Esquerda = bpy.data.objects[ObjEsq+'.001'] Base = bpy.data.objects[ObjBase+'.001'] PontoCentral = ( Direita.location[Eixo] + Esquerda.location[Eixo] ) / 2 Distancia = abs( PontoCentral - Base.location[Eixo] ) # Calcula Posicao if PontoCentral > Base.location[Eixo]: DistanciaFinal = Distancia * -1 print("DistanciaFinal", DistanciaFinal) print("") ApagaTudo() return DistanciaFinal if PontoCentral < Base.location[Eixo]: DistanciaFinal = Distancia print("DistanciaFinal", DistanciaFinal) print("") ApagaTudo() return DistanciaFinal if PontoCentral == Base.location[Eixo]: DistanciaFinal = Distancia print("DistanciaFinal", DistanciaFinal) print("") ApagaTudo() return DistanciaFinal else: print( "Não calculou. Algum objeto faltante:", ObjDir,",", ObjEsq, ",", ObjBase) def DistanciaUnica(ObjDist, ObjBase, Eixo): found_ObjDist = str(ObjDist) in bpy.data.objects found_ObjBase = str(ObjBase) in bpy.data.objects if found_ObjDist == True and found_ObjBase == True: def ApagaTudo(): bpy.ops.object.select_all(action='DESELECT') for item in ObjetosCopias: bpy.ops.object.select_all(action='DESELECT') item.select_set(True) bpy.context.view_layer.objects.active = item bpy.ops.object.delete(use_global=False) # Copia os 2 Objetos = [bpy.data.objects[ObjDist], bpy.data.objects[ObjBase]] MedidasEixo = [] ObjetosCopias = [] for item in Objetos: print("OBJETO", item) bpy.ops.object.select_all(action='DESELECT') item.select_set(True) bpy.context.view_layer.objects.active = item bpy.ops.object.duplicate_move() print("CAMADONA") bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') ObjetoAtual = bpy.context.selected_objects[0] MedidaAtual = ObjetoAtual.location[Eixo] MedidasEixo.append(MedidaAtual) ObjetosCopias.append(ObjetoAtual) Distancia = abs( MedidasEixo[0] - MedidasEixo[1] ) # Calcula Posicao if MedidasEixo[1] < MedidasEixo[0]: DistanciaFinal = Distancia * -1 print("DistanciaFinal", DistanciaFinal) print("") ApagaTudo() return DistanciaFinal if MedidasEixo[1] > MedidasEixo[0]: DistanciaFinal = Distancia print("DistanciaFinal", DistanciaFinal) print("") ApagaTudo() return DistanciaFinal if MedidasEixo[1] == MedidasEixo[0]: DistanciaFinal = Distancia print("DistanciaFinal", DistanciaFinal) print("") ApagaTudo() return DistanciaFinal else: print( "Não calculou. Algum objeto faltante:", ObjDist,",", ObjBase) def CalculaTudoCefalometriaDef(self, context): CalculaAnguloOclusao() CalculaAnguloNasolabial() CalculaAnguloGbSnPog() try: glabella_tvl = str(float(round(DistanciaUnica("ST Glabella", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_glabella_tvl = bpy.props.StringProperty \ ( name = "Glabella - TVL", description = "Glabella - TVL", default = glabella_tvl ) except: print("Algum ponto faltante!") try: rima_or_tvl = str(float(round(DistanciaDupla("OR right", "OR left", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_rima_or_tvl = bpy.props.StringProperty \ ( name = "OR' - TVL", description = "OR' - TVL", default = rima_or_tvl ) except: print("Algum ponto faltante!") try: rima_or_tvl = str(float(round(DistanciaDupla("Cheekbone right", "Cheekbone left", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_cheekbone_tvl = bpy.props.StringProperty \ ( name = "Cheekbone - TVL", description = "Cheekbone - TVL", default = rima_or_tvl ) except: print("Algum ponto faltante!") try: subpupilar_tvl = str(float(round(DistanciaDupla("Subpupil right", "Subpupil left", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_subpupil_tvl = bpy.props.StringProperty \ ( name = "Subpupil - TVL", description = "Subpupil - TVL", default = subpupilar_tvl ) except: print("Algum ponto faltante!") ''' try: proj_nasal_tvl = str(float(round(DistanciaDupla("Tip of Nose", "Tip of Nose", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_proj_nasal_tvl = bpy.props.StringProperty \ ( name = "Tip of Nose - TVL", description = "Tip of Nose - TVL", default = proj_nasal_tvl ) except: print("Algum ponto faltante!") ''' try: base_nasal_tvl = str(float(round(DistanciaDupla("AB right", "AB left", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_base_nasal_tvl = bpy.props.StringProperty \ ( name = "AB - TVL", description = "AB - TVL", default = base_nasal_tvl ) except: print("Algum ponto faltante!") ''' try: a_mole_tvl = str(float(round(DistanciaDupla("ST A point", "ST A point", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_a_mole_tvl = bpy.props.StringProperty \ ( name = "A' - TVL", description = "A' - TVL", default = a_mole_tvl ) except: print("Algum ponto faltante!") try: labio_superior_tvl = str(float(round(DistanciaDupla("Upper Lip", "Upper Lip", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_labio_superior_tvl = bpy.props.StringProperty \ ( name = "Upper Lip - TVL", description = "Upper Lip - TVL", default = labio_superior_tvl ) except: print("Algum ponto faltante!") try: l1_tvl = str(float(round(DistanciaDupla("L1 Tip", "L1 Tip", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_l1_tvl = bpy.props.StringProperty \ ( name = "L1 Tip - TVL", description = "L1 Tip - TVL", default = l1_tvl ) except: print("Algum ponto faltante!") try: u1_tvl = str(float(round(DistanciaDupla("U1 Tip", "U1 Tip", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_u1_tvl = bpy.props.StringProperty \ ( name = "U1 Tip - TVL", description = "U1 Tip - TVL", default = u1_tvl ) except: print("Algum ponto faltante!") try: labio_inferior_tvl = str(float(round(DistanciaDupla("Lower Lip", "Lower Lip", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_labio_inferior_tvl = bpy.props.StringProperty \ ( name = "Lower Lip - TVL", description = "Lower Lip - TVL", default = labio_inferior_tvl ) except: print("Algum ponto faltante!") try: b_mole_tvl = str(float(round(DistanciaDupla("ST B point", "ST B point", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_b_mole_tvl = bpy.props.StringProperty \ ( name = "ST B point - TVL", description = "ST B point - TVL", default = b_mole_tvl ) except: print("Algum ponto faltante!") try: pog_mole_tvl = str(float(round(DistanciaDupla("ST Pogonion", "ST Pogonion", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_pog_mole_tvl = bpy.props.StringProperty \ ( name = "ST Pogonion - TVL", description = "ST Pogonion - TVL", default = pog_mole_tvl ) except: print("Algum ponto faltante!") try: pescoco_garganta_tvl = str(float(round(DistanciaDupla("Throat point", "Throat point", "Subnasale", 1),2)))+" mm" bpy.types.Scene.dist_pescoco_garganta_tvl = bpy.props.StringProperty \ ( name = "Throat point - TVL", description = "Throat point - TVL", default = pescoco_garganta_tvl ) except: print("Algum ponto faltante!") ''' class CalculaTudoCefalometria(bpy.types.Operator): """Tooltip""" bl_idname = "object.calcula_tudo_cefalo" bl_label = "Cephalometry cal all" def execute(self, context): CalculaTudoCefalometriaDef(self, context) return {'FINISHED'} bpy.utils.register_class(CalculaTudoCefalometria) def CalculaDistanciaObjetos(ObjA, ObjB): A = bpy.data.objects[ObjA] B = bpy.data.objects[ObjB] Distancia = math.sqrt(( (B.location[0] - A.location[0])**2 ) + ( (B.location[1] - A.location[1])**2 ) + ( (B.location[2] - A.location[2])**2 )) print("A distância entre '"+ObjA+"' e '"+ObjB+"' é de", round(Distancia, 2)) return round(Distancia, 2) ================================================ FILE: CompareOnBlender.py ================================================ import bpy #import platform from .CompareTools import * class FORENSIC_PT_PontosFace17(bpy.types.Panel): bl_label = "Compare 17 Points" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Compare" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Digital Points:") row = layout.row() linha=row.operator("object.pronasale_digi_pt", text="1 - Pronasale") row = layout.row() linha=row.operator("object.exocanthus_alar_base_right_digi_pt", text="2 - Exocanthus-Alar Base right") row = layout.row() linha=row.operator("object.cheek_right_digi_pt", text="3 - Cheek right") row = layout.row() linha=row.operator("object.alar_base_right_digi_pt", text="4 - Alar Base right") row = layout.row() linha=row.operator("object.subnasale_digi_pt", text="5 - Subnasale") row = layout.row() linha=row.operator("object.alar_base_left_digi_pt", text="6 - Alar Base left") row = layout.row() linha=row.operator("object.cheek_left_digi_pt", text="7 - Cheek left") row = layout.row() linha=row.operator("object.exocanthus_alar_base_left_digi_pt", text="8 - Exocanthus-Alar Base left") row = layout.row() linha=row.operator("object.cheilion_alar_base_right_digi_pt", text="9 - Cheilion-Alar Base right") row = layout.row() linha=row.operator("object.cupids_bow_right_digi_pt", text="10 - Cupid's Bow right") row = layout.row() linha=row.operator("object.cupids_bow_left_digi_pt", text="11 - Cupid's Bow left") row = layout.row() linha=row.operator("object.cheilion_alar_base_left_digi_pt", text="12 - Cheilion-Alar Base left") row = layout.row() linha=row.operator("object.cheilion_right_digi_pt", text="13 - Cheilion right") row = layout.row() linha=row.operator("object.cheilion_left_digi_pt", text="14 - Cheilion left") row = layout.row() linha=row.operator("object.lower_lip_digi_pt", text="15 - Lower Lip") row = layout.row() linha=row.operator("object.b_point_soft_digi_pt", text="16 - B point soft") row = layout.row() linha=row.operator("object.pogonion_soft_digi_pt", text="17 - Pogonion soft") row = layout.row() row = layout.row() row.label(text="Real Points:") row = layout.row() linha=row.operator("object.pronasale_real_pt", text="1 - Pronasale") row = layout.row() linha=row.operator("object.exocanthus_alar_base_right_real_pt", text="2 - Exocanthus-Alar Base right") row = layout.row() linha=row.operator("object.cheek_right_real_pt", text="3 - Cheek right") row = layout.row() linha=row.operator("object.alar_base_right_real_pt", text="4 - Alar Base right") row = layout.row() linha=row.operator("object.subnasale_real_pt", text="5 - Subnasale") row = layout.row() linha=row.operator("object.alar_base_left_real_pt", text="6 - Alar Base left") row = layout.row() linha=row.operator("object.cheek_left_real_pt", text="7 - Cheek left") row = layout.row() linha=row.operator("object.exocanthus_alar_base_left_real_pt", text="8 - Exocanthus-Alar Base left") row = layout.row() linha=row.operator("object.cheilion_alar_base_right_real_pt", text="9 - Cheilion-Alar Base right") row = layout.row() linha=row.operator("object.cupids_bow_right_real_pt", text="10 - Cupid's Bow right") row = layout.row() linha=row.operator("object.cupids_bow_left_real_pt", text="11 - Cupid's Bow left") row = layout.row() linha=row.operator("object.cheilion_alar_base_left_real_pt", text="12 - Cheilion-Alar Base left") row = layout.row() linha=row.operator("object.cheilion_right_real_pt", text="13 - Cheilion right") row = layout.row() linha=row.operator("object.cheilion_left_real_pt", text="14 - Cheilion left") row = layout.row() linha=row.operator("object.lower_lip_real_pt", text="15 - Lower Lip") row = layout.row() linha=row.operator("object.b_point_soft_real_pt", text="16 - B point soft") row = layout.row() linha=row.operator("object.pogonion_soft_real_pt", text="17 - Pogonion soft") row = layout.row() row = layout.row() row.label(text="Distances Report:") row = layout.row() linha=row.operator("object.calcula_distancias_compare", text="Calc All Distances!", icon="PREFERENCES") bpy.utils.register_class(FORENSIC_PT_PontosFace17) ================================================ FILE: CompareTools.py ================================================ import bpy from .Cefalometria import * from .GeraRelatorio import * from .PontosAnatomicos import * from .FerrMedidas import * from .FerrImgTomo import * # Importa tratamento de materiais from math import sqrt import csv import bmesh from mathutils import Matrix, Vector from time import gmtime, strftime # PONTOS ANATOMICOS class Pronasale_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pronasale_digi_pt" bl_label = " Pronasale digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pronasale digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pronasale digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Pronasale_digi_pt) class Exocanthus_Alar_Base_right_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.exocanthus_alar_base_right_digi_pt" bl_label = "Exocanthus-Alar Base right digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Exocanthus-Alar Base right digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Exocanthus-Alar Base right digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Exocanthus_Alar_Base_right_digi_pt) class Exocanthus_Alar_Base_left_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.exocanthus_alar_base_left_digi_pt" bl_label = "Exocanthus-Alar Base left digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Exocanthus-Alar Base left digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Exocanthus-Alar Base left digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Exocanthus_Alar_Base_left_digi_pt) class Cheek_right_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheek_right_digi_pt" bl_label = "Cheek right digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheek right digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheek right digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheek_right_digi_pt) class Cheek_left_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheek_left_digi_pt" bl_label = "Cheek left digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheek left digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheek left digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheek_left_digi_pt) class Alar_Base_right_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_base_right_digi_pt" bl_label = "Alar Base right digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Base right digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Base right digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Base_right_digi_pt) class Alar_Base_left_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_base_left_digi_pt" bl_label = "Alar Base left digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Base left digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Base left digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Base_left_digi_pt) class Subnasale_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.subnasale_digi_pt" bl_label = "Subnasale digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Subnasale digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Subnasale digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class( Subnasale_digi_pt) class Cheilion_Alar_Base_right_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_alar_base_right_digi_pt" bl_label = "Cheilion-Alar Base right digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion-Alar Base right digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion-Alar Base right digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_Alar_Base_right_digi_pt) class Cheilion_Alar_Base_left_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_alar_base_left_digi_pt" bl_label = "Cheilion-Alar Base left digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion-Alar Base left digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion-Alar Base left digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_Alar_Base_left_digi_pt) class Cupids_Bow_right_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cupids_bow_right_digi_pt" bl_label = "Cupid's Bow right digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cupid\'s Bow right digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cupid\'s Bow right digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cupids_Bow_right_digi_pt) class Cupids_Bow_left_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cupids_bow_left_digi_pt" bl_label = "Cupid's Bow left digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cupid\'s Bow left digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cupid\'s Bow left digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cupids_Bow_left_digi_pt) class Cheilion_right_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_right_digi_pt" bl_label = "Cheilion right digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion right digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion right digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_right_digi_pt) class Cheilion_left_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_left_digi_pt" bl_label = "Cheilion left digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion left digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion left digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_left_digi_pt) class Lower_Lip_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.lower_lip_digi_pt" bl_label = "Lower Lip digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Lower Lip digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Lower Lip digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Lower_Lip_digi_pt) class B_point_soft_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.b_point_soft_digi_pt" bl_label = "B point soft digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'B point soft digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('B point soft digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(B_point_soft_digi_pt) class Pogonion_soft_digi_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pogonion_soft_digi_pt" bl_label = "Pogonion soft digi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pogonion soft digi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pogonion soft digi', 'Anatomical Points - Digital') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Pogonion_soft_digi_pt) # Real class Pronasale_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pronasale_real_pt" bl_label = " Pronasale real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pronasale real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pronasale real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Pronasale_real_pt) class Exocanthus_Alar_Base_right_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.exocanthus_alar_base_right_real_pt" bl_label = "Exocanthus-Alar Base right real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Exocanthus-Alar Base right real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Exocanthus-Alar Base right real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Exocanthus_Alar_Base_right_real_pt) class Exocanthus_Alar_Base_left_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.exocanthus_alar_base_left_real_pt" bl_label = "Exocanthus-Alar Base left real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Exocanthus-Alar Base left real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Exocanthus-Alar Base left real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Exocanthus_Alar_Base_left_real_pt) class Cheek_right_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheek_right_real_pt" bl_label = "Cheek right real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheek right real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheek right real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheek_right_real_pt) class Cheek_left_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheek_left_real_pt" bl_label = "Cheek left real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheek left real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheek left real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheek_left_real_pt) class Alar_Base_right_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_base_right_real_pt" bl_label = "Alar Base right real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Base right real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Base right real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Base_right_real_pt) class Alar_Base_left_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_base_left_real_pt" bl_label = "Alar Base left real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Base left real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Base left real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Base_left_real_pt) class Subnasale_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.subnasale_real_pt" bl_label = "Subnasale real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Subnasale real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Subnasale real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class( Subnasale_real_pt) class Cheilion_Alar_Base_right_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_alar_base_right_real_pt" bl_label = "Cheilion-Alar Base right real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion-Alar Base right real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion-Alar Base right real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_Alar_Base_right_real_pt) class Cheilion_Alar_Base_left_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_alar_base_left_real_pt" bl_label = "Cheilion-Alar Base left real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion-Alar Base left real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion-Alar Base left real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_Alar_Base_left_real_pt) class Cupids_Bow_right_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cupids_bow_right_real_pt" bl_label = "Cupid's Bow right real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cupid\'s Bow right real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cupid\'s Bow right real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cupids_Bow_right_real_pt) class Cupids_Bow_left_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cupids_bow_left_real_pt" bl_label = "Cupid's Bow left real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cupid\'s Bow left real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cupid\'s Bow left real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cupids_Bow_left_real_pt) class Cheilion_right_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_right_real_pt" bl_label = "Cheilion right real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion right real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion right real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_right_real_pt) class Cheilion_left_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheilion_left_real_pt" bl_label = "Cheilion left real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheilion left real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheilion left real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheilion_left_real_pt) class Lower_Lip_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.lower_lip_real_pt" bl_label = "Lower Lip real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Lower Lip real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Lower Lip real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Lower_Lip_real_pt) class B_point_soft_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.b_point_soft_real_pt" bl_label = "B point soft real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'B point soft real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('B point soft real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(B_point_soft_real_pt) class Pogonion_soft_real_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pogonion_soft_real_pt" bl_label = "Pogonion soft real" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pogonion soft real' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pogonion soft real', 'Anatomical Points - Real') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Pogonion_soft_real_pt) def GeraPlanilha(): tmpdir = tempfile.mkdtemp() ListaApagar = [] with open(tmpdir+'/Report_CompareOnBlender.csv', mode='w') as centroid_file: report_writer = csv.writer(centroid_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) report_writer.writerow(['CompareOnBlender']) report_writer.writerow(['']) report_writer.writerow(['Point Number', 'Point Name', 'Distance']) report_writer.writerow(['']) report_writer.writerow(['1', 'Pronasale (Pn)', CalculaDistanciaObjetos("Pronasale digi", "Pronasale real")]) report_writer.writerow(['2', 'Rigth Exocanthus-Alar Base (Rt.Exo-Al)', CalculaDistanciaObjetos("Exocanthus-Alar Base right digi", "Exocanthus-Alar Base right real")]) report_writer.writerow(['3', 'Rigth Cheek (Rt.Ck)', CalculaDistanciaObjetos("Cheek right digi", "Cheek right real")]) report_writer.writerow(['4', 'Rigth Alar Base (Rt.Al)', CalculaDistanciaObjetos("Alar Base right digi", "Alar Base right real")]) report_writer.writerow(['5', 'Subnasale (Sn)', CalculaDistanciaObjetos("Subnasale digi", "Subnasale real")]) report_writer.writerow(['6', 'Left Alar Base (Lt.Al)', CalculaDistanciaObjetos("Alar Base left digi", "Alar Base left real")]) report_writer.writerow(['7', 'Left Cheek (Ir.Ck)', CalculaDistanciaObjetos("Cheek left digi", "Cheek left real")]) report_writer.writerow(['8', 'Left Exocanthus-Alar Base (Lt.Exo-Al)', CalculaDistanciaObjetos("Exocanthus-Alar Base left digi", "Exocanthus-Alar Base left real")]) report_writer.writerow(['9', 'Rigth Cheilion-Alar Base (Rt.Ch-Al)', CalculaDistanciaObjetos("Cheilion-Alar Base right digi", "Cheilion-Alar Base right real")]) report_writer.writerow(['10', 'Rigth Cupid\'s Bow (Rt.Cu)', CalculaDistanciaObjetos("Cupid's Bow right digi", "Cupid's Bow right real")]) report_writer.writerow(['11', 'Left Cupid\'s Bow (Lt.Cu)', CalculaDistanciaObjetos("Cupid's Bow left digi", "Cupid's Bow left real")]) report_writer.writerow(['12', 'Left Cheilion-Alar Base (Lt.Ch-Al)', CalculaDistanciaObjetos("Cheilion-Alar Base left digi", "Cheilion-Alar Base left real")]) report_writer.writerow(['13', 'Rigth Cheilion (Rt.Ch)', CalculaDistanciaObjetos("Cheilion right digi", "Cheilion right real")]) report_writer.writerow(['14', 'Left Cheilion (Lt.Ch)', CalculaDistanciaObjetos("Cheilion left digi", "Cheilion left real")]) report_writer.writerow(['15', 'Lower Lip (LL)', CalculaDistanciaObjetos("Lower Lip digi", "Lower Lip real")]) report_writer.writerow(['16', 'Soft Tissue B Point (B\')', CalculaDistanciaObjetos("B point soft digi", "B point soft real")]) report_writer.writerow(['17', 'Soft Tissue Pogonion (Pog\')', CalculaDistanciaObjetos("Pogonion soft digi", "Pogonion soft real")]) Media = (CalculaDistanciaObjetos("Pronasale digi", "Pronasale real") + CalculaDistanciaObjetos("Exocanthus-Alar Base right digi", "Exocanthus-Alar Base right real") + CalculaDistanciaObjetos("Cheek right digi", "Cheek right real") + CalculaDistanciaObjetos("Alar Base right digi", "Alar Base right real") + CalculaDistanciaObjetos("Subnasale digi", "Subnasale real") + CalculaDistanciaObjetos("Alar Base left digi", "Alar Base left real") + CalculaDistanciaObjetos("Cheek left digi", "Cheek left real") + CalculaDistanciaObjetos("Exocanthus-Alar Base left digi", "Exocanthus-Alar Base left real") + CalculaDistanciaObjetos("Cheilion-Alar Base right digi", "Cheilion-Alar Base right real") + CalculaDistanciaObjetos("Cupid's Bow right digi", "Cupid's Bow right real") + CalculaDistanciaObjetos("Cupid's Bow left digi", "Cupid's Bow left real") + CalculaDistanciaObjetos("Cheilion-Alar Base left digi", "Cheilion-Alar Base left real") + CalculaDistanciaObjetos("Cheilion right digi", "Cheilion right real") + CalculaDistanciaObjetos("Cheilion left digi", "Cheilion left real") + CalculaDistanciaObjetos("Lower Lip digi", "Lower Lip real") + CalculaDistanciaObjetos("B point soft digi", "B point soft real") + CalculaDistanciaObjetos("Pogonion soft digi", "Pogonion soft real"))/17 report_writer.writerow(['']) report_writer.writerow(['', 'AVERAGE', round(Media, 2)]) if platform.system() == "Linux": abrir_diretorio(tmpdir) subprocess.Popen("libreoffice "+tmpdir+"/Report_CompareOnBlender.csv", shell=True) if platform.system() == "Windows": abrir_diretorio(tmpdir) subprocess.Popen('cd "C:/Program Files/LibreOffice/program/" & dir & soffice.bin '+tmpdir+"/Report_CompareOnBlender.csv", shell=True) if platform.system() == "Darwin": abrir_diretorio(tmpdir) subprocess.Popen('/Applications/LibreOffice.app/Contents/MacOS/soffice '+tmpdir+"/Report_CompareOnBlender.csv", shell=True) class CalculaDistanciasCompare(bpy.types.Operator): """Tooltip""" bl_idname = "object.calcula_distancias_compare" bl_label = "Calc Distances on Compare" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): GeraPlanilha() #CalculaDistanciaObjetos("Cheek left real","Cheek left digi") return {'FINISHED'} bpy.utils.register_class(CalculaDistanciasCompare) ================================================ FILE: ConfOsteotomiaAuto.py ================================================ import bpy import platform import bmesh from random import randint from .FerrImgTomo import * # MENSAGENS def CriaMaterialOsteotomia(NomeMaterial, R, G, B): activeObject = bpy.context.active_object m = Material() m.make_material(NomeMaterial) diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs["Base Color"].default_value = [R, G, B, 1] materialOutput = m.nodes['Material Output'] mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.dump_node(mixShader) mixShader.inputs['Fac'].default_value = 0.3 mixShader2 = m.makeNode('ShaderNodeMixShader', 'Mix Shader 2') mixShader2.inputs['Fac'].default_value = 0.05 sssShader = m.makeNode('ShaderNodeSubsurfaceScattering', 'Subsurface Scattering') sssShader.inputs[1].default_value = 60 sssShader.inputs["Color"].default_value = [R, G, B, 1] glossyShader = m.makeNode('ShaderNodeBsdfGlossy', 'Glossy BSDF') glossyShader.inputs[1].default_value = .30 m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(sssShader, 'BSSRDF', mixShader, 1) m.link(glossyShader, 'BSDF', mixShader2, 2) m.link(mixShader, 'Shader', mixShader2, 1) m.link(mixShader2, 'Shader', materialOutput, 'Surface') bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() activeObject.active_material = bpy.data.materials[NomeMaterial] bpy.context.object.active_material.diffuse_color = (R, G, B, 1) class MessageObjSelecionados(bpy.types.Operator): bl_idname = "object.dialog_operator_obj_selecionados" bl_label = "You have to select 6 objects!" def execute(self, context): message = ("You have to select 6 objects!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageObjSelecionados) # IMPORTA ARMATURE def ImportaArmatureDef(self, context): context = bpy.context obj = context.active_object scn = context.scene if platform.system() == "Linux" or platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Object\\" object = "Armature_Head" if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Object\\" object = "Armature_Head" filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) # bpy.ops.wm.append(filename=filename, directory=directory) # APAGA OBJETOS EXCEDENTES bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Mandibula'] b = bpy.data.objects['SETA_Corpo_M'] c = bpy.data.objects['SETA_Maxila'] d = bpy.data.objects['SETA_Mento'] a.select_set(True) b.select_set(True) c.select_set(True) d.select_set(True) bpy.ops.object.delete(use_global=False) class ImportaArmature(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_armature" bl_label = "Importa estrutura de bones" def execute(self, context): ImportaArmatureDef(self, context) return {'FINISHED'} # CONFIGURA CABEÇA def ConfiguraCabecaDef(self, context): context = bpy.context obj = context.active_object # scn = context.scene ob=bpy.data.objects["Armature_Head"] bpy.ops.object.mode_set(mode='EDIT') mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select_set(True) vg = obj.vertex_groups.new(name="ca") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') # Material CriaMaterialOsteotomia("MaterialCabeca", 0.8, 0.75, 0.2) bpy.context.object.name = "ca" armatureHead = bpy.data.objects['Armature_Head'] bpy.ops.object.select_all(action='DESELECT') armatureHead.hide_viewport=False armatureHead.select_set(True) bpy.context.view_layer.objects.active = armatureHead bpy.ops.object.posemode_toggle() # bpy.data.objects['ca'].select = True # bpy.data.objects['Armature_Head'].select = True # bpy.ops.object.parent_set(type='ARMATURE_NAME') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones['ca'] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones["ca"].constraints["Child Of"].target = bpy.data.objects["ca"] pbone = bpy.context.active_object.pose.bones["ca"] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() armatureHead.hide_viewport=True class ConfiguraCabeca(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_cabeca" bl_label = "Configura Cabeça" def execute(self, context): ConfiguraCabecaDef(self, context) return {'FINISHED'} # CONFIGURA MAXILA def ConfiguraMaxilaDef(self, context): context = bpy.context obj = context.active_object # scn = context.scene ob=bpy.data.objects["Armature_Head"] bpy.ops.object.mode_set(mode='EDIT') mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True vg = obj.vertex_groups.new(name="Maxila.GUIA") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') CriaMaterialOsteotomia("MaterialMaxila", 0.8, 0.3, 0.2) bpy.context.object.name = "ma" armatureHead = bpy.data.objects['Armature_Head'] bpy.ops.object.select_all(action='DESELECT') armatureHead.hide_viewport=False armatureHead.select_set(True) bpy.context.view_layer.objects.active = armatureHead bpy.ops.object.posemode_toggle() # bpy.data.objects['ma'].select = True # bpy.data.objects['Armature_Head'].select = True # bpy.ops.object.parent_set(type='ARMATURE_NAME') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones['Maxila.GUIA'] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones["Maxila.GUIA"].constraints["Child Of"].target = bpy.data.objects["ma"] pbone = bpy.context.active_object.pose.bones["Maxila.GUIA"] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() armatureHead.hide_viewport=True class ConfiguraMaxila(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_maxila" bl_label = "Configura Maxila" def execute(self, context): ConfiguraMaxilaDef(self, context) return {'FINISHED'} # CONFIGURA RAMO DIREITO def ConfiguraRamoDirDef(self, context): context = bpy.context obj = context.active_object # scn = context.scene ob=bpy.data.objects["Armature_Head"] bpy.ops.object.mode_set(mode='EDIT') mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True vg = obj.vertex_groups.new(name="rd") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') CriaMaterialOsteotomia("MaterialRamoDir", 0.4, 0.3, 0.8) bpy.context.object.name = "rd" armatureHead = bpy.data.objects['Armature_Head'] bpy.ops.object.select_all(action='DESELECT') armatureHead.hide_viewport=False armatureHead.select_set(True) bpy.context.view_layer.objects.active = armatureHead bpy.ops.object.posemode_toggle() # bpy.data.objects['rd'].select = True # bpy.data.objects['Armature_Head'].select = True # bpy.ops.object.parent_set(type='ARMATURE_NAME') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones['rd'] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones["rd"].constraints["Child Of"].target = bpy.data.objects["rd"] pbone = bpy.context.active_object.pose.bones["rd"] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() armatureHead.hide_viewport=True class ConfiguraRamoDir(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_ramo_dir" bl_label = "Configura Ramo Direito" def execute(self, context): ConfiguraRamoDirDef(self, context) return {'FINISHED'} # CONFIGURA RAMO ESQUERDO def ConfiguraRamoEsqDef(self, context): context = bpy.context obj = context.active_object # scn = context.scene ob=bpy.data.objects["Armature_Head"] bpy.ops.object.mode_set(mode='EDIT') mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True vg = obj.vertex_groups.new(name="re") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') CriaMaterialOsteotomia("MaterialRamoEsq", 0.4, 0.3, 0.8) bpy.context.object.name = "re" armatureHead = bpy.data.objects['Armature_Head'] bpy.ops.object.select_all(action='DESELECT') armatureHead.hide_viewport=False armatureHead.select_set(True) bpy.context.view_layer.objects.active = armatureHead bpy.ops.object.posemode_toggle() # bpy.data.objects['re'].select = True # bpy.data.objects['Armature_Head'].select = True # bpy.ops.object.parent_set(type='ARMATURE_NAME') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones['re'] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones["re"].constraints["Child Of"].target = bpy.data.objects["re"] pbone = bpy.context.active_object.pose.bones["re"] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() armatureHead.hide_viewport=True class ConfiguraRamoEsq(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_ramo_esq" bl_label = "Configura Ramo Esquerdo" def execute(self, context): ConfiguraRamoEsqDef(self, context) return {'FINISHED'} # CONFIGURA RAMO DA MANDÍBULA def ConfiguraCorpoMandDef(self, context): context = bpy.context obj = context.active_object # scn = context.scene ob=bpy.data.objects["Armature_Head"] bpy.ops.object.mode_set(mode='EDIT') mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True vg = obj.vertex_groups.new(name="Corpo_Mandibular.GUIA") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') CriaMaterialOsteotomia("MaterialCorpoMand", 0.35, 0.8, 0.4) bpy.context.object.name = "cm" armatureHead = bpy.data.objects['Armature_Head'] bpy.ops.object.select_all(action='DESELECT') armatureHead.hide_viewport=False armatureHead.select_set(True) bpy.context.view_layer.objects.active = armatureHead bpy.ops.object.posemode_toggle() # bpy.data.objects['cm'].select = True # bpy.data.objects['Armature_Head'].select = True # bpy.ops.object.parent_set(type='ARMATURE_NAME') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones['Corpo_Mandibular.GUIA'] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones["Corpo_Mandibular.GUIA"].constraints["Child Of"].target = bpy.data.objects["cm"] pbone = bpy.context.active_object.pose.bones["Corpo_Mandibular.GUIA"] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() armatureHead.hide_viewport=True class ConfiguraCorpoMand(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_corpo_mand" bl_label = "Configura Mento" def execute(self, context): ConfiguraCorpoMandDef(self, context) return {'FINISHED'} # CONFIGURA MENTO def ConfiguraMentoDef(self, context): context = bpy.context obj = context.active_object # scn = context.scene ob=bpy.data.objects["Armature_Head"] ob=bpy.data.objects["cm"] bpy.ops.object.mode_set(mode='EDIT') mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True vg = obj.vertex_groups.new(name="me") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') CriaMaterialOsteotomia("MaterialMento", 0.4, 0.3, 0.8) bpy.context.object.name = "me" armatureHead = bpy.data.objects['Armature_Head'] bpy.ops.object.select_all(action='DESELECT') armatureHead.hide_viewport=False armatureHead.select_set(True) bpy.context.view_layer.objects.active = armatureHead bpy.ops.object.posemode_toggle() # bpy.data.objects['me'].select = True # bpy.data.objects['Armature_Head'].select = True # bpy.ops.object.parent_set(type='ARMATURE_NAME') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones['me'] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones["me"].constraints["Child Of"].target = bpy.data.objects["me"] pbone = bpy.context.active_object.pose.bones["me"] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() armatureHead.hide_viewport=True a = bpy.data.objects['cm'] b = bpy.data.objects['me'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() class ConfiguraMento(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_mento" bl_label = "Configura Mento" def execute(self, context): ConfiguraMentoDef(self, context) return {'FINISHED'} # CONFIGURA OSTEO def ConfOsteotomiaAutoDef(self, context): objetos_selecionados = [ o for o in bpy.context.selected_objects ] # objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select ] objetos_visiveis = [] for i in objetos_selecionados: if i.visible_get() == True: objetos_visiveis.append(i.name) if len(objetos_visiveis) == 6: Obj_Hor = [] for i in objetos_selecionados: Obj_Hor.append(i.location[0]) # Ramos da mandíbula MaxHor = max(Obj_Hor) IndexMax = [i for i, j in enumerate(Obj_Hor) if j == MaxHor] re = objetos_selecionados[int(IndexMax[0])] print(re) MinHor = min(Obj_Hor) IndexMin = [i for i, j in enumerate(Obj_Hor) if j == MinHor] rd = objetos_selecionados[int(IndexMin[0])] print(rd) print("Len antes: ",len(objetos_selecionados)) objetos_selecionados.remove(re) objetos_selecionados.remove(rd) print("Len depois: ",len(objetos_selecionados)) # Cabeça e mento Obj_Ver = [] for i in objetos_selecionados: Obj_Ver.append(i.location[2]) MaxVer = max(Obj_Ver) IndexMax = [i for i, j in enumerate(Obj_Ver) if j == MaxVer] ca = objetos_selecionados[int(IndexMax[0])] print(ca) MinVer = min(Obj_Ver) IndexMin = [i for i, j in enumerate(Obj_Ver) if j == MinVer] me = objetos_selecionados[int(IndexMin[0])] print(me) print("Len antes: ",len(objetos_selecionados)) objetos_selecionados.remove(ca) objetos_selecionados.remove(me) print("Len depois: ",len(objetos_selecionados)) # Maxila e corpo da mandíbula Obj_Ver = [] for i in objetos_selecionados: Obj_Ver.append(i.location[2]) MaxVer = max(Obj_Ver) IndexMax = [i for i, j in enumerate(Obj_Ver) if j == MaxVer] ma = objetos_selecionados[int(IndexMax[0])] print(ma) MinVer = min(Obj_Ver) IndexMin = [i for i, j in enumerate(Obj_Ver) if j == MinVer] cm = objetos_selecionados[int(IndexMin[0])] print(cm) # Configura osteotomias bpy.ops.object.importa_armature() ca.select_set(True) bpy.context.view_layer.objects.active = ca bpy.ops.object.configura_cabeca() bpy.ops.object.select_all(action='DESELECT') ma.select_set(True) bpy.context.view_layer.objects.active = ma bpy.ops.object.configura_maxila() bpy.ops.object.select_all(action='DESELECT') rd.select_set(True) bpy.context.view_layer.objects.active = rd bpy.ops.object.configura_ramo_dir() bpy.ops.object.select_all(action='DESELECT') re.select_set(True) bpy.context.view_layer.objects.active = re bpy.ops.object.configura_ramo_esq() bpy.ops.object.select_all(action='DESELECT') cm.select_set(True) bpy.context.view_layer.objects.active = cm bpy.ops.object.configura_corpo_mand() bpy.ops.object.select_all(action='DESELECT') me.select_set(True) bpy.context.view_layer.objects.active = me bpy.ops.object.configura_mento() bpy.ops.object.select_all(action='DESELECT') # Zera Deltas lista_osteo = ['ca','ma', 'cm', 'rd', 're', 'me'] for i in lista_osteo: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[i].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[i] # bpy.ops.object.transforms_to_deltas(mode='ALL') # Se zerar dá problema no collision futuro. bpy.ops.anim.ortog_loc_rot() bpy.ops.object.select_all(action='DESELECT') bpy.context.scene.frame_end = 100 bpy.context.scene.frame_current = 100 if len(objetos_visiveis) != 6: print("Selecione os 6 objetos!") bpy.ops.object.dialog_operator_obj_selecionados('INVOKE_DEFAULT') class ConfOsteotomiaAuto(bpy.types.Operator): """Tooltip""" bl_idname = "object.conf_osteo_auto" bl_label = "Configura osteotomias automaticamente" def execute(self, context): ConfOsteotomiaAutoDef(self, context) return {'FINISHED'} # OSTEOTOMIA GERALAUTOMÁTICA def OsteoMoleAutomaticaDef(): context = bpy.context obj = context.active_object scn = context.scene #CRIA OS OSSOS # Lista tdos os objetos em um objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_set ] # Coloca o cursor na pocição do primeiro objeto #Adiciona e apaga em modo de edição bpy.ops.object.armature_add(radius=1, view_align=False, enter_editmode=False) bpy.ops.object.editmode_toggle() bpy.ops.armature.select_all(action='TOGGLE') bpy.ops.armature.select_all(action='TOGGLE') bpy.ops.armature.delete() for i in objetos_selecionados: if i.visible_get() == True: bpy.context.scene.cursor.location = (i.location) bpy.ops.armature.bone_primitive_add(name=i.name) bpy.ops.object.editmode_toggle() bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # Lista Objetos ob = bpy.context.object LisObjetos = [] if ob.type == 'ARMATURE': armature = ob.data for bone in armature.bones: print(bone.name) LisObjetos.append(bone.name) print("FIM") print(LisObjetos) # Cria Material bpy.ops.object.select_all(action='DESELECT') for i in LisObjetos: activeObject = bpy.data.objects[i] #Set active object to variable mat = bpy.data.materials.new(name=i) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object # bpy.context.object.active_material.diffuse_color = (0.8, 0.35, 0.2) #change color activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) # bpy.context.object.name = "me" # Cria áreas de interesse Face = bpy.data.objects['FaceMesh'] Face.hide_set(False) bpy.ops.object.select_all(action='DESELECT') Face.select_set(True) context.view_layer.objects.active = Face bpy.ops.object.mode_set(mode='EDIT') # Vertex Groups mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True for i in LisObjetos: Face.vertex_groups.new(name=i) scn.tool_settings.vertex_group_weight=0 #bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # Vertex Proximtiy for i in LisObjetos: bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = i bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects[i] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 60 #25 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 12 #8 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'SHARP' bpy.context.object.modifiers["VertexWeightProximity"].name = i bpy.context.object.modifiers[i].show_expanded = False # Converte em objeto bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.convert(target='MESH') # Parenteia Armature ArmatureOssos = bpy.data.objects['Armature'] ArmatureOssos.hide_set(False) bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = ArmatureOssos bpy.data.objects['FaceMesh'].select_set(True) ArmatureOssos.select_set(True) bpy.ops.object.parent_set(type='ARMATURE_NAME') #ArmatureOssos.hide=True #bpy.ops.object.select_all(action='DESELECT') #bpy.data.objects['FaceMesh'].select = True #bpy.context.scene.objects.active = bpy.data.objects['FaceMesh'] # Atrela malhas as armaduras bpy.ops.object.select_all(action='DESELECT') ArmatureOssos.select_set(True) bpy.context.view_layer.objects.active = ArmatureOssos #bpy.ops.object.posemode_toggle() for i in LisObjetos: bpy.ops.object.mode_set(mode='POSE') bpy.ops.pose.select_all(action='DESELECT') o=bpy.context.object b=o.data.bones[i] b.select=True o.data.bones.active=b bpy.ops.pose.constraint_add(type='CHILD_OF') bpy.context.object.pose.bones[i].constraints["Child Of"].target = bpy.data.objects[i] pbone = bpy.context.active_object.pose.bones[i] # Bone context_copy = bpy.context.copy() context_copy["constraint"] = pbone.constraints["Child Of"] bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE') bpy.ops.object.posemode_toggle() bpy.ops.transform.translate(value=(0,0,0)) class OsteoMoleAutomatica(bpy.types.Operator): """Tooltip""" bl_idname = "object.conf_osteo_mole_auto" bl_label = "Configura osteotomias automaticamente" def execute(self, context): OsteoMoleAutomaticaDef() return {'FINISHED'} bpy.utils.register_class(OsteoMoleAutomatica) def RenomearObjeto(nome): context = bpy.context obj = context.active_object scn = context.scene bpy.context.object.name = nome class NomeFace(bpy.types.Operator): """Tooltip""" bl_idname = "object.nome_face_malha" bl_label = "Set Face Mesh" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT': return True else: return False else: return False def execute(self, context): RenomearObjeto("FaceMesh") bpy.context.object.hide_set(True) return {'FINISHED'} bpy.utils.register_class(NomeFace) ================================================ FILE: CortaOssoFibula.py ================================================ import fnmatch from .PontosAnatomicos import * # Pontos class Cut_Point_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cut_point_pt" bl_label = "Condyle Rotation Point" bl_options = {'REGISTER', 'UNDO'} ''' @classmethod def poll(cls, context): found = 'Condyle Rotation Point' in bpy.data.objects if found == False: return True else: if found == True: return False ''' def execute(self, context): CriaPontoDef('CutPoint', 'Cut Points') #TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cut_Point_pt) # Gera medidas def CriaCotaCut(Objeto1, Objeto2): context = bpy.context scn = context.scene bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[Objeto1].select_set(True) bpy.data.objects[Objeto2].select_set(True) context.view_layer.objects.active = bpy.data.objects[Objeto1] bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') def AtribuiCotasCut(): ListaCutPoints = [] for i in bpy.data.objects: if fnmatch.fnmatchcase(i.name, "CutPoint.0*"): ListaCutPoints.append(i.name) ListaCutPoints.append("CutPoint") #print("Lista:", ListaCutPoints) TamanhoLista = len(ListaCutPoints) print(TamanhoLista) ItemLista = 0 #ListaPares = [] for i in range(TamanhoLista): try: print("valor",i) print(ListaCutPoints[ItemLista], ListaCutPoints[ItemLista+1]) CriaCotaCut(ListaCutPoints[ItemLista], ListaCutPoints[ItemLista+1]) #ListaPares.append([ListaCutPoints[ItemLista], ListaCutPoints[ItemLista+1]]) ItemLista += 1 except: print("Finalizado!") #print("ListaPares:", ListaPares) class CriaCotasBotao(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_cotas_botao" bl_label = "Create Measure on Cut Poins" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): AtribuiCotasCut() return {'FINISHED'} bpy.utils.register_class(CriaCotasBotao) # Cria bones def CriaBonesDef(): ListaCutPoints = [] for i in bpy.data.objects: if fnmatch.fnmatchcase(i.name, "CutPoint.0*"): ListaCutPoints.append(i.name) ListaCutPoints.append("CutPoint") TamanhoLista = len(ListaCutPoints) print(TamanhoLista) ItemLista = 0 bpy.context.scene.cursor.location = 0,0,0 bpy.ops.object.armature_add(radius=1, view_align=False, enter_editmode=True) for i in range(TamanhoLista): try: print("AQUIIIII") print("ITEM LISTA LOCARION:", bpy.data.objects[ListaCutPoints[ItemLista]].location) print("ITEM LISTA LOCARION:", bpy.data.objects[ListaCutPoints[ItemLista+1]].location) bpy.context.scene.cursor.location = bpy.data.objects[ListaCutPoints[ItemLista]].location bpy.ops.armature.bone_primitive_add() bpy.context.object.data.edit_bones["Bone"].name = ListaCutPoints[ItemLista] print("INTEMLISTA: ", ListaCutPoints[ItemLista]) bpy.context.object.data.edit_bones[ListaCutPoints[ItemLista]].head = bpy.data.objects[ListaCutPoints[ItemLista+1]].location print(bpy.data.objects[ListaCutPoints[ItemLista+1]].location) bpy.context.object.data.edit_bones[ListaCutPoints[ItemLista]].tail = bpy.data.objects[ListaCutPoints[ItemLista]].location print(bpy.data.objects[ListaCutPoints[ItemLista]].location) ItemLista += 1 except: print("Finalizado!") #print("ListaPares:", ListaPares) bpy.ops.object.mode_set(mode='OBJECT') # Volta ao modo de objeto class CriaBones(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_bones_fibula" bl_label = "Create Fibula Bones" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaBonesDef() return {'FINISHED'} bpy.utils.register_class(CriaBones) ================================================ FILE: CriaSplint.py ================================================ import bpy import platform import time from random import randint # IMPORTA SPLINT COM ARMATURE def ImportaSplintDef(self, context): context = bpy.context obj = context.active_object scn = context.scene if platform.system() == "Linux": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" # section = "\\Collection\\" # object = "SPLINT" section = "\\Object\\" object = "SPLINT" if platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Object\\" object = "SPLINT" if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Object\\" object = "SPLINT" # if platform.system() == "Darwin": # dirScript = bpy.utils.user_resource('SCRIPTS') # blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" # section = "\\Group\\" # object = "SPLINT" filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) class ImportaSplint(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_splint" bl_label = "Importa Splint" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ImportaSplintDef(self, context) return {'FINISHED'} bpy.utils.register_class(ImportaSplint) # CRIA EMPTIES INTERMEDIÁRIOS def CriaSplintDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 8'] b = bpy.data.objects['Tooth 25'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.empty_add(type='SPHERE') bpy.context.object.name = "EMP1141" bpy.context.object.empty_display_size = .5 ''' a = bpy.data.objects['cm'] b = bpy.data.objects['EMP1141'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ''' # ---------------------------- a = bpy.data.objects['Tooth 9'] b = bpy.data.objects['Tooth 24'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.empty_add(type='SPHERE') bpy.context.object.name = "EMP2131" bpy.context.object.empty_display_size = .5 ''' a = bpy.data.objects['cm'] b = bpy.data.objects['EMP2131'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ''' # ---------------------------- a = bpy.data.objects['Tooth 11'] b = bpy.data.objects['Tooth 22'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.empty_add(type='SPHERE') bpy.context.object.name = "EMP2333" bpy.context.object.empty_display_size = .5 ''' a = bpy.data.objects['cm'] b = bpy.data.objects['EMP2333'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ''' # ---------------------------- a = bpy.data.objects['Tooth 6'] b = bpy.data.objects['Tooth 27'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.empty_add(type='SPHERE') bpy.context.object.name = "EMP1343" bpy.context.object.empty_display_size = .5 ''' a = bpy.data.objects['cm'] b = bpy.data.objects['EMP1343'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ''' # ---------------------------- a = bpy.data.objects['Tooth 14'] b = bpy.data.objects['Tooth 19'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.empty_add(type='SPHERE') bpy.context.object.name = "EMP2636" bpy.context.object.empty_display_size = .5 ''' a = bpy.data.objects['cm'] b = bpy.data.objects['EMP2636'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ''' # ---------------------------- a = bpy.data.objects['Tooth 3'] b = bpy.data.objects['Tooth 30'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.empty_add(type='SPHERE') bpy.context.object.name = "EMP1646" bpy.context.object.empty_display_size = .5 ''' a = bpy.data.objects['cm'] b = bpy.data.objects['EMP1646'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = a bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') ''' # --------------- bpy.ops.object.importa_splint() # -------------- bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMP1646'] a.select_set(True) bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMPbone1646'] a.select_set(True) bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMP1343'] a.select_set(True) bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMPbone1343'] a.select_set(True) bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMP1141'] a.select_set(True) bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMPbone1141'] a.select_set(True) bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMP2131'] a.select_set(True) bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMPbone2131'] a.select_set(True) bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMP2333'] a.select_set(True) bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMPbone2333'] a.select_set(True) bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMP2636'] a.select_set(True) bpy.ops.view3d.snap_cursor_to_selected() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['EMPbone2636'] a.select_set(True) bpy.ops.view3d.snap_selected_to_cursor(use_offset=False) class CriaSplint(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_splint" bl_label = "Cria Splint" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'SPLINT_pronto' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaSplintDef(self, context) bpy.ops.object.select_all(action='DESELECT') splint = bpy.data.objects['SPLINT'] splint.select_set(True) context.view_layer.objects.active = splint bpy.ops.object.convert(target='MESH') bpy.context.object.name = "SPLINT_pronto" bpy.ops.object.select_all(action='DESELECT') objetos = ["Armature", "EMPbone1646", "EMPbone1343", "EMPbone1141", "EMPbone2131", "EMPbone2333", "EMPbone2636", "EMP1646", "EMP1343", "EMP1141", "EMP2131", "EMP2333", "EMP2636"] for item in objetos: bpy.ops.object.select_all(action='DESELECT') ObjAtual = bpy.data.objects[item] ObjAtual.select_set(True) context.view_layer.objects.active = ObjAtual bpy.ops.object.delete(use_global=False) SplintFinal = bpy.data.objects['SPLINT_pronto'] SplintFinal.select_set(True) context.view_layer.objects.active = SplintFinal bpy.ops.object.collection_link(collection='Collection') return {'FINISHED'} bpy.utils.register_class(CriaSplint) def DuplicaMaxMandDef(): bpy.ops.object.select_all(action='DESELECT') if bpy.data.objects.get("MaxillaMand") is not None: bpy.data.objects['MaxillaMand'].name = "Deletar" bpy.data.objects['ma'].select_set(True) bpy.data.objects['cm'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['ma'] bpy.ops.object.duplicate() bpy.ops.object.join() NomeMaterial = "MaxillaMand"+time.strftime("%Y%m%d%H%M%S") bpy.context.object.name = "MaxillaMand" # Deleta todos os objetos for x in bpy.context.object.material_slots: bpy.context.object.active_material_index = 0 bpy.ops.object.material_slot_remove() activeObject = bpy.data.objects["MaxillaMand"] #Set active object to variable mat = bpy.data.materials.new(name=NomeMaterial) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) bpy.data.objects['ma'].hide_set(True) bpy.data.objects['cm'].hide_set(True) class DuplicaMaxMand(bpy.types.Operator): """Tooltip""" bl_idname = "object.duplica_max_mand" bl_label = "Maxilla Mandible Duplication" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'MaxillaMand' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): DuplicaMaxMandDef() return {'FINISHED'} bpy.utils.register_class(DuplicaMaxMand) def VisualizaMaxMandDef(): if bpy.data.objects.get("Splint_result") is not None: bpy.data.objects['Splint_result'].name = "SPLINT_ready" if bpy.data.objects.get("SPLINT_pronto") is not None: bpy.data.objects['SPLINT_pronto'].name = "SPLINT_del" if bpy.data.objects.get("MaxillaMand") is not None: bpy.data.objects['MaxillaMand'].name = "Deletar" bpy.data.objects['ma'].hide_set(False) bpy.data.objects['cm'].hide_set(False) class VisualizaMaxMand(bpy.types.Operator): """Tooltip""" bl_idname = "object.visualiza_max_mand" bl_label = "Maxilla Mandible View" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): VisualizaMaxMandDef() return {'FINISHED'} bpy.utils.register_class(VisualizaMaxMand) class MessageNaoConstaSplintPronto(bpy.types.Operator): bl_idname = "object.dialog_operator_falta_splint_pronto" bl_label = "Doesn't have SPLINT_pronto, rename it!" def execute(self, context): message = ("Doesn't have SPLINT_pronto, rename it!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageNaoConstaSplintPronto) def BooleanSplintDef(): bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['SPLINT_pronto'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['SPLINT_pronto'] bpy.context.object.name = "Splint_usado" bpy.context.object.name = "Splint_usado" bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['MaxillaMand'].select_set(True) bpy.data.objects['Splint_usado'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['MaxillaMand'] bpy.ops.object.booleana_osteo_geral() bpy.context.object.name = "Splint_result" class BooleanSplint(bpy.types.Operator): """Tooltip""" bl_idname = "object.boolean_splint" bl_label = "Boolean Splint" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Splint_result' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): found = 'SPLINT_pronto' in bpy.data.objects if found == True: bpy.ops.object.duplica_max_mand() BooleanSplintDef() if found == False: bpy.ops.object.dialog_operator_falta_splint_pronto('INVOKE_DEFAULT') return {'FINISHED'} bpy.utils.register_class(BooleanSplint) def SplintMantemKeyStart(objeto, quadro): scn = bpy.context.scene obj = bpy.data.objects[objeto] animData = obj.animation_data action = animData.action fcurves = action.fcurves current_frame = scn.frame_current for i in fcurves: i.keyframe_points.insert(quadro, i.keyframe_points[0].co.y) # Primeiro keyframe i.keyframe_points[0].co.y += 0 # Atualiza a animação! bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) def SplintMantemKeyEnd(objeto, quadro): scn = bpy.context.scene obj = bpy.data.objects[objeto] animData = obj.animation_data action = animData.action fcurves = action.fcurves current_frame = scn.frame_current for i in fcurves: i.keyframe_points.insert(quadro, i.keyframe_points[1].co.y) # Primeiro keyframe i.keyframe_points[1].co.y += 0 # Atualiza a animação! bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) def SplintMaxilaOrigiMandFinalDef(): context = bpy.context scn = context.scene SplintMantemKeyStart('ma', 110) SplintMantemKeyEnd('cm', 110) SplintMantemKeyEnd('ma', 120) SplintMantemKeyEnd('cm', 120) bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR' bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['Condyle Rotation Point'].select_set(True) context.view_layer.objects.active = bpy.data.objects['Condyle Rotation Point'] bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['cm'].select_set(True) context.view_layer.objects.active = bpy.data.objects['cm'] class SplintMaxilaOrigiMandFinal(bpy.types.Operator): """Tooltip""" bl_idname = "object.splint_maxila_origi_mand_final" bl_label = "Splint Maxilla Origin Mandible Final" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Condyle Rotation Point' in bpy.data.objects if found == False: return False else: if found == True: return True def execute(self, context): SplintMaxilaOrigiMandFinalDef() return {'FINISHED'} bpy.utils.register_class(SplintMaxilaOrigiMandFinal) def SplintMandOrigiMaxilaFinalDef(): context = bpy.context scn = context.scene SplintMantemKeyStart('cm', 110) SplintMantemKeyEnd('ma', 110) SplintMantemKeyEnd('ma', 120) SplintMantemKeyEnd('cm', 120) bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR' bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['Condyle Rotation Point'].select_set(True) context.view_layer.objects.active = bpy.data.objects['Condyle Rotation Point'] bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['cm'].select_set(True) context.view_layer.objects.active = bpy.data.objects['cm'] class SplintMandOrigiMaxilaFinal(bpy.types.Operator): """Tooltip""" bl_idname = "object.splint_mand_origi_maxila_final" bl_label = "Splint Mandible Origin Maxilla Final" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Condyle Rotation Point' in bpy.data.objects if found == False: return False else: if found == True: return True def execute(self, context): SplintMandOrigiMaxilaFinalDef() return {'FINISHED'} bpy.utils.register_class(SplintMandOrigiMaxilaFinal) ================================================ FILE: DesenhaGuia.py ================================================ import bpy import fnmatch import bmesh import time def DesenhaGuiaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene # bpy.ops.gpencil.convert(type='PATH') # bpy.ops.gpencil.layer_remove() bpy.ops.gpencil.convert_old_files() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.convert(type='POLY', use_timing_data=True) # Seleciona linha e converte em mesh bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['Note'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['Note'] # bpy.ops.object.convert(target='MESH') bpy.ops.object.convert(target='CURVE') # Adiciona MBall bpy.ops.object.metaball_add(type='BALL', radius=1) Linha = bpy.data.objects['Note'] bpy.ops.object.select_all(action='DESELECT') Linha.select_set(True) bpy.context.view_layer.objects.active = Linha # bpy.context.space_data.context = 'DATA' bpy.context.object.data.fill_mode = 'FULL' bpy.context.object.data.bevel_depth = 10 bpy.ops.object.convert(target='MESH') bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].use_remove_disconnected = False bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 6 bpy.ops.object.convert(target='MESH') # bpy.context.space_data.context = 'PARTICLES' bpy.ops.object.particle_system_add() bpy.data.particles["ParticleSettings"].type = 'HAIR' bpy.data.particles["ParticleSettings"].render_type = 'OBJECT' bpy.data.particles["ParticleSettings"].count = 2000 # bpy.data.particles["ParticleSettings"].dupli_object = bpy.data.objects["Mball"] bpy.data.particles["ParticleSettings"].instance_object = bpy.data.objects["Mball"] bpy.data.particles["ParticleSettings"].particle_size = 0.6 bpy.data.particles["ParticleSettings"].name = "DELETE" # Senão não funciona, pois usa o nome anterior Guia = bpy.data.objects['Mball'] bpy.ops.object.select_all(action='DESELECT') Guia.select_set(True) bpy.context.view_layer.objects.active = Guia bpy.context.object.name = "CirGuide" bpy.ops.object.convert(target='MESH') bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 6 # antes 8 = muito pesado bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 20 # Antes 50 = muito arredondado para o 6 # bpy.ops.object.modifier_add(type='DECIMATE') # bpy.context.object.modifiers["Decimate"].ratio = 0.1 GuiaCopia = bpy.data.objects['CirGuide.001'] bpy.ops.object.select_all(action='DESELECT') GuiaCopia.select_set(True) bpy.context.view_layer.objects.active = GuiaCopia bpy.ops.object.convert(target='MESH') bpy.ops.object.select_all(action='DESELECT') Linha.select_set(True) bpy.context.view_layer.objects.active = Linha bpy.ops.object.delete(use_global=False) bpy.ops.object.select_all(action='DESELECT') GuiaCopia.select_set(True) bpy.context.view_layer.objects.active = GuiaCopia class DesenhaGuia(bpy.types.Operator): """Tooltip""" bl_idname = "object.desenha_guia" bl_label = "Desenha_Guia" def execute(self, context): DesenhaGuiaDef(self, context) return {'FINISHED'} bpy.utils.register_class(DesenhaGuia) ================================================ FILE: DesenhaObjetos.py ================================================ import bpy import fnmatch import bmesh import time from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup, ) from mathutils import Matrix, Vector from bpy_extras.object_utils import AddObjectHelper, object_data_add from .ConfOsteotomiaAuto import * def DesenhaGuiaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.gpencil.convert(type='PATH') bpy.ops.gpencil.layer_remove() # Adiciona MBall bpy.ops.object.metaball_add(type='BALL', radius=1) Linha = bpy.data.objects['GP_Layer'] bpy.ops.object.select_all(action='DESELECT') Linha.select = True bpy.context.scene.objects.active = Linha # bpy.context.space_data.context = 'DATA' bpy.context.object.data.fill_mode = 'FULL' bpy.context.object.data.bevel_depth = 10 bpy.ops.object.convert(target='MESH') bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].use_remove_disconnected = False bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 6 bpy.ops.object.convert(target='MESH') # bpy.context.space_data.context = 'PARTICLES' bpy.ops.object.particle_system_add() bpy.data.particles["ParticleSettings"].type = 'HAIR' bpy.data.particles["ParticleSettings"].render_type = 'OBJECT' bpy.data.particles["ParticleSettings"].count = 2000 bpy.data.particles["ParticleSettings"].dupli_object = bpy.data.objects["Mball"] bpy.data.particles["ParticleSettings"].particle_size = 0.6 bpy.data.particles["ParticleSettings"].name = "DELETE" # Senão não funciona, pois usa o nome anterior bpy.ops.object.select_all(action='DESELECT') Linha.select = True bpy.context.scene.objects.active = Linha bpy.ops.object.delete(use_global=False) Guia = bpy.data.objects['Mball'] bpy.ops.object.select_all(action='DESELECT') Guia.select = True bpy.context.scene.objects.active = Guia bpy.context.object.name = "CirGuide" bpy.ops.object.convert(target='MESH') bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 120 bpy.ops.object.modifier_add(type='DECIMATE') bpy.context.object.modifiers["Decimate"].ratio = 0.1 bpy.ops.object.convert(target='MESH') def AcabamentoDef(self, context): context = bpy.context obj = context.active_object scn = context.scene GuiaParte = bpy.context.active_object bpy.ops.gpencil.convert(type='PATH') bpy.ops.gpencil.layer_remove() Linha = bpy.data.objects['GP_Layer'] # Linha.select = True # bpy.context.scene.objects.active = Linha # bpy.ops.object.convert(target='MESH') bpy.ops.object.select_all(action='DESELECT') GuiaParte.select = True Linha.select = True bpy.context.scene.objects.active = GuiaParte bpy.ops.object.corta_ossos() bpy.ops.object.select_all(action='DESELECT') Linha.select = True bpy.context.scene.objects.active = Linha bpy.ops.object.delete(use_global=False) ObjAcabamento = bpy.data.objects['OssoPronto'] bpy.ops.object.select_all(action='DESELECT') ObjAcabamento.select = True bpy.context.scene.objects.active = ObjAcabamento bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_mode(type="EDGE") bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.select_non_manifold(use_non_contiguous=False) # bpy.ops.object.triangle_fill(res_mode='MAX') def FechaBuracoDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.triangle_fill(res_mode = 'MAX') def DesenhaLinhaCorteDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Osso = bpy.context.active_object bpy.ops.object.collection_link(collection='Collection') # Seleciona linha e converte em mesh bpy.ops.gpencil.convert_old_files() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.convert(type='POLY', use_timing_data=True) bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['Note'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['Note'] bpy.ops.object.convert(target='MESH') # Subdivide pois nessa versão a linha está simplificada bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.subdivide(quadcorner='INNERVERT') bpy.ops.mesh.subdivide() bpy.ops.mesh.remove_doubles() # Para juntar as partes separadas bpy.ops.mesh.remove_doubles(threshold=2) bpy.ops.mesh.subdivide() bpy.ops.object.editmode_toggle() # Modificadores para ficar sobre a superfície bpy.ops.object.modifier_add(type='SHRINKWRAP') # bpy.context.object.modifiers["Shrinkwrap"].use_keep_above_surface = True bpy.context.object.modifiers["Shrinkwrap"].wrap_mode = 'ABOVE_SURFACE' bpy.context.object.modifiers["Shrinkwrap"].target = Osso bpy.context.object.modifiers["Shrinkwrap"].offset = 1.5 bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 1 bpy.context.object.modifiers["Smooth"].iterations = 1 bpy.ops.object.convert(target='MESH') bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='TOGGLE') bpy.ops.mesh.remove_doubles() bpy.ops.mesh.remove_doubles(threshold=2) bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.edge_face_add() # bpy.ops.mesh.fill() bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":.5, "use_even_offset":False, "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":False, "use_accurate":False}) bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.edge_face_add() bpy.ops.object.editmode_toggle() bpy.context.object.name = "Corte" Linha = bpy.data.objects['Corte'] bpy.ops.object.select_all(action='DESELECT') Linha.select_set(True) Osso.select_set(True) bpy.context.view_layer.objects.active = Osso # Se não duplicar não funciona! # bpy.ops.object.duplicate() bpy.ops.object.booleana_osteo() #Joga osso para copier Osso.select_set(True) bpy.context.view_layer.objects.active = Osso bpy.ops.object.hide_view_set(unselected=False) # bpy.ops.object.collection_link(collection='Copied_Objects') # bpy.data.collections['Collection'].objects.unlink(Osso) bpy.ops.object.select_all(action='DESELECT') # Apaga os objetos anteriores # bpy.ops.object.select_all(action='DESELECT') # Linha.select_set(True) # Osso.select_set(True) # bpy.ops.object.delete(use_global=False) class DesenhaLinhaCorte(bpy.types.Operator): """Tooltip""" bl_idname = "object.desenha_linha_corte" bl_label = "Desenha Linha Corte" # ------------------------------ # Poll # ------------------------------ @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT': return True else: return False else: return False def execute(self, context): DesenhaLinhaCorteDef(self, context) return {'FINISHED'} def DesenhaLinhaVertexDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Osso = bpy.context.active_object # Renomeia para não dar erro OssoNome = Osso.name Osso.name = OssoNome+time.strftime("%Y%m%d%H%M%S") bpy.ops.object.collection_link(collection='Collection') print("NOMEDADO") # Seleciona linha e converte em mesh bpy.ops.gpencil.convert_old_files() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.convert(type='POLY', use_timing_data=True) bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['Note'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['Note'] bpy.ops.object.convert(target='MESH') # Subdivide pois nessa versão a linha está simplificada bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.subdivide(quadcorner='INNERVERT') bpy.ops.mesh.subdivide() bpy.ops.mesh.remove_doubles() # Para juntar as partes separadas bpy.ops.mesh.remove_doubles(threshold=2) bpy.ops.mesh.subdivide() bpy.ops.object.editmode_toggle() # Modificadores para ficar sobre a superfície bpy.ops.object.modifier_add(type='SHRINKWRAP') # bpy.context.object.modifiers["Shrinkwrap"].use_keep_above_surface = True bpy.context.object.modifiers["Shrinkwrap"].wrap_mode = 'ABOVE_SURFACE' bpy.context.object.modifiers["Shrinkwrap"].target = Osso bpy.context.object.modifiers["Shrinkwrap"].offset = 1.5 bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 1 bpy.context.object.modifiers["Smooth"].iterations = 1 bpy.ops.object.convert(target='MESH') bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='TOGGLE') bpy.ops.mesh.remove_doubles() bpy.ops.mesh.remove_doubles(threshold=2) bpy.ops.object.mode_set(mode='OBJECT') bpy.context.object.name = "Linha_"+Osso.name bpy.ops.object.mode_set(mode='EDIT') class DesenhaLinhaVertex(bpy.types.Operator): """Tooltip""" bl_idname = "object.desenha_linha_vertex" bl_label = "Desenha Linha Corte" # ------------------------------ # Poll # ------------------------------ @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT': return True else: return False else: return False def execute(self, context): DesenhaLinhaVertexDef(self, context) return {'FINISHED'} def DesenhaLinhaVertexFinDef(self, context): context = bpy.context scn = context.scene Linha = context.active_object bpy.ops.object.mode_set(mode='EDIT') # É NECESSÁRIO SELECIONAR OS EDGES!!! NÃO OS VÉRTICES! # mesh = bmesh.from_edit_mesh(Linha.data) # for e in mesh.edges: # e.select = True # trigger viewport update # bpy.context.scene.objects.active = bpy.context.scene.objects.active bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.edge_face_add() # bpy.ops.mesh.fill() bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":.5, "use_even_offset":False, "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":False, "use_accurate":False}) bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.edge_face_add() ''' bpy.ops.mesh.extrude_region() bpy.ops.mesh.extrude_region_move(MESH_OT_extrude_region={"use_normal_flip":False, "mirror":False}, TRANSFORM_OT_translate={"value":(1.81608e-08, .6, .6), "orient_type":'NORMAL', "orient_matrix":((0.238327, 0.958761, 0.154848), (0.00483444, -0.160612, 0.987006), (0.971173, -0.234481, -0.0429132)), "orient_matrix_type":'NORMAL', "constraint_axis":(False, False, True), "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}) ''' bpy.ops.object.editmode_toggle() Osso = bpy.data.objects[str(Linha.name.strip("Linha_"))] print("OSSSOOO", Osso) bpy.context.object.name = "Corte" # OssoNome = Osso.name # Osso.name = OssoNome+time.strftime("%Y%m%d%H%M%S") # print("NOMEDADO") bpy.ops.object.select_all(action='DESELECT') Linha.select_set(True) Osso.select_set(True) bpy.context.view_layer.objects.active = Osso # Se não duplicar não funciona! # bpy.ops.object.duplicate() bpy.ops.object.booleana_osteo() # Apaga os objetos anteriores bpy.ops.object.select_all(action='DESELECT') Linha.select_set(True) Osso.select_set(True) bpy.ops.object.delete(use_global=False) class DesenhaLinhaVertexFin(bpy.types.Operator): """Tooltip""" bl_idname = "object.desenha_linha_vertex_fin" bl_label = "Desenha Linha Corte" def execute(self, context): DesenhaLinhaVertexFinDef(self, context) return {'FINISHED'} def LinhaCorteDef(self, context): context = bpy.context scn = context.scene # bpy.context.scene.tool_settings.gpencil_stroke_placement_view3d = 'SURFACE' # bpy.ops.gpencil.convert(type='POLY', timing_mode='LINEAR', use_timing_data=False) # bpy.ops.gpencil.draw('INVOKE_DEFAULT', mode="DRAW_POLY") #bpy.ops.gpencil.annotate(mode="DRAW_POLY") bpy.ops.wm.tool_set_by_id(name="builtin.annotate_polygon") # Capturar direto dos botões da interface bpy.context.scene.tool_settings.annotation_stroke_placement_view3d = 'SURFACE' class LinhaCorte(bpy.types.Operator): """Tooltip""" bl_idname = "object.linha_corte" bl_label = "Desenha Linha Corte" # ------------------------------ # Poll # ------------------------------ @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT': return True else: return False else: return False def execute(self, context): LinhaCorteDef(self, context) return {'FINISHED'} def LinhaCorteForaaForaDef(self, context): context = bpy.context scn = context.scene # bpy.context.scene.tool_settings.gpencil_stroke_placement_view3d = 'SURFACE' # bpy.ops.gpencil.convert(type='POLY', timing_mode='LINEAR', use_timing_data=False) # bpy.ops.gpencil.draw('INVOKE_DEFAULT', mode="DRAW_POLY") #bpy.ops.gpencil.annotate(mode="DRAW_POLY") bpy.ops.wm.tool_set_by_id(name="builtin.annotate_polygon") # Capturar direto dos botões da interface bpy.context.scene.tool_settings.annotation_stroke_placement_view3d = 'CURSOR' class LinhaCorteForaaFora(bpy.types.Operator): """Tooltip""" bl_idname = "object.linha_corte_fora_a_fora" bl_label = "Desenha Linha Corte" # ------------------------------ # Poll # ------------------------------ @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT': return True else: return False else: return False def execute(self, context): LinhaCorteForaaForaDef(self, context) return {'FINISHED'} bpy.utils.register_class(LinhaCorteForaaFora) # Modal class ModalTimerOperator(bpy.types.Operator): """Operator which runs its self from a timer""" bl_idname = "wm.modal_cria_pontos" bl_label = "Create points line" _timer = None def modal(self, context, event): context = bpy.context obj = context.active_object context.view_layer.active_layer_collection = context.view_layer.layer_collection.children[0] bpy.ops.wm.tool_set_by_id(name="builtin.cursor") if event.type in {'RIGHTMOUSE', 'ESC'}: self.cancel(context) return {'CANCELLED'} # bpy.ops.object.select_pattern(pattern="Cub*") # Seleciona objetos com esse padrão if event.type == 'LEFTMOUSE' and event.value == 'RELEASE': if context.area.type == 'VIEW_3D': region = context.region r3d = context.space_data.region_3d # bpy.ops.object.empty_add(type='PLAIN_AXES', radius=1, location=(0,0,0)) bpy.ops.mesh.primitive_uv_sphere_add(radius=0.7, location=(0,0,0)) #Atrasa também bpy.ops.transform.translate(value=(bpy.context.scene.cursor.location)) bpy.context.object.name = "PT_Linha" ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatModalPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatModalPoints"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.9, 0.2, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatModalPoints") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.9, 0.2, 1) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj return {'PASS_THROUGH'} def execute(self, context): try: PontosDel = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] for i in PontosDel: i.name = 'del' except: print("Não conta nenhum ponto PT_Linha!") # Torna Collection active context.view_layer.active_layer_collection = context.view_layer.layer_collection.children[0] if context.area.type != 'VIEW_3D': print("Must use in a 3d region") return {'CANCELLED'} wm = context.window_manager wm.modal_handler_add(self) return {'RUNNING_MODAL'} def cancel(self, context): wm = context.window_manager def end_ui(self, context): context.area.header_text_set() context.window.cursor_modal_restore() def cleanup(self, context, cleantype=''): ''' remove temporary object ''' if cleantype == 'commit': pass elif cleantype == 'cancel': pass bpy.utils.register_class(ModalTimerOperator) def CriaLinhaPontosDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Pontos = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] vertices = [] for i in Pontos: VetorAtual = i.location VetX = i.location[0] VetY = i.location[1] VetZ = i.location[2] vertices.append((VetX, VetY, VetZ)) edges = [] for i in range(len(vertices)): edges.append([i,i+1]) del(edges[-1]) # Apaga o último elemento da cena faces = [] mesh = bpy.data.meshes.new(name="LineSolid") mesh.from_pydata(vertices, edges, faces) object_data_add(context, mesh, operator=self) bpy.context.object.location = 0,0,0 bpy.ops.object.convert(target='CURVE') bpy.context.object.data.fill_mode = 'FULL' bpy.context.object.data.bevel_depth = 0.915 bpy.context.object.data.bevel_resolution = 7 class CriaLinhaPontos(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_linha_pontos" bl_label = "Create Points Line" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaLinhaPontosDef(self, context) return {'FINISHED'} bpy.utils.register_class(CriaLinhaPontos) #----------------- #Pontos veia def CriaPontoVeiaDef(): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.mesh.primitive_uv_sphere_add(radius=1, location=(0,0,0)) #Atrasa também bpy.ops.transform.translate(value=(bpy.context.scene.cursor.location)) bpy.context.object.name = "PT_Linha" ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatModalPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatModalPointsTeeth"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.2, 0.9, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatModalPointsTeeth") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.2, 0.9, 1) bpy.ops.object.select_all(action='DESELECT') try: obj.select_set(True) bpy.context.view_layer.objects.active = obj except: print("Não há objeto selecionado!") class CriaPontoVeia(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_ponto_veia" bl_label = "Create Vein Point" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaPontoVeiaDef() return {'FINISHED'} bpy.utils.register_class(CriaPontoVeia) # Bezier veia def CriaBezierVeiaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Pontos = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] coords = [] for i in Pontos: VetorAtual = i.location VetX = i.location[0] VetY = i.location[1] VetZ = i.location[2] coords.append((VetX, VetY, VetZ)) # edges = [] # for i in range(len(vertices)): # edges.append([i,i+1]) # del(edges[-1]) # Apaga o último elemento da cena # create the Curve Datablock curveData = bpy.data.curves.new('myCurve', type='CURVE') curveData.dimensions = '3D' curveData.resolution_u = 6 # map coords to spline polyline = curveData.splines.new('BEZIER') polyline.bezier_points.add(len(coords)-1) # for i, coord in enumerate(coords): # x,y,z = coord # polyline.points[i].co = (x, y, z, 1) from bpy_extras.io_utils import unpack_list polyline.bezier_points.foreach_set("co", unpack_list(coords)) # Apaga pontos bpy.ops.object.select_all(action='DESELECT') for i in Pontos: i.select_set(True) bpy.ops.object.delete(use_global=False) # Cria Linha curveOB = bpy.data.objects.new('myCurve', curveData) # attach to scene and validate context scn = bpy.context.scene # scn.objects.link(curveOB) scn.collection.objects.link(curveOB) bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = curveOB curveOB.select_set(True) bpy.ops.object.editmode_toggle() bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.handle_type_set(type='AUTOMATIC') bpy.ops.object.editmode_toggle() bpy.context.object.data.bevel_depth = 1.6 # obj = context.active_object bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.move_to_collection(collection_index=1) # bpy.data.collections['Scene Collection'].objects.unlink(obj) CriaMaterialOsteotomia("VeinNerve", 1, 0, 0) # bpy.context.object.location = 0,0,0 class CriaBezierVeia(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_curva_bezier_veia" bl_label = "Create Bezier Vein" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaBezierVeiaDef(self, context) return {'FINISHED'} bpy.utils.register_class(CriaBezierVeia) #----------------- def CriaBezierDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Pontos = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] coords = [] for i in Pontos: VetorAtual = i.location VetX = i.location[0] VetY = i.location[1] VetZ = i.location[2] coords.append((VetX, VetY, VetZ)) # edges = [] # for i in range(len(vertices)): # edges.append([i,i+1]) # del(edges[-1]) # Apaga o último elemento da cena # create the Curve Datablock curveData = bpy.data.curves.new('myCurve', type='CURVE') curveData.dimensions = '3D' curveData.resolution_u = 6 # map coords to spline polyline = curveData.splines.new('BEZIER') polyline.bezier_points.add(len(coords)-1) # for i, coord in enumerate(coords): # x,y,z = coord # polyline.points[i].co = (x, y, z, 1) from bpy_extras.io_utils import unpack_list polyline.bezier_points.foreach_set("co", unpack_list(coords)) # Apaga pontos bpy.ops.object.select_all(action='DESELECT') for i in Pontos: i.select_set(True) bpy.ops.object.delete(use_global=False) # Cria Linha curveOB = bpy.data.objects.new('myCurve', curveData) # attach to scene and validate context scn = bpy.context.scene # scn.objects.link(curveOB) scn.collection.objects.link(curveOB) bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = curveOB curveOB.select_set(True) bpy.ops.object.editmode_toggle() bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.handle_type_set(type='AUTOMATIC') bpy.ops.object.editmode_toggle() bpy.context.object.data.bevel_depth = 5.5 bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 6 bpy.context.object.modifiers["Remesh"].scale = 0.99 # obj = context.active_object bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.move_to_collection(collection_index=1) # bpy.data.collections['Scene Collection'].objects.unlink(obj) # bpy.context.object.location = 0,0,0 class CriaBezier(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_curva_bezier" bl_label = "Create Points Line 2" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaBezierDef(self, context) return {'FINISHED'} bpy.utils.register_class(CriaBezier) def CriaBezierUnidoDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Pontos = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] coords = [] for i in Pontos: VetorAtual = i.location VetX = i.location[0] VetY = i.location[1] VetZ = i.location[2] coords.append((VetX, VetY, VetZ)) # edges = [] # for i in range(len(vertices)): # edges.append([i,i+1]) # del(edges[-1]) # Apaga o último elemento da cena # create the Curve Datablock curveData = bpy.data.curves.new('myCurve', type='CURVE') curveData.dimensions = '3D' # curveData.resolution_u = 6 curveData.resolution_u = 36 # map coords to spline polyline = curveData.splines.new('BEZIER') polyline.bezier_points.add(len(coords)-1) # for i, coord in enumerate(coords): # x,y,z = coord # polyline.points[i].co = (x, y, z, 1) from bpy_extras.io_utils import unpack_list polyline.bezier_points.foreach_set("co", unpack_list(coords)) # Apaga pontos bpy.ops.object.select_all(action='DESELECT') for i in Pontos: i.select_set(True) bpy.ops.object.delete(use_global=False) # Cria Linha curveOB = bpy.data.objects.new('myCurve', curveData) # attach to scene and validate context scn = bpy.context.scene # scn.objects.link(curveOB) scn.collection.objects.link(curveOB) bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = curveOB curveOB.select_set(True) bpy.ops.object.editmode_toggle() bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.handle_type_set(type='AUTOMATIC') bpy.ops.curve.make_segment() bpy.ops.object.editmode_toggle() bpy.ops.object.modifier_add(type='SHRINKWRAP') bpy.context.object.modifiers["Shrinkwrap"].target = obj bpy.context.object.modifiers["Shrinkwrap"].offset = 0.01 bpy.context.object.modifiers["Shrinkwrap"].wrap_mode = 'ABOVE_SURFACE' bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.context.space_data.overlay.show_curve_normals = False bpy.context.space_data.overlay.show_curve_handles = False bpy.ops.wm.tool_set_by_id(name="builtin.select_box") class CriaBezierUnido(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_curva_bezier_unido" bl_label = "Create Points Line 2" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaBezierUnidoDef(self, context) return {'FINISHED'} bpy.utils.register_class(CriaBezierUnido) def BezierCortaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.object.editmode_toggle() objInicial = obj.name bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['myCurve'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['myCurve'] bpy.context.object.modifiers["Shrinkwrap"].offset = 0 bpy.ops.object.convert(target='MESH') bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') context = bpy.context obj = context.active_object bm = bmesh.from_edit_mesh(obj.data) vertices = bm.verts edges = bm.verts VertIndexOrigi = [] for i in edges: print(i.index) VertIndexOrigi.append(i.index) print("VertIndexOrigi:", VertIndexOrigi) # Extruda para dentro bpy.ops.mesh.extrude_region_move(MESH_OT_extrude_region={"use_normal_flip":False, "mirror":False}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((0, 0, 0), (0, 0, 0), (0, 0, 0)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}) bpy.ops.transform.resize(value=(0.9, 0.9, 0.9), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.mesh.select_all(action='DESELECT') for i in VertIndexOrigi: # print(vertices) # É necessário fazer isso senão não seleciona e dá erro! if hasattr(bm.edges, "ensure_lookup_table"): bm.edges.ensure_lookup_table() bm.edges[i].select_set(True) # Extruda para fora bpy.ops.mesh.extrude_region_move(MESH_OT_extrude_region={"use_normal_flip":False, "mirror":False}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((0, 0, 0), (0, 0, 0), (0, 0, 0)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}) bpy.ops.transform.resize(value=(1.1, 1.1, 1.1), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.mesh.select_all(action='DESELECT') for i in VertIndexOrigi: # print(vertices) # É necessário fazer isso senão não seleciona e dá erro! if hasattr(bm.edges, "ensure_lookup_table"): bm.edges.ensure_lookup_table() bm.edges[i].select_set(True) # Apaga vértices do meio e une as outras bpy.ops.mesh.delete(type='VERT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.bridge_edge_loops() bpy.ops.object.editmode_toggle() bpy.data.objects[objInicial].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[objInicial] bpy.ops.object.join() obj = context.active_object bpy.ops.object.editmode_toggle() bm2 = bmesh.from_edit_mesh(obj.data) vertices2 = bm2.verts edges2 = bm2.edges VertIndexOrigi2 = [] for i in vertices2: if i.select == True: print(i.index) VertIndexOrigi2.append(i.index) bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.intersect() bpy.ops.mesh.intersect(mode='SELECT') bpy.ops.mesh.select_all(action='DESELECT') for i in VertIndexOrigi2: # print(vertices) # É necessário fazer isso senão não seleciona e dá erro! if hasattr(bm2.verts, "ensure_lookup_table"): bm2.verts.ensure_lookup_table() bm2.verts[i].select_set(True) bpy.ops.mesh.delete(type='VERT') bpy.ops.object.editmode_toggle() bpy.ops.mesh.separate(type='LOOSE') bpy.ops.wm.tool_set_by_id(name="builtin.select_box") class BezierCorta(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.bezier_corta" bl_label = "Create Points Line 2" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): BezierCortaDef(self, context) return {'FINISHED'} bpy.utils.register_class(BezierCorta) def BezierCortaDuplaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.object.editmode_toggle() objInicial = obj.name bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['myCurve'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['myCurve'] bpy.ops.object.convert(target='MESH') # Revoncerte em linha bpy.ops.object.convert(target='CURVE') bpy.context.object.data.bevel_depth = 0.5 bpy.ops.object.convert(target='MESH') bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') # Cria vertex group objeto = bpy.data.objects['myCurve'] vg = objeto.vertex_groups.new(name="Apagar") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.editmode_toggle() bpy.ops.object.join() bpy.ops.object.editmode_toggle() context = bpy.context obj = context.active_object bpy.data.objects[objInicial].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[objInicial] bpy.ops.object.join() # Corta bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.intersect(mode='SELECT') bpy.ops.mesh.select_all(action='DESELECT') # -------- groupName = 'Apagar' obj = bpy.context.view_layer.objects.active bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.object.vertex_group_set_active(group=groupName) bpy.ops.object.vertex_group_select() bpy.ops.mesh.delete(type='VERT') bpy.ops.object.editmode_toggle() bpy.ops.mesh.separate(type='LOOSE') bpy.ops.wm.tool_set_by_id(name="builtin.select_box") class BezierCortaDupla(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.bezier_corta_dupla" bl_label = "Create Points Line 2" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): BezierCortaDuplaDef(self, context) return {'FINISHED'} bpy.utils.register_class(BezierCortaDupla) # MODAL SEPARA DENTES class ModalTimerOperatorTeeth(bpy.types.Operator): """Operator which runs its self from a timer""" bl_idname = "wm.modal_cria_pontos_teeth" bl_label = "Create points line on teeth" _timer = None def modal(self, context, event): context = bpy.context obj = context.active_object bpy.ops.wm.tool_set_by_id(name="builtin.cursor") if event.type in {'RIGHTMOUSE', 'ESC'}: self.cancel(context) return {'CANCELLED'} # bpy.ops.object.select_pattern(pattern="Cub*") # Seleciona objetos com esse padrão if event.type == 'LEFTMOUSE' and event.value == 'RELEASE': if context.area.type == 'VIEW_3D': region = context.region r3d = context.space_data.region_3d # bpy.ops.object.empty_add(type='PLAIN_AXES', radius=1, location=(0,0,0)) bpy.ops.mesh.primitive_uv_sphere_add(radius=0.2, location=(0,0,0)) #Atrasa também bpy.ops.transform.translate(value=(bpy.context.scene.cursor.location)) bpy.context.object.name = "PT_Linha" ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatModalPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatModalPointsTeeth"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.2, 0.9, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatModalPointsTeeth") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.2, 0.9, 1) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj return {'PASS_THROUGH'} def execute(self, context): if context.area.type != 'VIEW_3D': print("Must use in a 3d region") return {'CANCELLED'} wm = context.window_manager wm.modal_handler_add(self) return {'RUNNING_MODAL'} def cancel(self, context): wm = context.window_manager def end_ui(self, context): context.area.header_text_set() context.window.cursor_modal_restore() def cleanup(self, context, cleantype=''): ''' remove temporary object ''' if cleantype == 'commit': pass elif cleantype == 'cancel': pass bpy.utils.register_class(ModalTimerOperatorTeeth) def CriaBezierUnidoTeethDef(self, context): context = bpy.context obj = context.active_object scn = context.scene Pontos = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] coords = [] for i in Pontos: VetorAtual = i.location VetX = i.location[0] VetY = i.location[1] VetZ = i.location[2] coords.append((VetX, VetY, VetZ)) # edges = [] # for i in range(len(vertices)): # edges.append([i,i+1]) # del(edges[-1]) # Apaga o último elemento da cena # create the Curve Datablock curveData = bpy.data.curves.new('myCurve', type='CURVE') curveData.dimensions = '3D' # curveData.resolution_u = 6 curveData.resolution_u = 36 # map coords to spline polyline = curveData.splines.new('BEZIER') polyline.bezier_points.add(len(coords)-1) # for i, coord in enumerate(coords): # x,y,z = coord # polyline.points[i].co = (x, y, z, 1) from bpy_extras.io_utils import unpack_list polyline.bezier_points.foreach_set("co", unpack_list(coords)) # Apaga pontos bpy.ops.object.select_all(action='DESELECT') for i in Pontos: i.select_set(True) bpy.ops.object.delete(use_global=False) # Cria Linha curveOB = bpy.data.objects.new('myCurve', curveData) # attach to scene and validate context scn = bpy.context.scene # scn.objects.link(curveOB) scn.collection.objects.link(curveOB) bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = curveOB curveOB.select_set(True) bpy.ops.object.editmode_toggle() bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.handle_type_set(type='AUTOMATIC') bpy.ops.curve.make_segment() bpy.ops.object.editmode_toggle() bpy.ops.object.modifier_add(type='SHRINKWRAP') bpy.context.object.modifiers["Shrinkwrap"].target = obj bpy.context.object.modifiers["Shrinkwrap"].offset = 0.01 # ORIGINAL 0.01 bpy.context.object.modifiers["Shrinkwrap"].wrap_mode = 'ABOVE_SURFACE' bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Shrinkwrap") # bpy.ops.object.modifier_add(type='SMOOTH') # bpy.context.object.modifiers["Smooth"].factor = 2 # bpy.context.object.modifiers["Smooth"].iterations = 3 bpy.context.object.data.bevel_depth = 0.2 ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatModalPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatModalPointsTeeth"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.2, 0.9, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatModalPointsTeeth") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.2, 0.9, 1) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj class CriaBezierUnidoTeeth(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_curva_bezier_unido_teeth" bl_label = "Create Points Line Teeth" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaBezierUnidoTeethDef(self, context) return {'FINISHED'} bpy.utils.register_class(CriaBezierUnidoTeeth) def BezierCortaDuplaTeethDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.object.editmode_toggle() objInicial = obj.name bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['myCurve'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['myCurve'] bpy.ops.object.convert(target='MESH') # Revoncerte em linha # bpy.ops.object.convert(target='CURVE') # bpy.context.object.data.bevel_depth = 0.5 # bpy.ops.object.convert(target='MESH') bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') # Cria vertex group objeto = bpy.data.objects['myCurve'] vg = objeto.vertex_groups.new(name="Apagar") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.editmode_toggle() bpy.ops.object.join() bpy.ops.object.editmode_toggle() context = bpy.context obj = context.active_object bpy.data.objects[objInicial].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[objInicial] bpy.ops.object.join() # Corta bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.intersect(mode='SELECT') bpy.ops.mesh.select_all(action='DESELECT') # -------- groupName = 'Apagar' obj = bpy.context.view_layer.objects.active bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.object.vertex_group_set_active(group=groupName) bpy.ops.object.vertex_group_select() bpy.ops.mesh.delete(type='VERT') bpy.ops.object.editmode_toggle() bpy.ops.mesh.separate(type='LOOSE') bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') # Centralizar origem bpy.ops.wm.tool_set_by_id(name="builtin.select_box") class BezierCortaDuplaTeeth(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.bezier_corta_dupla_teeth" bl_label = "Create Points Line Teeth " bl_options = {'REGISTER', 'UNDO'} def execute(self, context): BezierCortaDuplaTeethDef(self, context) return {'FINISHED'} bpy.utils.register_class(BezierCortaDuplaTeeth) def PreparaMalhaCorteDef(self, context): bpy.ops.object.prepara_impressao_3d() bpy.context.object.modifiers["Remesh"].use_remove_disconnected = False # bpy.context.object.modifiers["Remesh"].octree_depth = 9 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh") bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="EDGE") bpy.ops.mesh.select_all(action = 'DESELECT') class PreparaMalhaCorte(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.prepara_malha_corte" bl_label = "Prepare Mesh to Cut" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): PreparaMalhaCorteDef(self, context) return {'FINISHED'} bpy.utils.register_class(PreparaMalhaCorte) ''' def CortaMalhaKnifeDef(self, context): bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="EDGE") bpy.ops.mesh.select_all(action = 'DESELECT') # bpy.ops.mesh.knife_tool() print("AQUIII 1") bpy.ops.mesh.knife_tool() print("AQUII 2") class CortaMalhaKnife(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.corta_malha_knife" bl_label = "Knife Cut" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CortaMalhaKnifeDef(self, context) return {'FINISHED'} bpy.utils.register_class(CortaMalhaKnife) ''' def SeparaEdgeSplitDef(self, context): bpy.ops.object.mode_set(mode = 'OBJECT') context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.edge_split() bpy.ops.mesh.select_mode(type="EDGE") bpy.ops.mesh.select_all(action = 'SELECT') bpy.ops.mesh.separate(type='LOOSE') bpy.ops.object.mode_set(mode = 'OBJECT') bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') bpy.ops.wm.tool_set_by_id(name="builtin.select_box") bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj class SeparaEdgeSplit(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.separa_edge_split" bl_label = "Edge Split Teeth Separation" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): SeparaEdgeSplitDef(self, context) return {'FINISHED'} bpy.utils.register_class(SeparaEdgeSplit) # Modal cria pontos microscopio class ModalTimerOperatorMicros(bpy.types.Operator): """Operator which runs its self from a timer""" bl_idname = "wm.modal_cria_pontos_micros" bl_label = "Create points line microscope" _timer = None def modal(self, context, event): context = bpy.context obj = context.active_object context.view_layer.active_layer_collection = context.view_layer.layer_collection.children[0] bpy.ops.wm.tool_set_by_id(name="builtin.cursor") if event.type in {'RIGHTMOUSE', 'ESC'}: self.cancel(context) return {'CANCELLED'} # bpy.ops.object.select_pattern(pattern="Cub*") # Seleciona objetos com esse padrão if event.type == 'LEFTMOUSE' and event.value == 'RELEASE': if context.area.type == 'VIEW_3D': region = context.region r3d = context.space_data.region_3d # bpy.ops.object.empty_add(type='PLAIN_AXES', radius=1, location=(0,0,0)) bpy.ops.mesh.primitive_uv_sphere_add(radius=0.05, location=(0,0,0)) #Atrasa também bpy.ops.transform.translate(value=(bpy.context.scene.cursor.location)) bpy.context.object.name = "PT_Linha" ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatModalPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatModalPoints"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.9, 0.2, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatModalPoints") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.2, 0.9, 0.2, 1) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj return {'PASS_THROUGH'} def execute(self, context): try: PontosDel = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "PT_Linh*")] for i in PontosDel: i.name = 'del' except: print("Não conta nenhum ponto PT_Linha!") # Torna Collection active context.view_layer.active_layer_collection = context.view_layer.layer_collection.children[0] if context.area.type != 'VIEW_3D': print("Must use in a 3d region") return {'CANCELLED'} wm = context.window_manager wm.modal_handler_add(self) return {'RUNNING_MODAL'} def cancel(self, context): wm = context.window_manager def end_ui(self, context): context.area.header_text_set() context.window.cursor_modal_restore() def cleanup(self, context, cleantype=''): ''' remove temporary object ''' if cleantype == 'commit': pass elif cleantype == 'cancel': pass bpy.utils.register_class(ModalTimerOperatorMicros) ================================================ FILE: DinamicaMole.py ================================================ import bpy import bmesh from mathutils import Matrix # Deformação do nariz def AreasInfluenciaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') obj.name = "SoftTissueDynamic" #vg = obj.vertex_groups.new(name=slot.material.name) bpy.ops.object.mode_set(mode='EDIT') # bpy.ops.object.editmode_toggle() mesh=bmesh.from_edit_mesh(bpy.context.object.data) for v in mesh.verts: v.select = True # CORPO MANDÍBULA vg = obj.vertex_groups.new(name="cm") scn.tool_settings.vertex_group_weight=0 bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # MAXILA vg = obj.vertex_groups.new(name="ma") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # MENTO vg = obj.vertex_groups.new(name="me") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # CABEÇA vg = obj.vertex_groups.new(name="ca") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # RAMO DIREITO vg = obj.vertex_groups.new(name="rd") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # RAMO ESQUERDO vg = obj.vertex_groups.new(name="re") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() # FRENTE vg = obj.vertex_groups.new(name="frente") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') # Depois de fazer tudo voltar ao modo de Objeto class AreasInfluencia(bpy.types.Operator): """Tooltip""" bl_idname = "object.areas_influencia" bl_label = "Áreas de Influência - Dinâmica de Tecidos Moles" def execute(self, context): AreasInfluenciaDef(self, context) return {'FINISHED'} # CRIA ÁREA DE DEFORMAÇÃO def CriaAreasDeformacaoDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "me" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["me"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist =30 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 12 #3 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'SHARP' bpy.context.object.modifiers["VertexWeightProximity"].name = "Mento" bpy.context.object.modifiers["Mento"].show_expanded = False bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "cm" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["cm"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 20 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 11 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'LINEAR' bpy.context.object.modifiers["VertexWeightProximity"].name = "Corpo Mandibula" bpy.context.object.modifiers["Corpo Mandibula"].show_expanded = False bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "re" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["re"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 35 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 12 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'SHARP' bpy.context.object.modifiers["VertexWeightProximity"].name = "Ramo Esquerdo" bpy.context.object.modifiers["Ramo Esquerdo"].show_expanded = False bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "rd" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["rd"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 35 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 12 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'SHARP' bpy.context.object.modifiers["VertexWeightProximity"].name = "Ramo Direito" bpy.context.object.modifiers["Ramo Direito"].show_expanded = False bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "ma" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["ma"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 37 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 9.5 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'SHARP' bpy.context.object.modifiers["VertexWeightProximity"].name = "Maxila" bpy.context.object.modifiers["Maxila"].show_expanded = False bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "ca" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["ca"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 90 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 0 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'SHARP' bpy.context.object.modifiers["VertexWeightProximity"].name = "Cabeça" bpy.context.object.modifiers["Cabeça"].show_expanded = False bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "frente" bpy.context.object.modifiers["VertexWeightProximity"].target = bpy.data.objects["ma"] bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist = 40 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = 20 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'LINEAR' bpy.context.object.modifiers["VertexWeightProximity"].name = "Frente" bpy.context.object.modifiers["Maxila"].show_expanded = False class CriaAreasDeformacao(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_areas_deformacao" bl_label = "Cria Areas Deformação" def execute(self, context): CriaAreasDeformacaoDef(self, context) return {'FINISHED'} # CONFIGURA DINÂMICA MOLE def ConfiguraDinamicaMoleDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.areas_influencia() bpy.ops.object.cria_areas_deformacao() bpy.ops.object.convert(target='MESH') # a = bpy.data.objects['FaceMalha.001'] armatureHead = bpy.data.objects['Armature_Head'] armatureHead.hide_viewport=False bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = armatureHead obj.select_set(True) bpy.data.objects['Armature_Head'].select_set(True) bpy.ops.object.parent_set(type='ARMATURE_NAME') armatureHead.hide_viewport=True bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) # faceMalha = bpy.data.objects['FaceMalha.001'] bpy.context.view_layer.objects.active = obj bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 3 bpy.context.object.modifiers["Smooth"].vertex_group = "frente" def CursorParaSelecao(): context = bpy.context for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) def SelecaoParaCursor(): context = bpy.context for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_selected_to_cursor(ctx) def SelectionaObjeto(Obj): context = bpy.context Objeto = bpy.data.objects[Obj] bpy.ops.object.select_all(action='DESELECT') Objeto.select_set(True) context.view_layer.objects.active = Objeto def SelecionaOssos(Armature, Bone): context = bpy.context bpy.ops.object.select_all(action='DESELECT') ArmatureAtual = bpy.data.objects[Armature] ArmatureAtual.select_set(True) context.view_layer.objects.active = ArmatureAtual bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.armature.select_all(action='DESELECT') bpy.context.object.data.edit_bones[Bone].select_tail = True bpy.context.object.data.edit_bones[Bone].select_head = True def CorrigeOssosArmature(Objeto, Armature, Osso): SelectionaObjeto(Objeto) CursorParaSelecao() SelecionaOssos(Armature, Osso) SelecaoParaCursor() bpy.ops.object.mode_set(mode = 'OBJECT') def GeraNarizDinamicaMole(): foundTrichion = 'Trichion' in bpy.data.objects foundRadix = 'Radix' in bpy.data.objects foundTipofNose = 'Tip of Nose' in bpy.data.objects foundAlarGrooveright = 'Alar Groove right' in bpy.data.objects foundAlarGrooveleft = 'Alar Groove left' in bpy.data.objects foundSubmental = 'Submental' in bpy.data.objects if foundTrichion == True and foundRadix == True and foundTipofNose == True and foundAlarGrooveright == True and foundAlarGrooveleft == True and foundSubmental == True: print("Pontos do nariz presentes!") def InverseMatrix(): context = bpy.context ob = context.object constraints = [(pb, c) for pb in ob.pose.bones for c in pb.constraints if c.type == 'CHILD_OF'] cmd = 'SET' # or 'SET' for pb, c in constraints: if cmd == 'CLEAR': c.inverse_matrix = Matrix.Identity(4) elif cmd == 'SET': if c.target: M = ob.convert_space(pose_bone=pb, matrix=c.target.matrix_world, from_space='WORLD', to_space='POSE') P = Matrix.Identity(4).lerp(M, c.influence) c.inverse_matrix = P.inverted() # toggle a property target = c.target c.target = None c.target = target #pb.constraints.update() # Captura objetos ListaPontos = ['Radix', 'Tip of Nose', 'Alar Groove left', 'Alar Groove right', 'Trichion', 'Submental'] print("LEITURA FEITA!") for i in ListaPontos: # print("HÁ O NOME!", i.name) bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects[i] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.duplicate() NovoNome = str(bpy.data.objects[i].name)+"_COPY_NOSE_DEFORM" bpy.context.object.name = NovoNome bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.ops.object.select_all(action='DESELECT') EMPNasionSoft = bpy.data.objects["Radix_COPY_NOSE_DEFORM"] EMPPNPoint = bpy.data.objects["Tip of Nose_COPY_NOSE_DEFORM"] EMPAlaL = bpy.data.objects["Alar Groove left_COPY_NOSE_DEFORM"] EMPAlaR = bpy.data.objects["Alar Groove right_COPY_NOSE_DEFORM"] EMPTopHead = bpy.data.objects["Trichion_COPY_NOSE_DEFORM"] EMPBottomHead = bpy.data.objects["Submental_COPY_NOSE_DEFORM"] # Adiciona Empty Sphere bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.empty_add(type='SPHERE', radius=7, view_align=False, location=EMPPNPoint.location) bpy.context.object.name = "EMPNoseUpDown" EMPNoseUpDown = bpy.data.objects["EMPNoseUpDown"] bpy.ops.object.constraint_add(type='TRANSFORM') bpy.context.object.constraints["Transformation"].target = bpy.data.objects["ma"] bpy.context.object.constraints["Transformation"].use_motion_extrapolate = True bpy.context.object.constraints["Transformation"].from_max_y = 10 bpy.context.object.constraints["Transformation"].map_to_x_from = 'Y' bpy.context.object.constraints["Transformation"].map_to_y_from = 'Y' bpy.context.object.constraints["Transformation"].map_to_z_from = 'Y' bpy.context.object.constraints["Transformation"].to_max_z = -5 # O CURSOR TEM QUE ESTAR NA ORIGEM TOTAL #bpy.context.area.spaces[1].pivot_point='CURSOR' # ANTIGO 2.79 bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR' #bpy.context.area.spaces[1].cursor_location = (0.0, 0.0, 0.0) # ANTIGO 2.79 bpy.context.scene.cursor.location = 0,0,0 # Adiciona Armature em modo de edição bpy.ops.object.armature_add(radius=1, view_align=False, enter_editmode=True) # Desseleciona tudo #bpy.ops.armature.select_all(action='TOGGLE') # Modifica posição dos bones #bpy.context.object.data.edit_bones["Bone"].head = Vector((1.0, 2.0, 3.0)) bpy.context.object.data.edit_bones["Bone"].name = "Nose" bpy.context.object.data.edit_bones["Nose"].head = EMPPNPoint.location bpy.context.object.data.edit_bones["Nose"].tail = EMPNasionSoft.location # Adiciona Asa Esquerda bpy.ops.armature.bone_primitive_add() bpy.context.object.data.edit_bones["Bone"].name = "AlaL" bpy.context.object.data.edit_bones["AlaL"].head = EMPPNPoint.location bpy.context.object.data.edit_bones["AlaL"].tail = EMPAlaL.location # Adiciona Asa Direita bpy.ops.armature.bone_primitive_add() bpy.context.object.data.edit_bones["Bone"].name = "AlaR" bpy.context.object.data.edit_bones["AlaR"].head = EMPPNPoint.location bpy.context.object.data.edit_bones["AlaR"].tail = EMPAlaR.location # Adiciona Nariz bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR' bpy.context.scene.cursor.location = EMPPNPoint.location bpy.ops.armature.bone_primitive_add() bpy.context.object.data.edit_bones["Bone"].name = "IK_Nose" bpy.context.object.data.edit_bones["IK_Nose"].use_deform = False # Adicionar Top Bottom bpy.ops.armature.bone_primitive_add() bpy.context.object.data.edit_bones["Bone"].name = "TopBottomHead" bpy.context.object.data.edit_bones["TopBottomHead"].head = EMPTopHead.location bpy.context.object.data.edit_bones["TopBottomHead"].tail = EMPBottomHead.location # Parentamento bpy.context.object.data.edit_bones["Nose"].parent = bpy.context.object.data.edit_bones['IK_Nose'] bpy.context.object.data.edit_bones["AlaL"].parent = bpy.context.object.data.edit_bones['IK_Nose'] bpy.context.object.data.edit_bones["AlaR"].parent = bpy.context.object.data.edit_bones['IK_Nose'] # bpy.context.object.data.draw_type = 'ENVELOPE' # ANTIGO 2.78 bpy.context.object.data.display_type = 'ENVELOPE' # Aumenta tamanho envelope bpy.ops.object.mode_set(mode='EDIT') bpy.context.object.data.edit_bones["Nose"].head_radius=8.5 bpy.context.object.data.edit_bones["AlaL"].head_radius=8.5 bpy.context.object.data.edit_bones["AlaR"].head_radius=8.5 bpy.context.object.data.edit_bones["Nose"].tail_radius=3.5 bpy.context.object.data.edit_bones["AlaL"].tail_radius=3.5 bpy.context.object.data.edit_bones["AlaR"].tail_radius=3.5 #bpy.context.object.data.edit_bones["Nose"].select_head=True #bpy.context.object.data.edit_bones["AlaL"].select_head=True #bpy.context.object.data.edit_bones["AlaR"].select_head=True #bpy.ops.transform.transform(mode='BONE_ENVELOPE', value=(85, 0, 0, 0)) # Fazendo o constraint #obj = bpy.data.objects["Armature.002"] bpy.ops.object.mode_set(mode='OBJECT') context = bpy.context obj = context.active_object bpy.ops.object.mode_set(mode='POSE') pbase=obj.pose.bones['IK_Nose'] pbase.bone.select=True bpy.context.object.data.bones.active = bpy.context.object.data.bones['IK_Nose'] # Child Of selected_bone = pbase constraint = selected_bone.constraints ChildOf = constraint.new('CHILD_OF') ChildOf.target = EMPNoseUpDown InverseMatrix() bpy.context.object.pose.bones["IK_Nose"].constraints["Child Of"].influence = 0.5 # Track to pbase=obj.pose.bones['Nose'] pbase.bone.select=True bpy.context.object.data.bones.active = bpy.context.object.data.bones['Nose'] selected_bone = pbase constraint = selected_bone.constraints StretchTo = constraint.new('STRETCH_TO') StretchTo.target = EMPNasionSoft pbase=obj.pose.bones['AlaL'] pbase.bone.select=True bpy.context.object.data.bones.active = bpy.context.object.data.bones['AlaL'] selected_bone = pbase constraint = selected_bone.constraints StretchTo = constraint.new('STRETCH_TO') StretchTo.target = EMPAlaL pbase=obj.pose.bones['AlaR'] pbase.bone.select=True bpy.context.object.data.bones.active = bpy.context.object.data.bones['AlaR'] selected_bone = pbase constraint = selected_bone.constraints StretchTo = constraint.new('STRETCH_TO') StretchTo.target = EMPAlaR bpy.ops.object.mode_set(mode='OBJECT') Armature = context.active_object bpy.ops.object.select_all(action='DESELECT') Armature.select_set(True) # Envelope configurações bpy.ops.object.mode_set(mode='EDIT') bpy.context.object.data.edit_bones["Nose"].envelope_distance = 14 bpy.context.object.data.edit_bones["Nose"].head_radius = 5 bpy.context.object.data.edit_bones["Nose"].tail_radius = 1 bpy.context.object.data.edit_bones["AlaL"].envelope_distance = 9 bpy.context.object.data.edit_bones["AlaL"].head_radius = 9 bpy.context.object.data.edit_bones["AlaL"].tail_radius = 3.5 bpy.context.object.data.edit_bones["AlaR"].envelope_distance = 9 bpy.context.object.data.edit_bones["AlaR"].head_radius = 9 bpy.context.object.data.edit_bones["AlaR"].tail_radius = 3.5 bpy.context.object.data.edit_bones["TopBottomHead"].envelope_distance = 55 bpy.context.object.data.edit_bones["TopBottomHead"].head_radius = 22 bpy.context.object.data.edit_bones["TopBottomHead"].tail_radius = 22 # Deformação bpy.ops.object.mode_set(mode='OBJECT') #bpy.context.object.data.draw_type = 'WIRE' # ANTIGO 2.78 bpy.context.object.data.display_type = 'WIRE' bpy.ops.object.select_all(action='DESELECT') FaceMalha = bpy.data.objects['SoftTissueDynamic'] Armature.select_set(True) FaceMalha.select_set(True) bpy.context.view_layer.objects.active = Armature bpy.ops.object.parent_set(type='ARMATURE_ENVELOPE') bpy.ops.object.select_all(action='DESELECT') FaceMalha.select_set(True) bpy.context.view_layer.objects.active = FaceMalha bpy.ops.object.modifier_move_up(modifier="Armature.001") # Oculta Objetos EMPNoseUpDown.hide_viewport=True Armature.hide_viewport=True EMPNasionSoft.hide_viewport=True EMPPNPoint.hide_viewport=True EMPAlaL.hide_viewport=True EMPAlaR.hide_viewport=True EMPTopHead.hide_viewport=True EMPBottomHead.hide_viewport=True else: print("Falta algum ponto anatômico no processo.") def CorrigeDeformacaoOperacoesDef(self, context): # Maxila - correção bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX') bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = "ma" bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = "cm" bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'SUB' bpy.ops.object.modifier_apply(apply_as='DATA', modifier="VertexWeightMix") # Corpo da mandíbula - correções bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX') bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = "cm" bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = "ma" bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'SUB' bpy.ops.object.modifier_apply(apply_as='DATA', modifier="VertexWeightMix") bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX') bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = "cm" bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = "me" bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'SUB' bpy.context.object.modifiers["VertexWeightMix"].mask_constant = 0.30 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="VertexWeightMix") # Cabeça - correçoes bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX') bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = "ca" bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = "cm" bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'SUB' bpy.context.object.modifiers["VertexWeightMix"].mask_constant = 0.05 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="VertexWeightMix") bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX') bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = "ca" bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = "ma" bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'SUB' bpy.context.object.modifiers["VertexWeightMix"].mask_constant = 0.2 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="VertexWeightMix") class ConfiguraDinamicaMole(bpy.types.Operator): """Tooltip""" bl_idname = "object.configura_dinamica_mole" bl_label = "Configura Dinâmica do Mole" def execute(self, context): context = bpy.context ObjFace = context.active_object bpy.data.objects['Armature_Head'].hide_viewport=False # bpy.data.objects['Armature_Head'].hide_set(False) CorrigeOssosArmature('re', 'Armature_Head', 're') CorrigeOssosArmature('rd', 'Armature_Head', 'rd') CorrigeOssosArmature('ma', 'Armature_Head', 'ma') CorrigeOssosArmature('ma', 'Armature_Head', 'Maxila.GUIA') CorrigeOssosArmature('cm', 'Armature_Head', 'cm') CorrigeOssosArmature('cm', 'Armature_Head', 'Corpo_Mandibular.GUIA') CorrigeOssosArmature('me', 'Armature_Head', 'me') CorrigeOssosArmature('ca', 'Armature_Head', 'ca') CorrigeOssosArmature('ca', 'Armature_Head', 'Mandibula') # bpy.data.objects['Armature_Head'].hide_set(True) bpy.data.objects['Armature_Head'].hide_viewport=True SelectionaObjeto(str(ObjFace.name)) ConfiguraDinamicaMoleDef(self, context) CorrigeDeformacaoOperacoesDef(self, context) # FAZER MAIS TESTES FUTUROS! GeraNarizDinamicaMole() return {'FINISHED'} ================================================ FILE: FerrFisica.py ================================================ import bpy import fnmatch def ColisaoArcosDef(): context = bpy.context scn = context.scene bpy.context.scene.frame_end = 110 if len(bpy.context.selected_objects) != 2: print("Selecione dois objetos!") # Substituir por mensagem de erro! else: print("Tudo certo") # Inverte gravidade. bpy.context.scene.gravity[2] = -9.81 ObjOriginais = bpy.context.selected_objects for i in bpy.context.selected_objects: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') for i in ObjOriginais: i.select_set(True) if bpy.context.selected_objects[0].location[2] == bpy.context.selected_objects[1].location[2]: print("Os objetos estão na mesma altura!") if bpy.context.selected_objects[0].location[2] > bpy.context.selected_objects[1].location[2]: # if bpy.context.selected_objects[0].location[2] > bpy.context.selected_objects[1].location[2]: ArcadaSup = bpy.context.selected_objects[0] ArcadaInf = bpy.context.selected_objects[1] print("Obj[0] mais alnto") if bpy.context.selected_objects[0].location[2] < bpy.context.selected_objects[1].location[2]: # if bpy.context.selected_objects[0].location[2] < bpy.context.selected_objects[1].location[2]: ArcadaSup = bpy.context.selected_objects[1] ArcadaInf = bpy.context.selected_objects[0] print("Obj[1] mais alto") # Seleciona arcada inferior e cria vertex group bpy.ops.object.select_all(action='DESELECT') ArcadaInf.select_set(True) bpy.context.view_layer.objects.active = ArcadaInf try: bpy.ops.object.modifier_remove(modifier="ArchSupTouch") bpy.ops.object.vertex_group_remove(all=False, all_unlocked=False) bpy.ops.rigidbody.object_remove() ArcadaSup.animation_data_clear() print("APAGADOS o grupo e o modificador.") except: print("Não foi criado grupo.") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') vg = ArcadaInf.vertex_groups.new(name="ArchInf") scn.tool_settings.vertex_group_weight=1 bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.rigidbody.object_add() bpy.context.object.rigid_body.enabled = False bpy.context.object.rigid_body.collision_shape = 'MESH' bpy.context.object.rigid_body.collision_margin = 0 #Arco Superior bpy.ops.object.select_all(action='DESELECT') ArcadaSup.select_set(True) bpy.context.view_layer.objects.active = ArcadaSup try: bpy.ops.object.modifier_remove(modifier="ArchSupTouch") bpy.ops.object.vertex_group_remove(all=False, all_unlocked=False) bpy.ops.rigidbody.object_remove() ArcadaSup.animation_data_clear() print("APAGADOS o grupo e o modificador.") except: print("Não foi criado grupo e modificador.") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') vg = ArcadaSup.vertex_groups.new(name="ArchSup") scn.tool_settings.vertex_group_weight=0 bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') # Vertex proximity bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "ArchSup" bpy.context.object.modifiers["VertexWeightProximity"].target = ArcadaInf bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist =0 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = .5 #3 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'LINEAR' bpy.context.object.modifiers["VertexWeightProximity"].name = "ArchSupTouch" bpy.context.object.modifiers["ArchSupTouch"].show_expanded = False bpy.ops.rigidbody.object_add() bpy.context.object.rigid_body.collision_shape = 'MESH' bpy.context.object.rigid_body.collision_margin = 0 # override = {'scene': bpy.context.scene, # 'point_cache': bpy.context.scene.rigidbody_world.point_cache} # bpy.ops.ptcache.bake(override, bake=True) # bpy.context.scene.update() # bpy.ops.rigidbody.bake_to_keyframes(frame_start=1, frame_end=110) # bpy.ops.object.mode_set(mode='WEIGHT_PAINT') bpy.ops.screen.animation_play() class ColisaoArcos(bpy.types.Operator): """Tooltip""" bl_idname = "object.colisao_arcos" bl_label = "Archs Collision" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): if len(bpy.context.selected_objects) == 2: return True else: if len(bpy.context.selected_objects) != 2: return False def execute(self, context): ColisaoArcosDef() return {'FINISHED'} bpy.utils.register_class(ColisaoArcos) # GARAVIDADE INVERSA def ColisaoArcosInversoDef(): context = bpy.context scn = context.scene bpy.context.scene.frame_end = 110 if len(bpy.context.selected_objects) != 2: print("Selecione dois objetos!") # Substituir por mensagem de erro! else: print("Tudo certo") # Inverte gravidade. bpy.context.scene.gravity[2] = 9.81 ObjOriginais = bpy.context.selected_objects for i in ObjOriginais: bpy.ops.object.select_all(action='DESELECT') i.select_set(True) bpy.context.view_layer.objects.active = i bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') for i in ObjOriginais: i.select_set(True) if ObjOriginais[0].location[2] == ObjOriginais[1].location[2]: print("Os objetos estão na mesma altura!") if ObjOriginais[0].location[2] > ObjOriginais[1].location[2]: # if bpy.context.selected_objects[0].location[2] > bpy.context.selected_objects[1].location[2]: ArcadaSup = ObjOriginais[0] ArcadaInf = ObjOriginais[1] print("Obj[1] mais baixo") print("LocSUP",ArcadaSup.name,ArcadaSup.location[2]) print("LocINF",ArcadaInf.name,ArcadaInf.location[2]) if ObjOriginais[0].location[2] < ObjOriginais[1].location[2]: # if bpy.context.selected_objects[0].location[2] < bpy.context.selected_objects[1].location[2]: ArcadaSup = ObjOriginais[1] ArcadaInf = ObjOriginais[0] print("Obj[0] mais baixo") print("LocSUP",ArcadaSup.name,ArcadaSup.location[2]) print("LocINF",ArcadaInf.name,ArcadaInf.location[2]) print(ArcadaInf.name) #Arco Superior bpy.ops.object.select_all(action='DESELECT') ArcadaSup.select_set(True) bpy.context.view_layer.objects.active = ArcadaSup try: bpy.ops.object.modifier_remove(modifier="ArchInfTouch") bpy.ops.object.vertex_group_remove(all=False, all_unlocked=False) bpy.ops.rigidbody.object_remove() ArcadaSup.animation_data_clear() print("APAGADOS o grupo e o modificador.") except: print("Não foi criado grupo e modificador.") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') vg = ArcadaSup.vertex_groups.new(name="ArchSup") scn.tool_settings.vertex_group_weight=1 bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.rigidbody.object_add() bpy.context.object.rigid_body.enabled = False bpy.context.object.rigid_body.collision_shape = 'MESH' bpy.context.object.rigid_body.collision_margin = 0 # Arcada inferior bpy.ops.object.select_all(action='DESELECT') ArcadaInf.select_set(True) bpy.context.view_layer.objects.active = ArcadaInf try: bpy.ops.object.modifier_remove(modifier="ArchInfTouch") bpy.ops.object.vertex_group_remove(all=False, all_unlocked=False) bpy.ops.rigidbody.object_remove() ArcadaInf.animation_data_clear() print("APAGADOS o grupo e o modificador.") except: print("Não foi criado grupo.") bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') vg = ArcadaInf.vertex_groups.new(name="ArchInf") scn.tool_settings.vertex_group_weight=0 bpy.ops.object.vertex_group_assign() bpy.ops.object.mode_set(mode='OBJECT') # Vertex proximity bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_PROXIMITY') bpy.context.object.modifiers["VertexWeightProximity"].vertex_group = "ArchInf" bpy.context.object.modifiers["VertexWeightProximity"].target = ArcadaSup bpy.context.object.modifiers["VertexWeightProximity"].proximity_mode = 'GEOMETRY' bpy.context.object.modifiers["VertexWeightProximity"].min_dist =0 bpy.context.object.modifiers["VertexWeightProximity"].max_dist = .5 #3 bpy.context.object.modifiers["VertexWeightProximity"].falloff_type = 'LINEAR' bpy.context.object.modifiers["VertexWeightProximity"].name = "ArchInfTouch" bpy.context.object.modifiers["ArchInfTouch"].show_expanded = False bpy.ops.rigidbody.object_add() bpy.context.object.rigid_body.collision_shape = 'MESH' bpy.context.object.rigid_body.collision_margin = 0 bpy.ops.screen.animation_play() class ColisaoArcosInverso(bpy.types.Operator): """Tooltip""" bl_idname = "object.colisao_arcos_inverso" bl_label = "Inverted Archs Collision" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): if len(bpy.context.selected_objects) == 2: return True else: if len(bpy.context.selected_objects) != 2: return False def execute(self, context): ColisaoArcosInversoDef() return {'FINISHED'} bpy.utils.register_class(ColisaoArcosInverso) def AplicaAnimCorDef(): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.screen.animation_cancel() override = {'scene': bpy.context.scene, 'point_cache': bpy.context.scene.rigidbody_world.point_cache} bpy.ops.ptcache.bake(override, bake=True) bpy.context.scene.update() bpy.ops.rigidbody.bake_to_keyframes(frame_start=1, frame_end=110) bpy.context.scene.frame_current = 110 bpy.ops.object.mode_set(mode='WEIGHT_PAINT') bpy.ops.screen.animation_play() class AplicaAnimCor(bpy.types.Operator): """Tooltip""" bl_idname = "object.aplica_anima_cor" bl_label = "Apply Color and Animation" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): if len(bpy.context.selected_objects) == 1: return True else: if len(bpy.context.selected_objects) != 1: return False def execute(self, context): AplicaAnimCorDef() return {'FINISHED'} bpy.utils.register_class(AplicaAnimCor) def TravaArcoDef(): context = bpy.context obj = context.active_object scn = context.scene # bpy.ops.screen.animation_cancel() bpy.ops.object.mode_set(mode='OBJECT') # bpy.context.scene.frame_current = 110 obj.animation_data_clear() ''' try: bpy.ops.object.vertex_group_remove(all=False, all_unlocked=False) bpy.ops.rigidbody.object_remove() ArcadaSup.animation_data_clear() print("APAGADOS o grupo e o modificador.") except: print("Não foi criado grupo e modificador.") ''' class TravaArco(bpy.types.Operator): """Tooltip""" bl_idname = "object.trava_arco" bl_label = "Arch Stop" bl_options = {'REGISTER', 'UNDO'} # Programação diferente para funcionar!!! @classmethod def poll(cls, context): scene = context.scene tool_settings = context.tool_settings screen = context.screen if not screen.is_animation_playing: return True if screen.is_animation_playing: return False def execute(self, context): bpy.ops.screen.animation_cancel() TravaArcoDef() return {'FINISHED'} bpy.utils.register_class(TravaArco) def PreparaMaxilaMandibulaDef(): context = bpy.context #obj = context.active_object scn = context.scene Maxila = bpy.data.objects['ma'] Mandibula = bpy.data.objects['cm'] bpy.ops.object.select_all(action='DESELECT') Maxila.select_set(True) Mandibula.select_set(True) bpy.context.view_layer.objects.active = Maxila bpy.ops.object.duplicate() Maxila.hide_viewport=True Mandibula.hide_viewport=True # Apagar_Ziga = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "*Ziga")] #for Ziga in Apagar_Ziga: for objeto in context.selected_objects: if fnmatch.fnmatchcase(objeto.name, "ma*"): objeto.name = "MaxillaCopyZiga" MaxilaCopia = objeto objeto.animation_data_clear() print("Maxila OK", objeto) if fnmatch.fnmatchcase(objeto.name, "cm*"): objeto.name = "MandibleCopyZiga" MandibulaCopia = objeto objeto.animation_data_clear() print("Mandibula OK", objeto) #Apagar_Bracket_ref = [obj for obj in bpy.context.scene.objects if fnmatch.fnmatchcase(obj.name, "Bracket_re*")] class PreparaMaxilaMandibula(bpy.types.Operator): """Tooltip""" bl_idname = "object.prepara_maxila_mandibula" bl_label = "Prepares Maxilla & Mandible" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): if bpy.data.objects['MaxillaCopyZiga'] and bpy.data.objects['MandibleCopyZiga']: return False else: return True def execute(self, context): PreparaMaxilaMandibulaDef() return {'FINISHED'} bpy.utils.register_class(PreparaMaxilaMandibula) def FinalizaColisaoMaxMandDef(): context = bpy.context scn = context.scene bpy.context.scene.frame_end = 100 bpy.context.scene.frame_current = 100 # bpy.ops.screen.animation_cancel(restore_frame=True) # bpy.ops.screen.animation_cancel() bpy.ops.object.trava_arco() bpy.data.objects['ma'].hide_viewport=False bpy.data.objects['cm'].hide_viewport=False bpy.data.objects['cm'].location = bpy.data.objects['MandibleCopyZiga'].location bpy.data.objects['cm'].rotation_euler = bpy.data.objects['MandibleCopyZiga'].rotation_euler bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['cm'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['cm'] bpy.ops.anim.ortog_loc_rot() # bpy.context.scene.frame_end = 100 # FrameEnd = bpy.data.scenes["Scene"].frame_end # bpy.context.scene.frame_set(FrameEnd) # bpy.context.scene.frame_current = 100 bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['MaxillaCopyZiga'].select_set(True) bpy.data.objects['MandibleCopyZiga'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['MandibleCopyZiga'] bpy.ops.object.delete(use_global=False) bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['cm'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['cm'] class FinalizaColisaoMaxMand(bpy.types.Operator): """Tooltip""" bl_idname = "object.finaliza_colisao_max_mand" bl_label = "Apply Maxilla & Mandible Collision" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): FinalizaColisaoMaxMandDef() return {'FINISHED'} bpy.utils.register_class(FinalizaColisaoMaxMand) ================================================ FILE: FerrImgTomo.py ================================================ import bpy import os import pydicom as dicom import subprocess import tempfile import platform from os.path import expanduser import platform #if platform.system() == "Linux": import SimpleITK as sitk # EXTRAI DADOS DA TOMOGRAFIA def ExtraiDadosTomo(): context = bpy.context # obj = context.active_object scn = context.scene #Corrige tomo bpy.ops.object.corrige_dicom() tmpdirTomo2 = tempfile.mkdtemp() os.chdir(scn.my_tool.path) if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('for i in *; do gdcmconv -w -i $i -o '+tmpdirTomo2+'/$i; done', shell=True) print("Tomografia corrigida!!!") if platform.system() == "Windows": subprocess.call('for %f in (*) do C:\OrtogOnBlender\GDCM\\bin\gdcmconv -w -i %f -o '+tmpdirTomo2+'/%f', shell=True) print("Tomografia corrigida!!!") scn.my_tool.path = tmpdirTomo2+"/" #Extrai dados global EspacoSlices, DimensaoLateralX, DimensaoLateralY, RowsPixels, ColumnsPixels, TmpDirPNG, DiretorioDCM DiretorioDCM = scn.my_tool.path #tmpdirTomo2+"/" #scn.my_tool.path #"/home/linux3dcs/prj/Estudos/Tomografia/TOMOGRAFIA_2_MENOR/ScalarVolume_10/" ListaArquivos = sorted(os.listdir(DiretorioDCM)) TmpDirPNG = tempfile.mkdtemp() if platform.system() == "Linux" or platform.system() == "Darwin": ds = dicom.dcmread(DiretorioDCM+ListaArquivos[0], force = True) # Diretório e arquivo concatenados if platform.system() == "Windows": ds = dicom.dcmread(DiretorioDCM+"\\"+ListaArquivos[0], force = True) # Diretório e arquivo concatenados if platform.system() == "Linux" or platform.system() == "Darwin": ds = dicom.dcmread(DiretorioDCM+ListaArquivos[0], force = True) # Diretório e arquivo concatenados if platform.system() == "Windows": ds = dicom.dcmread(DiretorioDCM+"\\"+ListaArquivos[0], force = True) # Distância da altura dos slices #Tenta pegar por try: if platform.system() == "Linux" or platform.system() == "Darwin": ds2 = dicom.dcmread(DiretorioDCM+ListaArquivos[1], force = True) if platform.system() == "Windows": ds2 = dicom.dcmread(DiretorioDCM+"\\"+ListaArquivos[1], force = True) EspacoSlices = abs(ds.SliceLocation - ds2.SliceLocation) print("Deu certo por SliceLocation!") except: slice_thickness = ds.data_element("SliceThickness") sliceLimpa1 = str(slice_thickness).split('DS: ') sliceLimpa2 = sliceLimpa1[1].strip('"') # sliceLimpa1 = str(slice_thickness).strip('(0018, 0050) Slice Thickness DS:') # sliceLimpa2 = sliceLimpa1.strip('"') EspacoSlices = float(sliceLimpa2) print("Espaço entre os slices:", EspacoSlices) bpy.types.Scene.SliceThickness = bpy.props.StringProperty \ ( name = "SliceThickness", description = "Slice Thickness", default = str(EspacoSlices) ) # Dimensões laterais pixel_spacing = ds.data_element("PixelSpacing") pixelLimpa1 = str(pixel_spacing).split('DS: ') # pixelLimpa1 = str(pixel_spacing).strip('(0028, 0030) Pixel Spacing DS:') pixelLimpa2 = pixelLimpa1[1].strip('[') pixelLimpa3 = pixelLimpa2.strip(']') DimensoesLaterais = pixelLimpa3.split(",") DimensaoLateralX = float(DimensoesLaterais[0].strip("'")) bpy.types.Scene.PixelSpacingX = bpy.props.StringProperty \ ( name = "PixelSpacingX", description = "Pixel SpacingX", default = str(DimensaoLateralX) ) DimensaoLateralY = float(DimensoesLaterais[1].strip("'").strip(" '")) bpy.types.Scene.PixelSpacingY = bpy.props.StringProperty \ ( name = "PixelSpacingY", description = "Pixel SpacingY", default = str(DimensaoLateralY) ) # Pixels rows = ds.data_element("Rows") rowsLimpa1 = str(rows).split('US: ') RowsPixels = float(rowsLimpa1[1]) bpy.types.Scene.IMGDimX = bpy.props.StringProperty \ ( name = "IMGDimX", description = "IMGDimX", default = str(RowsPixels) ) columns = ds.data_element("Columns") columnsLimpa1 = str(rows).split('US: ') ColumnsPixels = float(rowsLimpa1[1]) bpy.types.Scene.IMGDimY = bpy.props.StringProperty \ ( name = "IMGDimY", description = "IMGDimY", default = str(ColumnsPixels) ) # Conversão de DICOM para PNG def ConverteDCMparaPNG(): #if platform.system() == "Linux": os.chdir(DiretorioDCM) ListaArquivos = os.listdir(DiretorioDCM) for ArquivoAtual in ListaArquivos: img = sitk.ReadImage(ArquivoAtual) # rescale intensity range from [-1000,1000] to [0,255] img = sitk.IntensityWindowing(img, -1000, 1000, 0, 255) # convert 16-bit pixels to 8-bit img = sitk.Cast(img, sitk.sitkUInt8) sitk.WriteImage(img, TmpDirPNG+"/"+ArquivoAtual+".png") print("DICOMs convertidos em PNG") # Oficial # subprocess.call('cd '+DiretorioDCM+' && for i in *; do convert -verbose -auto-level $i "${i%.dcm}".png; done && mv *.png '+TmpDirPNG, shell=True) # print("DICOMs convertidos em PNG") # Alternativa DCMTK # subprocess.call('cd '+DiretorioDCM+' && for x in *.dcm; do dcmj2pnm --write-png $x "${x%.dcm}".png; done && mv *.png '+TmpDirPNG, shell=True) # print("DICOMs convertidos em PNG") # Alternativa # subprocess.call('cd '+DiretorioDCM+' && for i in *; do mogrify -verbose -format png $i; done && mv *.png '+TmpDirPNG, shell=True) # print("DICOMs convertidos em PNG") ''' if platform.system() == "Darwin": subprocess.call('cd '+DiretorioDCM+' && for i in *; do magick $i -auto-level -verbose "${i%.dcm}".png; done && mv *.png '+TmpDirPNG, shell=True) print("DICOMs convertidos em PNG") if platform.system() == "Windows": subprocess.call('cd '+DiretorioDCM+' & for %f in (*) do C:\OrtogOnBlender\ImageMagick\magick %f -auto-level -verbose %f.png & move *.png '+TmpDirPNG, shell=True) print("DICOMs convertidos em PNG") # subprocess.call('cd '+DiretorioDCM+' & for %f in (*) do C:\OrtogOnBlender\ImageMagick\mogrify -verbose -format png %f & move *.png '+TmpDirPNG, shell=True) # print("DICOMs convertidos em PNG") ''' # Material class Material: def set_cycles(self): scn = bpy.context.scene if not scn.render.engine == 'CYCLES': scn.render.engine = 'CYCLES' def make_material(self, name): self.mat = bpy.data.materials.new(name) self.mat.use_nodes = True self.nodes = self.mat.node_tree.nodes def link(self, from_node, from_slot_name, to_node, to_slot_name): input = to_node.inputs[to_slot_name] output = from_node.outputs[from_slot_name] self.mat.node_tree.links.new(input, output) def makeNode(self, type, name): self.node = self.nodes.new(type) self.node.name = name self.xpos += 200 self.node.location = self.xpos, self.ypos return self.node def dump_node(self, node): print (node.name) print ("Inputs:") for n in node.inputs: print (" ", n) print ("Outputs:") for n in node.outputs: print (" ", n) def new_row(): self.xpos = 0 self.ypos += 200 def __init__(self): self.xpos = 0 self.ypos = 0 # Importação dos slices def ImportaFatiasDef(): context = bpy.context # obj = context.active_object scn = context.scene ExtraiDadosTomo() ConverteDCMparaPNG() #Diretorio = "/home/linux3dcs/prj/Estudos/Tomografia/TOMOGRAFIA_2_MENOR/imagens/" ListaArquivos = sorted(os.listdir(TmpDirPNG)) # ListaArquivos = sorted(os.listdir(TmpDirPNG)) DistanciaZ = 0 EscalaX = DimensaoLateralX * RowsPixels EscalaY = DimensaoLateralY * ColumnsPixels #Renderização #bpy.context.scene.eevee.use_gtao = True bpy.context.scene.eevee.gtao_distance = 8 bpy.context.scene.eevee.use_gtao_bent_normals = False # bpy.context.scene.eevee.use_bloom = True # NÃO FICA BOM! bpy.context.scene.eevee.use_sss = False #Senão não fica bom! bpy.context.scene.eevee.use_ssr = True bpy.context.scene.eevee.use_ssr_refraction = True bpy.context.scene.eevee.ssr_thickness = 3 bpy.context.scene.render.hair_type = 'STRIP' bpy.context.scene.eevee.shadow_method = 'ESM' bpy.context.scene.eevee.shadow_cube_size = '512' bpy.context.scene.eevee.shadow_cascade_size = '512' bpy.context.scene.eevee.use_soft_shadows = True bpy.context.scene.eevee.light_threshold = 0.013 bpy.context.scene.view_settings.exposure = 0.2 bpy.context.scene.render.engine = 'BLENDER_EEVEE' bpy.context.space_data.shading.type = 'MATERIAL' # Descobri sozinho! bpy.context.space_data.shading.use_scene_world = True # Tem que ser aqui - muda fundo # Background BackNodeTree = bpy.data.materials.data.worlds['World'].node_tree BackNodeTree.nodes['Background'].inputs['Color'].default_value = (1,1,1,1) # Importa node group if platform.system() == "Linux": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" # section = "\\Collection\\" # object = "SPLINT" section = "\\NodeTree\\" object = "GroupVoxelShader" if platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\NodeTree\\" object = "GroupVoxelShader" if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\NodeTree\\" object = "GroupVoxelShader" filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) # Importa fatias for Arquivo in ListaArquivos: bpy.ops.import_image.to_plane(files=[{"name":Arquivo, "name":Arquivo}], directory=TmpDirPNG) bpy.ops.transform.translate(value=(0, 0, DistanciaZ), constraint_axis=(False, False, True), mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True) bpy.ops.transform.resize(value=(EscalaX, EscalaY, 0), constraint_axis=(False, False, False), mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) #bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) print(Arquivo) DistanciaZ += EspacoSlices # ATRIBUI MATERIAL m = Material() m.set_cycles() # from chapter 1 of [DRM protected book, could not copy author/title] m.make_material("mat_"+Arquivo) image_path = TmpDirPNG+"/"+Arquivo ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images.load(image_path) bpy.data.materials["mat_"+Arquivo].node_tree.nodes['Image Texture'].color_space = "NONE" # Sozinho! Coloca como Non-Color Data materialOutput = m.nodes['Material Output'] m.link(ImageTexture, 'Color', materialOutput, 'Surface') # Faze ro link com o GROUP node_tree = bpy.data.materials["mat_"+Arquivo].node_tree # And a node group that you have in the file: node_group_name = "GroupVoxelShader" nodes = node_tree.nodes links = node_tree.links # Let's at least check if some image node and output node exists # you might need a way to determine which ones to use if there are multiple image_node = output_node = None node_group_exists = False for node in nodes: if node.type == 'TEX_IMAGE': image_node = node elif node.type == 'OUTPUT_MATERIAL': output_node = node elif node.type == 'GROUP': # in case the script was used already if node.node_tree.name == node_group_name: node_group_exists = True print('exists') group_node = node if output_node and image_node: if node_group_name in bpy.data.node_groups and not node_group_exists: group_node=nodes.new("ShaderNodeGroup") # Creating the group is not enough, we need to specify data(node tree) for it group_node.node_tree = bpy.data.node_groups[node_group_name] group_node.location = (0,0) #This is default anyway, but in case you wish to move it links.new(image_node.outputs[0], group_node.inputs[0]) links.new(group_node.outputs[0], output_node.inputs[0]) # Código original ''' ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images.load(image_path) diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs["Base Color"].default_value = [0.3, 0.2, 0.4, 0.5] materialOutput = m.nodes['Material Output'] transparentBSDF = m.makeNode('ShaderNodeBsdfTransparent', 'Transparent BSDF') invertColor = m.makeNode('ShaderNodeInvert', 'Invert') mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.dump_node(mixShader) mixShader.inputs['Fac'].default_value = 0.3 m.link(transparentBSDF, 'BSDF', mixShader, 1) m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(mixShader, 'Shader', materialOutput, 'Surface') m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') m.link(ImageTexture, 'Color', transparentBSDF, 'Color') m.link(ImageTexture, 'Color', mixShader, 'Fac') m.link(ImageTexture, 'Color', invertColor, 'Color') m.link(invertColor, 'Color', transparentBSDF, 'Color') ''' bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["mat_"+Arquivo] #bpy.context.object.active_material.blend_method = 'BLEND' # Descobri sozinho! #bpy.context.object.active_material.blend_method = 'CLIP' bpy.context.object.active_material.blend_method = 'HASHED' # Para a textura if platform.system() == "Windows" or platform.system() == "Darwin": bpy.context.object.active_material.transparent_shadow_method = 'HASHED' if platform.system() == "Linux": bpy.context.object.active_material.shadow_method = 'HASHED' bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "CT_Scan Voxel" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("CT_Scan Voxel") bpy.context.scene.collection.children.link(myCol) obj.instance_collection = myCol bpy.ops.object.collection_link(collection='CT_Scan Voxel') bpy.data.collections['Collection'].objects.unlink(obj) else: obj = context.active_object bpy.ops.object.collection_link(collection='CT_Scan Voxel') bpy.data.collections['Collection'].objects.unlink(obj) # Agrupa e ajusta posição bpy.ops.object.select_all(action='DESELECT') for Arquivo in ListaArquivos: bpy.data.objects[str(Arquivo).strip('.png')].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[str(Arquivo).strip('.png')] bpy.ops.object.join() bpy.ops.transform.mirror(orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) # Corrige rotacao bpy.ops.transform.rotate(value=3.14159, orient_axis='Z', orient_type='VIEW', orient_matrix=((-1, 0, 0), (0, -1, 0), (-0, 0, -1)), orient_matrix_type='VIEW', mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') bpy.ops.object.modifier_add(type='ARRAY') bpy.context.object.modifiers["Array"].use_constant_offset = True bpy.context.object.modifiers["Array"].use_relative_offset = False bpy.context.object.modifiers["Array"].constant_offset_displace[2] = 0.1 bpy.context.object.modifiers["Array"].count = 4 bpy.context.object.modifiers["Array"].show_viewport = False # Cria booleana bpy.context.object.name = "VOXEL" bpy.context.object.name = "VOXEL" VoxelDimensoes = bpy.data.objects['VOXEL'].dimensions VoxelLoc = bpy.data.objects['VOXEL'].location bpy.ops.mesh.primitive_cube_add(size=2, view_align=False, enter_editmode=False, location=(-24.6565, -42.9511, 16.0004)) bpy.context.object.name = "VOXEL_Boolean" bpy.context.object.name = "VOXEL_Boolean" bpy.data.objects['VOXEL_Boolean'].dimensions = VoxelDimensoes * 1.01 bpy.data.objects['VOXEL_Boolean'].location = VoxelLoc bpy.context.object.display_type = 'WIRE' bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['VOXEL'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['VOXEL'] bpy.ops.object.modifier_add(type='BOOLEAN') bpy.context.object.modifiers["Boolean"].operation = 'INTERSECT' bpy.context.object.modifiers["Boolean"].object = bpy.data.objects["VOXEL_Boolean"] # Renderizador bpy.context.scene.eevee.use_sss = False bpy.context.scene.eevee.gtao_distance = 30 bpy.context.scene.eevee.gtao_factor = 2 #bpy.context.scene.eevee.use_gtao_bounce = True # bpy.data.node_groups["Shader Nodetree"].nodes["Background"].inputs[0].default_value = (0.983241, 0.914842, 1, 1) #bpy.data.screens["Default"].shading.use_scene_world = True # Centraliza for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) # bpy.context.space_data.shading.type = 'MATERIAL' # Descobri sozinho! # bpy.ops.file.autopack_toggle() bpy.context.scene.frame_end = int(len(ListaArquivos))+1 bpy.types.Scene.IMGPathSeq = bpy.props.StringProperty \ ( name = "IMGPathSeq", description = "IMGPathSeq", default = str(TmpDirPNG) ) bpy.ops.file.pack_all() class ImportaFatias(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_fatias_dcm" bl_label = "Importa fatias de tomografia DICOM" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): #bpy.ops.object.corrige_dicom() ImportaFatiasDef() return {'FINISHED'} bpy.utils.register_class(ImportaFatias) def ImportaFatiasSimplesDef(): context = bpy.context # obj = context.active_object scn = context.scene ExtraiDadosTomo() ConverteDCMparaPNG() #Diretorio = "/home/linux3dcs/prj/Estudos/Tomografia/TOMOGRAFIA_2_MENOR/imagens/" ListaArquivos = sorted(os.listdir(TmpDirPNG)) # ListaArquivos = sorted(os.listdir(TmpDirPNG)) DistanciaZ = 0 EscalaX = DimensaoLateralX * RowsPixels EscalaY = DimensaoLateralY * ColumnsPixels # Importa node group if platform.system() == "Linux": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" # section = "\\Collection\\" # object = "SPLINT" section = "\\NodeTree\\" object = "GroupVoxelShader" if platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\NodeTree\\" object = "GroupVoxelShader" if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\NodeTree\\" object = "GroupVoxelShader" filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) # Importa fatias for Arquivo in ListaArquivos: bpy.ops.import_image.to_plane(files=[{"name":Arquivo, "name":Arquivo}], directory=TmpDirPNG) bpy.ops.transform.translate(value=(0, 0, DistanciaZ), constraint_axis=(False, False, True), mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True) bpy.ops.transform.resize(value=(EscalaX, EscalaY, 0), constraint_axis=(False, False, False), mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) #bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) print(Arquivo) DistanciaZ += EspacoSlices # ATRIBUI MATERIAL m = Material() m.set_cycles() # from chapter 1 of [DRM protected book, could not copy author/title] m.make_material("mat_"+Arquivo) image_path = TmpDirPNG+"/"+Arquivo ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images.load(image_path) bpy.data.materials["mat_"+Arquivo].node_tree.nodes['Image Texture'].color_space = "NONE" # Sozinho! Coloca como Non-Color Data materialOutput = m.nodes['Material Output'] m.link(ImageTexture, 'Color', materialOutput, 'Surface') # Faze ro link com o GROUP node_tree = bpy.data.materials["mat_"+Arquivo].node_tree # And a node group that you have in the file: node_group_name = "GroupVoxelShader" nodes = node_tree.nodes links = node_tree.links # Let's at least check if some image node and output node exists # you might need a way to determine which ones to use if there are multiple image_node = output_node = None node_group_exists = False for node in nodes: if node.type == 'TEX_IMAGE': image_node = node elif node.type == 'OUTPUT_MATERIAL': output_node = node elif node.type == 'GROUP': # in case the script was used already if node.node_tree.name == node_group_name: node_group_exists = True print('exists') group_node = node if output_node and image_node: if node_group_name in bpy.data.node_groups and not node_group_exists: group_node=nodes.new("ShaderNodeGroup") # Creating the group is not enough, we need to specify data(node tree) for it group_node.node_tree = bpy.data.node_groups[node_group_name] group_node.location = (0,0) #This is default anyway, but in case you wish to move it links.new(image_node.outputs[0], group_node.inputs[0]) links.new(group_node.outputs[0], output_node.inputs[0]) bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["mat_"+Arquivo] #bpy.context.object.active_material.blend_method = 'BLEND' # Descobri sozinho! #bpy.context.object.active_material.blend_method = 'CLIP' bpy.context.object.active_material.blend_method = 'HASHED' # Para a textura if platform.system() == "Windows" or platform.system() == "Darwin": bpy.context.object.active_material.transparent_shadow_method = 'HASHED' if platform.system() == "Linux": bpy.context.object.active_material.shadow_method = 'HASHED' bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) # ENVIA COLLECTION ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "CT_Scan Voxel" not in ListaColl: obj = context.active_object myCol = bpy.data.collections.new("CT_Scan Voxel") bpy.context.scene.collection.children.link(myCol) obj.instance_collection = myCol bpy.ops.object.collection_link(collection='CT_Scan Voxel') bpy.data.collections['Collection'].objects.unlink(obj) else: obj = context.active_object bpy.ops.object.collection_link(collection='CT_Scan Voxel') bpy.data.collections['Collection'].objects.unlink(obj) # Agrupa e ajusta posição bpy.ops.object.select_all(action='DESELECT') for Arquivo in ListaArquivos: bpy.data.objects[str(Arquivo).strip('.png')].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[str(Arquivo).strip('.png')] bpy.ops.object.join() bpy.ops.transform.mirror(orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) # Corrige rotacao bpy.ops.transform.rotate(value=3.14159, orient_axis='Z', orient_type='VIEW', orient_matrix=((-1, 0, 0), (0, -1, 0), (-0, 0, -1)), orient_matrix_type='VIEW', mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') bpy.ops.object.modifier_add(type='ARRAY') bpy.context.object.modifiers["Array"].use_constant_offset = True bpy.context.object.modifiers["Array"].use_relative_offset = False bpy.context.object.modifiers["Array"].constant_offset_displace[2] = 0.1 bpy.context.object.modifiers["Array"].count = 4 bpy.context.object.modifiers["Array"].show_viewport = False # Centraliza for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) bpy.context.scene.frame_end = int(len(ListaArquivos))+1 bpy.types.Scene.IMGPathSeq = bpy.props.StringProperty \ ( name = "IMGPathSeq", description = "IMGPathSeq", default = str(TmpDirPNG) ) bpy.ops.file.pack_all() class ImportaFatiasSimples(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_fatias_simples_dcm" bl_label = "Import DICOM slices" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): #bpy.ops.object.corrige_dicom() ImportaFatiasSimplesDef() return {'FINISHED'} bpy.utils.register_class(ImportaFatiasSimples) def FatiasAxialSagitalCoronalDef(): context = bpy.context scn = context.scene obj = context.object bpy.context.space_data.shading.type = 'MATERIAL' # Descobri sozinho! bpy.context.space_data.shading.use_scene_world = True # Tem que ser aqui - muda fundo tmpdirAxial = tempfile.mkdtemp() tmpdirCoronal = tempfile.mkdtemp() tmpdirSagital = tempfile.mkdtemp() # Converte tomos em dicom def GeraSlicesVista(Vista, DiretorioDestino): context = bpy.context scn = context.scene os.chdir(scn.my_tool.path) if platform.system() == "Linux": os.system("dicomtodicom --verbose --"+Vista+" -o "+DiretorioDestino+" *") if platform.system() == "Darwin": os.system(homeall+"/Programs/OrtogOnBlender/vtk-dicom/./dicomtodicom --verbose --"+Vista+" -o "+DiretorioDestino+" *") if platform.system() == "Windows": os.system("C:\\OrtogOnBlender\\dicomtools\\dicomtodicom --verbose --"+Vista+" -o "+DiretorioDestino+" *") GeraSlicesVista("axial", tmpdirAxial) GeraSlicesVista("coronal", tmpdirCoronal) GeraSlicesVista("sagittal", tmpdirSagital) # Renomeia arquivos para evitar problema de nome dubplicado # É possível que no futuro seja necessário renomear com ID dia_mes_ano_hora_minuto_segundo_milesimo, tem que ser assim para criar um ID único, com número de ordem ou afins pode ser duplicado. def ConverteNome(Diretorio, NomeBase): ListaArquivos = os.listdir(Diretorio) os.chdir(Diretorio) for i in ListaArquivos: os.rename(i,NomeBase+"-"+i) print("Renomeado para", NomeBase) ConverteNome(tmpdirAxial, "Axial") ConverteNome(tmpdirCoronal, "Coronal") ConverteNome(tmpdirSagital, "Sagital") scn.my_tool.path = tmpdirAxial bpy.ops.object.importa_fatias_simples_dcm() bpy.context.object.name = "VOXEL_AXIAL" bpy.context.object.name = "VOXEL_AXIAL" scn.my_tool.path = tmpdirCoronal bpy.ops.object.importa_fatias_simples_dcm() bpy.context.object.name = "VOXEL_CORONAL" bpy.context.object.name = "VOXEL_CORONAL" bpy.ops.transform.rotate(value=-1.5708, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.transform_apply(location=False, rotation=True, scale=False) bpy.data.objects['VOXEL_CORONAL'].location = bpy.data.objects['VOXEL_AXIAL'].location bpy.data.objects['VOXEL_CORONAL'].dimensions = bpy.data.objects['VOXEL_AXIAL'].dimensions bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) scn.my_tool.path = tmpdirSagital bpy.ops.object.importa_fatias_simples_dcm() bpy.context.object.name = "VOXEL_SAGITTAL" bpy.context.object.name = "VOXEL_SAGITTAL" bpy.ops.transform.rotate(value=-1.5708, orient_axis='Y', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.transform.rotate(value=-1.5708, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.transform_apply(location=False, rotation=True, scale=False) bpy.data.objects['VOXEL_SAGITTAL'].location = bpy.data.objects['VOXEL_AXIAL'].location bpy.data.objects['VOXEL_SAGITTAL'].dimensions = bpy.data.objects['VOXEL_AXIAL'].dimensions bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) #Renderização #bpy.context.scene.eevee.use_gtao = True bpy.context.scene.eevee.gtao_distance = 8 bpy.context.scene.eevee.use_gtao_bent_normals = False # bpy.context.scene.eevee.use_bloom = True # NÃO FICA BOM! bpy.context.scene.eevee.use_sss = False #Senão não fica bom! bpy.context.scene.eevee.use_ssr = True bpy.context.scene.eevee.use_ssr_refraction = True bpy.context.scene.eevee.ssr_thickness = 3 bpy.context.scene.render.hair_type = 'STRIP' bpy.context.scene.eevee.shadow_method = 'ESM' bpy.context.scene.eevee.shadow_cube_size = '512' bpy.context.scene.eevee.shadow_cascade_size = '512' bpy.context.scene.eevee.use_soft_shadows = True bpy.context.scene.eevee.light_threshold = 0.013 bpy.context.scene.view_settings.exposure = 0.2 bpy.context.scene.render.engine = 'BLENDER_EEVEE' # Background BackNodeTree = bpy.data.materials.data.worlds['World'].node_tree BackNodeTree.nodes['Background'].inputs['Color'].default_value = (1,1,1,1) # Boolean VoxelDimensoes = bpy.data.objects['VOXEL_AXIAL'].dimensions VoxelLoc = bpy.data.objects['VOXEL_AXIAL'].location bpy.ops.mesh.primitive_cube_add(size=2, view_align=False, enter_editmode=False, location=(0, 0, 0)) bpy.context.object.name = "VOXEL_Boolean" bpy.context.object.name = "VOXEL_Boolean" bpy.data.objects['VOXEL_Boolean'].dimensions = VoxelDimensoes * 1.01 bpy.data.objects['VOXEL_Boolean'].location = VoxelLoc bpy.context.object.display_type = 'WIRE' bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['VOXEL_AXIAL'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['VOXEL_AXIAL'] bpy.ops.object.modifier_add(type='BOOLEAN') bpy.context.object.modifiers["Boolean"].operation = 'INTERSECT' bpy.context.object.modifiers["Boolean"].object = bpy.data.objects["VOXEL_Boolean"] bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['VOXEL_CORONAL'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['VOXEL_CORONAL'] bpy.ops.object.modifier_add(type='BOOLEAN') bpy.context.object.modifiers["Boolean"].operation = 'INTERSECT' bpy.context.object.modifiers["Boolean"].object = bpy.data.objects["VOXEL_Boolean"] bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['VOXEL_SAGITTAL'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['VOXEL_SAGITTAL'] bpy.ops.object.modifier_add(type='BOOLEAN') bpy.context.object.modifiers["Boolean"].operation = 'INTERSECT' bpy.context.object.modifiers["Boolean"].object = bpy.data.objects["VOXEL_Boolean"] class FatiasAxialSagitalCoronal(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_fatias_axial_coronal_sagital" bl_label = "Import DICOM slices axial, coronal and sagittal" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): #bpy.ops.object.corrige_dicom() FatiasAxialSagitalCoronalDef() return {'FINISHED'} bpy.utils.register_class(FatiasAxialSagitalCoronal) # IMPORTA IMAGENS def ImportaSeqTomoDef(self, context): layout = self.layout scn = context.scene obj = context.object IMGDir = str(bpy.types.Scene.IMGPathSeq[1]['default']) ListaArquivos = sorted(os.listdir(IMGDir)) listaIMG=[] for Arquivo in ListaArquivos: listaIMG.append( {"name":Arquivo, "name":Arquivo} ) print(listaIMG) bpy.ops.image.open(directory=IMGDir, files=listaIMG, relative_path=True, show_multiview=False) bpy.data.images[str(ListaArquivos[0])].source = 'SEQUENCE' space = context.space_data space.image_user.use_auto_refresh = True # bpy.data.screens["Default"]..use_auto_refresh = True class ImportaSeqTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_img_tomo" bl_label = "Import CT-Scan Images" def execute(self, context): ImportaSeqTomoDef(self, context) return {'FINISHED'} bpy.utils.register_class(ImportaSeqTomo) def ExportaSeqTomoDef(self, context): layout = self.layout scn = context.scene obj = context.object IMGDir = str(bpy.types.Scene.IMGPathSeq[1]['default']) SliceThickness = str(bpy.types.Scene.SliceThickness[1]['default']) PixelSpacingX = str(bpy.types.Scene.PixelSpacingX[1]['default']) PixelSpacingY = str(bpy.types.Scene.PixelSpacingY[1]['default']) DimPixelX = str(bpy.types.Scene.IMGDimX[1]['default']) DimPixelY = str(bpy.types.Scene.IMGDimY[1]['default']) DirDcmExp = tempfile.mkdtemp() if platform.system() == "Linux": subprocess.call('cd '+IMGDir+' && mkdir GREY && for i in *.png; do convert $i -type Grayscale -depth 8 GREY/$i; done', shell=True) print("PNGs GERADOS!!!") with open("/etc/issue") as f: Versao = str(f.read().lower().split()[1]) if Versao == "18.04": subprocess.call('python ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -i '+IMGDir+'/GREY/ -o '+DirDcmExp+' -s '+PixelSpacingX+' '+PixelSpacingY+' '+SliceThickness+' -t png', shell=True) print("DICOM BASE GERADO!!!") if Versao == "20.04": subprocess.call('python3 ~/Programs/OrtogOnBlender/Img2Dcm2004/img2dcm.py -i '+IMGDir+'/GREY/ -o '+DirDcmExp+' -s '+PixelSpacingX+' '+PixelSpacingY+' '+SliceThickness+' -t png', shell=True) #print("Entrando....") #subprocess.call('cd '+IMGDir+'/GREY/ && for i in *.png; do convert -quality 100 $i ${i%.png}.jpg; done && for i in *.jpg; do img2dcm $i ${i%.jpg}.dcm; done && mv *.dcm '+DirDcmExp, shell=True) #print("Feito") ListaArquivos = sorted(os.listdir(DirDcmExp)) os.chdir(DirDcmExp) for fatia in range(len(ListaArquivos)): ds = dicom.dcmread(str(ListaArquivos[fatia]), force=True) ds.SeriesNumber = "1" ds.AccessionNumber = "1" ds.Modality = "CT" #ds.ImagePositionPatient = "0\\0\\"+str((fatia)*float(SliceThickness)) # Valor do SliceThickness ds.PatientID = "OrtogOnBlender" ds.InstanceNumber = str(int(fatia)-1) ds.SliceThickness = SliceThickness ds.SliceLocation = str((fatia)*float(SliceThickness)) ds.PixelSpacing = PixelSpacingX+"\\"+PixelSpacingY ds.StudyID = "TESTEID" ds.PatientName = "Teste" ds.Rows = int(float(DimPixelX)) ds.Columns = int(float(DimPixelY)) ds.save_as(str(ListaArquivos[fatia])) scn.my_tool.path = DirDcmExp print("DirDcmExp:", DirDcmExp) scn.my_tool.path = DirDcmExp+"/" bpy.ops.object.corrige_dicom() # Corrige Raw tmpdirTomo2 = tempfile.mkdtemp() if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('for i in *; do gdcmconv -w -i $i -o '+tmpdirTomo2+'/$i; done', shell=True) print("Tomografia corrigida!!!") if platform.system() == "Windows": subprocess.call('for %f in (*) do C:\OrtogOnBlender\GDCM\\bin\gdcmconv -w -i %f -o '+tmpdirTomo2+'/%f', shell=True) print("Tomografia corrigida!!!") scn.my_tool.path = tmpdirTomo2+"/" print("tmpdirTomo2:", tmpdirTomo2) # subprocess.call('python2 ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -i '+IMGDir+'/GREY/ -o '+DirDcmExp+' -s '+PixelSpacingX+' '+PixelSpacingY+' '+SliceThickness+' -t png', shell=True) print("DICOM BASE GERADO!!!") # ListaArquivos = sorted(os.listdir(DirDcmExp)) # ListaArquivos = sorted(os.listdir(IMGDir+'/GREY/')) # subprocess.call('cd '+DirDcmExp, shell=True) # for fatia in range(len(ListaArquivos)): # ds = dicom.dcmread(ListaArquivos[fatia]) # ds.ImagePositionPatient[2] = int(fatia)*float(SliceThickness) # print("Fatia", ListaArquivos[fatia], "Slice", int(fatia)*float(SliceThickness)) # ds.save_as(ListaArquivos[fatia]) # print("LOOP FINALIZADO") if platform.system() == "Darwin": # Converte slices em PNGs e depois o PNGs em JPGs monocromaticos subprocess.call('cd '+IMGDir+' && mkdir GREY && for i in *.png; do convert $i -type Grayscale -depth 8 -quality 100 GREY/${i%.png}.jpg; done', shell=True) print("JPEGs GERADOS!!!") subprocess.call('cd '+IMGDir+'/GREY/ && for i in *.jpg; do img2dcm $i ${i%.jpg}.dcm; done && rm *.jpg', shell=True) # Ajusta os DICOMs nos campos que dao erro ListaArquivos = sorted(os.listdir(IMGDir+"/GREY/")) os.chdir(IMGDir+"/GREY/") for fatia in range(len(ListaArquivos)): ds = dicom.dcmread(str(ListaArquivos[fatia]), force=True) ds.SeriesNumber = "1" ds.AccessionNumber = "1" ds.Modality = "CT" ds.ImagePositionPatient = "0\\0\\"+str((fatia)*float(SliceThickness)) # Valor do SliceThickness ds.PatientID = "OrtogOnBlender" #ds.InstanceNumber = str(int(fatia)-1) ds.SliceThickness = SliceThickness ds.PixelSpacing = PixelSpacingX+"\\"+PixelSpacingY ds.StudyID = "TESTEID" ds.PatientName = "Teste" ds.Rows = int(float(DimPixelX)) ds.Columns = int(float(DimPixelY)) ds.save_as(str(ListaArquivos[fatia])) scn.my_tool.path = IMGDir+"/GREY/" if platform.system() == "Windows": DirGrayDcm = tempfile.mkdtemp() os.chdir(IMGDir) # Converte slices em PNGs e depois o PNGs em JPGs monocromaticos # subprocess.call('for %f in (*); do C:\OrtogOnBlender\ImageMagick\magick %f -type Grayscale -depth 8 -quality 100 %f.jpg; done && mkdir GREY && move *.jpg GREY', shell=True) subprocess.call('C:\OrtogOnBlender\ImageMagick\mogrify -type Grayscale -format jpg *.png && mkdir GREY && move *.jpg GREY', shell=True) print("JPEGs GERADOS!!!") scn.my_tool.path = IMGDir # subprocess.call('cd '+IMGDir+'/GREY & mkdir DCM', shell=True) # subprocess.call('cd '+IMGDir+'/GREY & for %f in *.jpg do C:\OrtogOnBlender\dcmtk\img2dcm %f %f.dcm', shell=True) ListaArquivos = sorted(os.listdir(IMGDir+"/GREY/")) os.chdir(IMGDir+"/GREY/") for arquivo in ListaArquivos: subprocess.call('C:\OrtogOnBlender\dcmtk\img2dcm '+arquivo+' '+DirGrayDcm+'\\'+arquivo+'.dcm', shell=True) print("Arquivo "+arquivo+" gerado!") # scn.my_tool.path = DirGrayDcm # Ajusta os DICOMs nos campos que dao erro ListaArquivos = sorted(os.listdir(DirGrayDcm)) os.chdir(DirGrayDcm) for fatia in range(len(ListaArquivos)): ds = dicom.dcmread(str(ListaArquivos[fatia]), force=True) ds.SeriesNumber = "1" ds.AccessionNumber = "1" ds.Modality = "CT" ds.ImagePositionPatient = "0\\0\\"+str((fatia)*float(SliceThickness)) # Valor do SliceThickness ds.PatientID = "OrtogOnBlender" ds.InstanceNumber = str(int(fatia)-1) ds.SliceThickness = SliceThickness ds.PixelSpacing = PixelSpacingX+"\\"+PixelSpacingY ds.StudyID = "TESTEID" ds.PatientName = "Teste" ds.Rows = int(float(DimPixelX)) ds.Columns = int(float(DimPixelY)) ds.save_as(str(ListaArquivos[fatia])) print("Ajustados parâmetros de "+str(fatia)) scn.my_tool.path = DirGrayDcm # Ajusta com o dicomtodicom e corrige os pontos que dao erro na importacao bpy.ops.object.corrige_dicom() ListaArquivos = sorted(os.listdir(DirGrayDcm+"/FIXED/")) os.chdir(DirGrayDcm+"/FIXED/") for fatia in range(len(ListaArquivos)): ds = dicom.dcmread(str(ListaArquivos[fatia]), force=True) ds.SeriesNumber = "1" ds.AccessionNumber = "1" ds.Modality = "CT" ds.ImagePositionPatient = "0\\0\\"+str((fatia)*float(SliceThickness)) # Valor do SliceThickness ds.PatientID = "OrtogOnBlender" ds.InstanceNumber = str(int(fatia)-1) ds.SliceThickness = SliceThickness ds.PixelSpacing = PixelSpacingX+"\\"+PixelSpacingY ds.StudyID = "TESTEID" ds.PatientName = "Teste" ds.Rows = int(float(DimPixelX)) ds.Columns = int(float(DimPixelY)) ds.save_as(str(ListaArquivos[fatia])) print("Ajustados FIXED de "+str(fatia)) scn.my_tool.path = DirGrayDcm+"/FIXED/" class ExportaSeqTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.exporta_img_tomo" bl_label = "Teste" def execute(self, context): ExportaSeqTomoDef(self, context) return {'FINISHED'} bpy.utils.register_class(ExportaSeqTomo) # Abre o SLicer para ver o Threshold def AbreSlicerDef(self, context): context = bpy.context scn = context.scene if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: homeall = expanduser("~") os.chdir(scn.my_tool.path) DirAtual = os.getcwd() ArqAtual = os.listdir(os.getcwd())[0] print("Atual:", os.getcwd()) print (os.listdir(os.getcwd())[0]) # ABRE SLICER if platform.system() == "Linux": subprocess.call(homeall+'/Programs/OrtogOnBlender/Slicer481/./Slicer '+str(DirAtual+"/"+ArqAtual+" &"), shell=True) if platform.system() == "Windows": subprocess.call('START /B C:/OrtogOnBlender/Slicer410/Slicer.exe '+str(DirAtual+"/"+ArqAtual), shell=True) if platform.system() == "Darwin": subprocess.call(homeall+'/Programs/OrtogOnBlender/Slicer/Slicer.app/Contents/MacOS/Slicer '+str(DirAtual+"/"+ArqAtual+" &"), shell=True) class AbreSlicer(bpy.types.Operator): """Tooltip""" bl_idname = "object.abre_slicer" bl_label = "Open Slicer" def execute(self, context): AbreSlicerDef(self, context) return {'FINISHED'} bpy.utils.register_class(AbreSlicer) def AbreSlicerMHADef(self, context): context = bpy.context scn = context.scene homeall = expanduser("~") if platform.system() == "Linux": subprocess.call(homeall+'/Programs/OrtogOnBlender/Slicer481/./Slicer '+scn.my_tool.filepathmha+" &", shell=True) if platform.system() == "Windows": subprocess.call('START /B C:/OrtogOnBlender/Slicer410/Slicer.exe '+scn.my_tool.filepathmha, shell=True) if platform.system() == "Darwin": subprocess.call(homeall+'/Programs/OrtogOnBlender/Slicer/Slicer.app/Contents/MacOS/Slicer '+scn.my_tool.filepathmha+" &", shell=True) class AbreSlicerMHA(bpy.types.Operator): """Tooltip""" bl_idname = "object.abre_slicer_mha" bl_label = "Open Slicer MHA" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): AbreSlicerMHADef(self, context) return {'FINISHED'} bpy.utils.register_class(AbreSlicerMHA) def VoxelShaderDefaultDef(): try: bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[0].position = 0.164 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[1].position = 1 # Cor pele bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.364313 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['RGB Curves'].inputs['Fac'].default_value = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['RGB Curves'].inputs['Fac'].default_value = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[0].position = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.364 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[2].position = 0.776 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[3].position = 1 except: print("Problema com o material do voxel na cena, pode não conter!") class VoxelShaderDefault(bpy.types.Operator): """Tooltip""" bl_idname = "object.voxelshader_default" bl_label = "Voxel Shader Default" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): VoxelShaderDefaultDef() return {'FINISHED'} bpy.utils.register_class(VoxelShaderDefault) def VoxelShaderOssoDef(): try: bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[0].position = 0.55 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[1].position = 1 # Cor pele bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.364313 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['RGB Curves'].inputs['Fac'].default_value = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['RGB Curves'].inputs['Fac'].default_value = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[0].position = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.364 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[2].position = 0.776 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[3].position = 1 except: print("Problema com o material do voxel na cena, pode não conter!") class VoxelShaderOsso(bpy.types.Operator): """Tooltip""" bl_idname = "object.voxelshader_osso" bl_label = "Voxel Shader Bone" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): VoxelShaderOssoDef() return {'FINISHED'} bpy.utils.register_class(VoxelShaderOsso) def VoxelShaderPeleDef(): try: bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[0].position = 0.04 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[1].position = 1 # Cor pele bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.08 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['RGB Curves'].inputs['Fac'].default_value = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[0].position = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.364 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[2].position = 0.776 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[3].position = 1 except: print("Problema com o material do voxel na cena, pode não conter!") class VoxelShaderPele(bpy.types.Operator): """Tooltip""" bl_idname = "object.voxelshader_pele" bl_label = "Voxel Shader Skin" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): VoxelShaderPeleDef() return {'FINISHED'} bpy.utils.register_class(VoxelShaderPele) def VoxelShaderMusculoDef(): try: bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[0].position = 0.444 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.004'].color_ramp.elements[1].position = 1 # Cor pele bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.08 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['RGB Curves'].inputs['Fac'].default_value = 1 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[0].position = 0 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[1].position = 0.108 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[2].position = 0.286 bpy.data.materials.data.node_groups['GroupVoxelShader'].nodes['ColorRamp.003'].color_ramp.elements[3].position = 1 except: print("Problema com o material do voxel na cena, pode não conter!") class VoxelShaderMusculo(bpy.types.Operator): """Tooltip""" bl_idname = "object.voxelshader_musculo" bl_label = "Voxel Shader Muscle" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): VoxelShaderMusculoDef() return {'FINISHED'} bpy.utils.register_class(VoxelShaderMusculo) ================================================ FILE: FerrMalhas.py ================================================ import bpy def FechaMoldeSimplesDef(self, context): context = bpy.context obj = context.object scn = context.scene bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.fill() bpy.ops.object.editmode_toggle() class FechaMoldeSimples(bpy.types.Operator): """Tooltip""" bl_idname = "object.fecha_molde_simples" bl_label = "Close hole simple" def execute(self, context): FechaMoldeSimplesDef(self, context) return {'FINISHED'} bpy.utils.register_class(FechaMoldeSimples) def ParenteiaObjetosDef(): # objetos_selecionados = [ o for o in bpy.context.selected_objects ] # for i in objetos_selecionados: # if i.visible_get() == True: # bpy.ops.object.parent_set(type='OBJECT', keep_transform=True) bpy.ops.object.parent_set(type='OBJECT', keep_transform=True) print("Parenteado!") class ParenteiaObjetos(bpy.types.Operator): """Tooltip""" bl_idname = "object.parenteia_objetos" bl_label = "Parenteia objetos" def execute(self, context): ParenteiaObjetosDef() return {'FINISHED'} bpy.utils.register_class(ParenteiaObjetos) def DesparenteiaObjetosDef(): bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') print("Desparenteado!") class DesparenteiaObjetos(bpy.types.Operator): """Tooltip""" bl_idname = "object.desparenteia_objetos" bl_label = "Desparenteia objetos" def execute(self, context): DesparenteiaObjetosDef() return {'FINISHED'} bpy.utils.register_class(DesparenteiaObjetos) def CriaShapeKeysDef(): bpy.ops.object.shape_key_add(from_mix=False) bpy.ops.object.shape_key_add(from_mix=False) bpy.data.shape_keys["Key"].key_blocks["Key 1"].value = 1 class CriaShapeKeys(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_shape_keys" bl_label = "Cria ShapeKeys Def" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaShapeKeysDef() return {'FINISHED'} bpy.utils.register_class(CriaShapeKeys) class EntraEditModeLimpo(bpy.types.Operator): """Tooltip""" bl_idname = "object.entra_editmode_limpo" bl_label = "Cria ShapeKeys Def" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') return {'FINISHED'} bpy.utils.register_class(EntraEditModeLimpo) def SelecionaObjeto(NomeObjeto): context = bpy.context scn = context.scene objeto = bpy.data.objects[NomeObjeto] bpy.ops.object.select_all(action='DESELECT') objeto.select_set(True) context.view_layer.objects.active = objeto ================================================ FILE: FerrMedidas.py ================================================ import bpy import math from math import sqrt def CriaPontoMedidasDef(): context = bpy.context objInicial = context.active_object # Objeto selecionado scn = context.scene bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = bpy.context.scene.nome_ponto_customizado #bpy.context.object.show_name = True obj = context.active_object # Muda para o ponto # Atribui a coleção ListaColecoes = [] ColocoesCena = bpy.data.collections colecao = "Anatomical Measure Custom" for i in ColocoesCena: ListaColecoes.append(i.name) if colecao in ListaColecoes: bpy.ops.object.collection_link(collection=colecao) # bpy.data.collections['Collection'].objects.unlink(obj) else: myCol = bpy.data.collections.new(colecao) bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection=colecao) # bpy.data.collections['Collection'].objects.unlink(obj) bpy.data.collections['Collection'].objects.unlink(obj) # Adiciona material ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatCustomPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatCustomPoints"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.8, 0.7, 0, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatCustomPoints") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.8, 0.70, 0, 1) bpy.ops.object.duplicate_move() bpy.context.object.name = bpy.context.scene.nome_ponto_customizado+"Parent" objParent = context.active_object bpy.ops.object.select_all(action='DESELECT') # Parenteia cópia a osteotomia objInicial.select_set(True) objParent.select_set(True) bpy.context.view_layer.objects.active = objInicial bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') # Cria objeto X obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.duplicate_move() bpy.context.object.name = bpy.context.scene.nome_ponto_customizado+"X" objX = context.active_object # Apaga todos os Materiais do objeto for ob in bpy.context.selected_editable_objects: ob.active_material_index = 0 for i in range(len(ob.material_slots)): bpy.ops.object.material_slot_remove({'object': ob}) # Cria e atribui material ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatCustomPointsX' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatCustomPointsX"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.8, 0, 0, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatCustomPointsX") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.8, 0, 0, 1) # Atribui constraint X bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = objParent bpy.context.object.constraints["Copy Location"].use_y = False bpy.context.object.constraints["Copy Location"].use_z = False # Atribui medida X bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) objX.select_set(True) bpy.context.view_layer.objects.active = obj bpy.context.scene.measureit_default_color = (1, 0.210597, 0.00242219, 1) bpy.context.scene.measureit_font_size = 22 bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') # Cria objeto Y bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.duplicate_move() bpy.context.object.name = bpy.context.scene.nome_ponto_customizado+"Y" objY = context.active_object # Apaga todos os Materiais do objeto for ob in bpy.context.selected_editable_objects: ob.active_material_index = 0 for i in range(len(ob.material_slots)): bpy.ops.object.material_slot_remove({'object': ob}) # Cria e atribui material ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatCustomPointsY' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatCustomPointsY"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0, 0.8, 0, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatCustomPointsY") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0, 0.8, 0, 1) # Atribui constraint Y bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = objParent bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_z = False # Atribui medida Y bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) objY.select_set(True) bpy.context.view_layer.objects.active = obj bpy.context.scene.measureit_default_color = (0.393438, 1, 0.265891, 1) bpy.context.scene.measureit_font_size = 22 bpy.ops.measureit.addlink() # Cria objeto Z bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.duplicate_move() bpy.context.object.name = bpy.context.scene.nome_ponto_customizado+"Z" objZ = context.active_object # Apaga todos os Materiais do objeto for ob in bpy.context.selected_editable_objects: ob.active_material_index = 0 for i in range(len(ob.material_slots)): bpy.ops.object.material_slot_remove({'object': ob}) # Cria e atribui material ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatCustomPointsZ' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatCustomPointsZ"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0, 0, 0.8, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatCustomPointsZ") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0, 0, 0.8, 1) # Atribui constraint Z bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = objParent bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False # Atribui medida Z bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) objZ.select_set(True) bpy.context.view_layer.objects.active = obj bpy.context.scene.measureit_default_color = (0.49548, 0.676547, 1, 1) bpy.context.scene.measureit_font_size = 22 bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') # Apagar as medidas a MAIS objY.select_set(True) bpy.context.view_layer.objects.active = objY bpy.ops.measureit.deletesegment(tag=0) bpy.ops.object.select_all(action='DESELECT') objZ.select_set(True) bpy.context.view_layer.objects.active = objZ bpy.ops.measureit.deletesegment(tag=0) bpy.ops.measureit.deletesegment(tag=0) bpy.ops.object.select_all(action='DESELECT') class CriaPontoMedida(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_ponto_medida" bl_label = "Create Measure Anatomical Point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = len(bpy.context.selected_objects) if found == 1: return True else: if found != 1: return False def execute(self, context): CriaPontoMedidasDef() return {'FINISHED'} bpy.utils.register_class(CriaPontoMedida) def CalculaAngulo(Obj1, Obj2, Obj3): # Calcula d1_2 = DistanciaObjetos(Obj1, Obj2) d2_3 = DistanciaObjetos(Obj2, Obj3) d1_3 = DistanciaObjetos(Obj1, Obj3) Grau = (d2_3**2 + d1_2**2 - d1_3**2) / (2 * d2_3 * d1_2) Angulo = float(round(math.degrees(math.acos(Grau)),2)) print("Grau (rad):", Grau) print("Ângulo:", Angulo) return str(Angulo)+"º" def DistanciaObjetos(obj1, obj2): objA = bpy.data.objects[obj1].location objB = bpy.data.objects[obj2].location distancia = sqrt( (objB[0] - objA[0])**2 + (objB[1] - objA[1])**2 + (objB[2] - objA[2])**2 ) print("Distancia", obj1 , "<-->", obj2 , "=" , distancia ) return distancia def MedidasVerDentesDef(self, context): context = bpy.context obj = context.active_object bpy.context.scene.measureit_default_color = (1, 1, 1, 1) bpy.context.scene.measureit_font_size = 16 bpy.ops.mesh.add_linhabase(location=(0,0,0), rotation=(0, 1.5708, 0)) # bpy.context.object.show_x_ray = True bpy.context.object.lock_location[0] = True bpy.context.object.lock_location[1] = True bpy.context.object.name = "LinhaMedida" bpy.ops.object.select_all(action='DESELECT') # CRIA CÓPIAS DOS EMPTIES bpy.data.objects['Tooth 8'].select_set(True) bpy.data.objects['Tooth 9'].select_set(True) bpy.data.objects['Tooth 6'].select_set(True) bpy.data.objects['Tooth 11'].select_set(True) bpy.data.objects['Tooth 3'].select_set(True) bpy.data.objects['Tooth 14'].select_set(True) bpy.ops.object.duplicate() # TRAVA OS EMPTIES NA LINHA DE REFERÊNCIA bpy.ops.object.select_all(action='DESELECT') objAct = bpy.data.objects['Tooth 8.001'] objAct.select_set(True) context.view_layer.objects.active = objAct bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedida"] bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects["Tooth 8"] bpy.context.object.constraints["Copy Location.001"].use_z = False bpy.ops.object.select_all(action='DESELECT') objAct = bpy.data.objects['Tooth 9.001'] objAct.select_set(True) context.view_layer.objects.active = objAct bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedida"] bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects["Tooth 9"] bpy.context.object.constraints["Copy Location.001"].use_z = False bpy.ops.object.select_all(action='DESELECT') objAct = bpy.data.objects['Tooth 6.001'] objAct.select_set(True) context.view_layer.objects.active = objAct bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedida"] bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects["Tooth 6"] bpy.context.object.constraints["Copy Location.001"].use_z = False bpy.ops.object.select_all(action='DESELECT') objAct = bpy.data.objects['Tooth 11.001'] objAct.select_set(True) context.view_layer.objects.active = objAct bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedida"] bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects["Tooth 11"] bpy.context.object.constraints["Copy Location.001"].use_z = False bpy.ops.object.select_all(action='DESELECT') objAct = bpy.data.objects['Tooth 3.001'] objAct.select_set(True) context.view_layer.objects.active = objAct bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedida"] bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects["Tooth 3"] bpy.context.object.constraints["Copy Location.001"].use_z = False bpy.ops.object.select_all(action='DESELECT') objAct = bpy.data.objects['Tooth 14.001'] objAct.select_set(True) context.view_layer.objects.active = objAct bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedida"] bpy.context.object.constraints["Copy Location"].use_x = False bpy.context.object.constraints["Copy Location"].use_y = False bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects["Tooth 14"] bpy.context.object.constraints["Copy Location.001"].use_z = False # CRIA MEDIDAS bpy.ops.measureit.runopengl() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 8'] b = bpy.data.objects['Tooth 8.001'] a.select_set(True) b.select_set(True) context.view_layer.objects.active = a bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 9'] b = bpy.data.objects['Tooth 9.001'] a.select_set(True) b.select_set(True) context.view_layer.objects.active = a bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 6'] b = bpy.data.objects['Tooth 6.001'] a.select_set(True) b.select_set(True) context.view_layer.objects.active = a bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 11'] b = bpy.data.objects['Tooth 11.001'] a.select_set(True) b.select_set(True) context.view_layer.objects.active = a bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 3'] b = bpy.data.objects['Tooth 3.001'] a.select_set(True) b.select_set(True) context.view_layer.objects.active = a bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['Tooth 14'] b = bpy.data.objects['Tooth 14.001'] a.select_set(True) b.select_set(True) context.view_layer.objects.active = a bpy.ops.measureit.addlink() # SELECIONA LINHA MEDIDA bpy.ops.object.select_all(action='DESELECT') a = bpy.data.objects['LinhaMedida'] a.select_set(True) context.view_layer.objects.active = a def CriaMedidaHor(Obj1, Obj2): bpy.context.scene.measureit_default_color = (1, 1, 0, 1) bpy.context.scene.measureit_font_size = 16 bpy.ops.object.empty_add(type='PLAIN_AXES') # bpy.context.space_data.context = 'CONSTRAINT' bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location"].target = bpy.data.objects["LinhaMedidaHor"] bpy.context.object.constraints["Copy Location"].use_y = False bpy.context.object.constraints["Copy Location"].use_z = False bpy.context.object.constraints["Copy Location"].use_z = True bpy.ops.object.constraint_add(type='COPY_LOCATION') bpy.context.object.constraints["Copy Location.001"].target = bpy.data.objects[Obj1] bpy.context.object.constraints["Copy Location.001"].use_x = False bpy.context.object.constraints["Copy Location.001"].use_z = False bpy.ops.object.parent_set(type='OBJECT', keep_transform=True) bpy.context.object.name = Obj2 bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[Obj1].select_set(True) bpy.data.objects[Obj2].select_set(True) # context.view_layer.objects.active = bpy.data.objects['Tooth 9.001'] bpy.ops.measureit.addlink() bpy.ops.object.select_all(action='DESELECT') def MedidasHorDentesDef(self, context): context = bpy.context obj = context.active_object bpy.ops.mesh.add_linhabase(location=(0,0,0), rotation=( 1.5708, 0 , 0)) # bpy.context.object.show_x_ray = True bpy.context.object.lock_location[0] = True bpy.context.object.lock_location[1] = True bpy.context.object.name = "LinhaMedidaHor" bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['LinhaMedida'].select_set(True) bpy.data.objects['LinhaMedidaHor'].select_set(True) context.view_layer.objects.active = bpy.data.objects['LinhaMedida'] bpy.ops.object.parent_set(type='OBJECT', keep_transform=True) bpy.ops.object.select_all(action='DESELECT') CriaMedidaHor("Tooth 9.001", "EMPHor_9") CriaMedidaHor("Tooth 8.001", "EMPHor_8") CriaMedidaHor("Tooth 6.001", "EMPHor_6") CriaMedidaHor("Tooth 11.001", "EMPHor_11") CriaMedidaHor("Tooth 3.001", "EMPHor_3") CriaMedidaHor("Tooth 14.001", "EMPHor_14") class MedidasVerHorDentes(bpy.types.Operator): """Tooltip""" bl_idname = "object.medverhor_dentes" bl_label = "Medidas Verticais" def execute(self, context): MedidasVerDentesDef(self, context) MedidasHorDentesDef(self, context) return {'FINISHED'} bpy.utils.register_class(MedidasVerHorDentes) def ApagaPontosCopiadosDef(): ListaPontos = ["Tooth 9.001","Tooth 8.001","Tooth 6.001","Tooth 11.001","Tooth 3.001","Tooth 14.001"] for ob in ListaPontos: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[ob].select_set(True) bpy.ops.object.delete(use_global=False) class ApagaPontosCopiados(bpy.types.Operator): """Tooltip""" bl_idname = "object.apaga_pontos_objetos" bl_label = "Apaga Pontos Copiados" def execute(self, context): ApagaPontosCopiadosDef() return {'FINISHED'} bpy.utils.register_class(ApagaPontosCopiados) ================================================ FILE: FerrSegmentacao.py ================================================ import bpy import bmesh import tempfile import subprocess import platform #from .__init__ import * from .AjustaTomo import * from .ConfOsteotomiaAuto import * from math import sqrt def CriaVoxelCubePlanosDef(): bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['VoxelCube'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['VoxelCube'] Origem = bpy.data.objects['VoxelCube'].location bpy.ops.mesh.primitive_cube_add(size=300, view_align=False, enter_editmode=False, location=Origem) ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatVoxelCube' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatVoxelCube"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (1, 1, 1, 0.5) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatVoxelCube") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (1, 1, 1, 0.5) class CriaVoxelCubePlanos(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_voxelcube_planos" bl_label = "Create VoxelCube Planes" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaVoxelCubePlanosDef() return {'FINISHED'} bpy.utils.register_class(CriaVoxelCubePlanos) def ImportaObjBlendDef(nome): #, colecao): context = bpy.context obj = context.active_object scn = context.scene try: bpy.ops.object.mode_set(mode='OBJECT') except: print("Erro com o Object Mode!") if platform.system() == "Linux": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" # section = "\\Collection\\" # object = "SPLINT" section = "\\Object\\" object = nome if platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Object\\" object = nome if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Object\\" object = nome filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) ObjImportado = bpy.data.objects[nome] bpy.ops.object.select_all(action='DESELECT') ObjImportado.select_set(True) context.view_layer.objects.active = ObjImportado # Coloca na camada obj2 = bpy.context.view_layer.objects.active ''' ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if colecao not in ListaColl: myCol = bpy.data.collections.new(colecao) bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection=colecao) # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection=colecao) # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) ''' class ImportaVoxelCube(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_voxelcube" bl_label = "Import VoxelCube" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'VoxelCube' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ImportaObjBlendDef("VoxelCube") #, "Collection") return {'FINISHED'} bpy.utils.register_class(ImportaVoxelCube) def Converte3DparaVoxelDef(): context = bpy.context obj = context.object scn = context.scene tmpdir = tempfile.mkdtemp() # Seleciona o VoxelCube bpy.data.objects['VoxelCube'].select_set(True) # Exporta como STL bpy.ops.export_mesh.stl(filepath=tmpdir+"/Model.stl", check_existing=True, filter_glob="*.stl", use_selection=True, global_scale=1, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF', axis_forward='Y', axis_up='Z') if platform.system() == "Linux": with open("/etc/issue") as f: Versao = str(f.read().lower().split()[1]) if Versao == "18.04": # Converte objeto em slices de imagens subprocess.call('cd '+tmpdir+' && mkdir '+tmpdir+'/VOXEL && python3 ~/Programs/OrtogOnBlender/StlToVoxel/stltovoxel.py '+tmpdir+'/Model.stl '+tmpdir+'/VOXEL/img.png', shell=True) # Converte em greyscale subprocess.call('cd '+tmpdir+'/VOXEL && mkdir '+tmpdir+'/VOXEL/GREY && for i in *.png; do convert $i -type Grayscale -depth 8 '+tmpdir+'/VOXEL/GREY/${i%.png}.png; done', shell=True) # Converte em DICOM subprocess.call('cd '+tmpdir+'/VOXEL/GREY && mkdir '+tmpdir+'/VOXEL/GREY/DCM/ && python ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -i '+tmpdir+'/VOXEL/GREY/ -o '+tmpdir+'/VOXEL/GREY/DCM/ -s 0.588 0.588 0.588 -t png', shell=True) print("DICOM BASE GERADO!!!") subprocess.call('~/Programs/OrtogOnBlender/VolView/bin/VolView '+tmpdir+'/VOXEL/GREY/DCM/0000.dcm &', shell=True) if Versao == "20.04.1" or Versao == "20.04": # Converte objeto em slices de imagens subprocess.call('cd '+tmpdir+' && mkdir '+tmpdir+'/VOXEL && python3 ~/Programs/OrtogOnBlender/StlToVoxel/stltovoxel.py '+tmpdir+'/Model.stl '+tmpdir+'/VOXEL/img.png', shell=True) # Converte em greyscale subprocess.call('cd '+tmpdir+'/VOXEL && mkdir '+tmpdir+'/VOXEL/GREY && for i in *.png; do convert $i -type Grayscale -depth 8 '+tmpdir+'/VOXEL/GREY/${i%.png}.png; done', shell=True) # Converte em DICOM subprocess.call('cd '+tmpdir+'/VOXEL/GREY && mkdir '+tmpdir+'/VOXEL/GREY/DCM/ && python2 ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -i '+tmpdir+'/VOXEL/GREY/ -o '+tmpdir+'/VOXEL/GREY/DCM/ -s 0.588 0.588 0.588 -t png', shell=True) print("DICOM BASE GERADO!!!") subprocess.call('~/Programs/OrtogOnBlender/VolView/bin/VolView '+tmpdir+'/VOXEL/GREY/DCM/0000.dcm &', shell=True) if platform.system() == "Windows": Temporario = str(tmpdir).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") os.chdir(tmpdir) subprocess.call('mkdir VOXEL', shell=True) # Converte objeto em slices de imagens subprocess.call("wsl python3 \"/mnt/c/OrtogOnBlender/StlToVoxel/stltovoxel.py\" \""+Temporario+"/Model.stl\" \""+Temporario+"/VOXEL/img.png\"", shell=True) # Converte em greyscale os.chdir(tmpdir+"/VOXEL") subprocess.call('mkdir GREY', shell=True) subprocess.call("wsl for i in *.png; do convert $i -type Grayscale -depth 8 GREY/${i%.png}.png; done", shell=True) # Converte em DICOM os.chdir(tmpdir+"/VOXEL/GREY") subprocess.call('mkdir DEC', shell=True) subprocess.call("wsl python \"/mnt/c/OrtogOnBlender/Img2Dcm/img2dcm.py\" -i \""+Temporario+"/VOXEL/GREY\" -o \""+Temporario+"/DCM\" -s \"0.588\" \"0.588\" \"0.588\" -t png", shell=True) print("DICOM BASE GERADO!!!") #subprocess.call('C:/OrtogOnBlender/VolView/bin/VolView.exe '+tmpdir+'/DCM/0000.dcm', shell=True) # POR ALGUM MOTIVO NÃO FUNCIONA!!! USE O DE BAIXO! subprocess.call("C:\\OrtogOnBlender\\VolView\\bin\\VolView "+tmpdir+"\\DCM\\0000.dcm &", shell=True) class Converte3DparaVoxel(bpy.types.Operator): """Tooltip""" bl_idname = "object.converte_3d_voxel" bl_label = "Convert 3D to Voxel" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'VoxelCube' in bpy.data.objects if found == False: return False else: if found == True: return True def execute(self, context): Converte3DparaVoxelDef() return {'FINISHED'} bpy.utils.register_class(Converte3DparaVoxel) def ConverteImagensTomoDef(): context = bpy.context obj = context.object scn = context.scene s1 = bpy.context.scene.S1 s2 = bpy.context.scene.S2 s3 = bpy.context.scene.S3 print("s1: ", s1) print("s2: ", s2) print("s3: ", s3) try: tmpdir = tempfile.mkdtemp() print("Criei tmp") if platform.system() == "Linux": subprocess.call('cd '+scn.my_tool.path_slices_img+' && mkdir '+tmpdir+'/GREY && for i in *.jpg; do convert $i -type Grayscale -depth 8 -quality 100 '+tmpdir+'/GREY/${i%.png}.jpg; done', shell=True) #subprocess.call('mkdir '+tmpdir+'/DCM && python2.7 ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -t jpg -i '+tmpdir+'/GREY/ -o '+tmpdir+'/DCM/ -s '+str(s1)+' '+str(s2)+' '+str(s3), shell=True) subprocess.call('python ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -i '+tmpdir+'/GREY/ -o '+tmpdir+'/DCM/ -s '+str(s1)+' '+str(s2)+' '+str(s3)+' -t jpg', shell=True) print("DICOM BASE GERADO!!!") subprocess.call('~/Programs/OrtogOnBlender/VolView/bin/VolView '+tmpdir+'/DCM/0000.dcm &', shell=True) if platform.system() == "Windows": os.chdir(scn.my_tool.path_slices_img) print("Entrrei") subprocess.call('C:\OrtogOnBlender\ImageMagick\mogrify -type Grayscale -format jpg *.png && mkdir GREY && move *.jpg GREY', shell=True) print("Rodei") #subprocess.call('python ~/Programs/OrtogOnBlender/Img2Dcm/img2dcm.py -i '+tmpdir+'/GREY/ -o '+tmpdir+'/DCM/ -s '+str(s1)+' '+str(s2)+' '+str(s3)+' -t jpg', shell=True) #print("DICOM BASE GERADO!!!") Entrada = str(scn.my_tool.path_slices_img+"/GREY").replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") Saida = str(scn.my_tool.path_slices_img+"/DCM").replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") subprocess.call("mkdir DCM", shell=True) print("Criei DCM") print("wsl python \"/mnt/c/OrtogOnBlender/Img2Dcm/img2dcm.py\" -i \""+Entrada+"\" -o \""+Saida+"\" -t jpg") subprocess.call("wsl python \"/mnt/c/OrtogOnBlender/Img2Dcm/img2dcm.py\" -i \""+Entrada+"\" -o \""+Saida+"\" -s "+str(s1)+" "+str(s2)+" "+str(s3)+" -t jpg", shell=True) ''' ListaArquivos = sorted(os.listdir(scn.my_tool.path_slices_img+"/GREY/")) os.chdir(scn.my_tool.path_slices_img+"/GREY/") subprocess.call('mkdir DCM', shell=True) for arquivo in ListaArquivos: subprocess.call('C:\OrtogOnBlender\dcmtk\img2dcm '+arquivo+' DCM\\'+arquivo+'.dcm', shell=True) print("Convertendo para DCM:", arquivo) print("Arquivo "+arquivo+" gerado!") print("C:\\OrtogOnBlender\\VolView\\bin\\VolView "+scn.my_tool.path_slices_img+"\\GREY\\DCM\\"+str(ListaArquivos[0])+".dcm &") ''' subprocess.call("C:\\OrtogOnBlender\\VolView\\bin\\VolView "+scn.my_tool.path_slices_img+"\\DCM\\0000.dcm &", shell=True) except: print("Não consegui converter as imagens em GREY!") class ConverteImagensTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.converte_imagens_tomo" bl_label = "Convert Images to CT-Scan" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ConverteImagensTomoDef() return {'FINISHED'} bpy.utils.register_class(ConverteImagensTomo) def CalculaDimensaoDCMDef(): context = bpy.context obj = context.object scn = context.scene # FatorEscalaDCM = bpy.context.scene.FatorEscalaDCM # MedidaRealDCM = bpy.context.scene.MedidaRealDCM # MedidaAtualDCM = bpy.context.scene.MedidaAtualDCM FatorEscala = float(bpy.context.scene.MedidaRealDCM) / float(bpy.context.scene.MedidaAtualDCM) bpy.types.Scene.FatorEscalaDCM = bpy.props.StringProperty \ ( name = "", description = "Scale Factor", default = str(round((FatorEscala),2)) ) class CalculaDimensaoDCM(bpy.types.Operator): """Tooltip""" bl_idname = "object.calcula_dimensao_dcm" bl_label = "Calc CT-Scan Dimension" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CalculaDimensaoDCMDef() return {'FINISHED'} bpy.utils.register_class(CalculaDimensaoDCM) def ConverteVideoImagemDef(): context = bpy.context obj = context.object scn = context.scene tmpdir = tempfile.mkdtemp() try: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call("ffmpeg -i "+scn.my_tool.filepathvideo+" -quality 100 "+tmpdir+"/pic_%04d.jpg", shell=True) subprocess.call("cd "+tmpdir+" && mkdir SELECTED", shell=True) abrir_diretorio(tmpdir) scn.my_tool.path_slices_img = tmpdir+"/SELECTED" if platform.system() == "Windows": subprocess.call('C:\\OrtogOnBlender\\ffmpeg\\ffmpeg.exe -i '+scn.my_tool.filepathvideo+" -quality 100 "+tmpdir+"\pic_%04d.jpg", shell=True) #subprocess.call(['C:\OrtogOnBlender\ffmpeg\ffmpeg.exe','-i', scn.my_tool.filepathvideo, '-quality', '100', tmpdir+"\pic_%04d.jpg" ]) abrir_diretorio(tmpdir) scn.my_tool.path_slices_img = tmpdir+"/SELECTED" except: print("Algo deu errado com o arquivo de vídeo!") class ConverteVideoImagem(bpy.types.Operator): """Tooltip""" bl_idname = "object.converte_video_imagem" bl_label = "Convert Video to Image" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ConverteVideoImagemDef() return {'FINISHED'} bpy.utils.register_class(ConverteVideoImagem) def ConverteVideoImagemWINDef(): context = bpy.context obj = context.object scn = context.scene tmpdir = tempfile.mkdtemp() try: if platform.system() == "Windows": subprocess.call('C:\\OrtogOnBlender\\ffmpeg\\ffmpeg.exe -i '+scn.my_tool.filepathvideo+" "+tmpdir+"\pic_%04d.png", shell=True) subprocess.call("cd "+tmpdir+" && mkdir SELECTED", shell=True) abrir_diretorio(tmpdir) scn.my_tool.path_slices_img = tmpdir+"/SELECTED" except: print("Algo deu errado com o arquivo de vídeo!") class ConverteVideoImagemWIN(bpy.types.Operator): """Tooltip""" bl_idname = "object.converte_video_imagem_win" bl_label = "Convert Video to Image" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ConverteVideoImagemWINDef() return {'FINISHED'} bpy.utils.register_class(ConverteVideoImagemWIN) def SegmentaLinkedDef(self, context): listaDist = [] # ponto = bpy.context.scene.cursor_location ponto = bpy.context.scene.cursor.location # obj = bpy.context.scene.objects.active obj = bpy.context.view_layer.objects.active # Duplica objeto bpy.ops.object.duplicate() obj2 = bpy.context.view_layer.objects.active # Joga outro layer #TESTA SE HÁ Copied_Objects ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Copied_Objects" not in ListaColl: myCol = bpy.data.collections.new("Copied_Objects") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Copied_Objects') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) bpy.data.collections['Copied_Objects'].hide_viewport=True # bpy.ops.object.move_to_layer(layers=(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False)) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj # Lista os vértices do objeto if obj.mode == 'EDIT': bm = bmesh.from_edit_mesh(obj.data) vertices = bm.verts else: vertices = obj.data.vertices # Todos os vértices por vetor # verts = [obj.matrix_world * vert.co for vert in vertices] verts = [obj.matrix_world @ vert.co for vert in vertices] # Captura vetor do objeto referencia = bpy.context.scene.cursor.location # Calcula distância pontos def DistanciaObjs(obj1, obj2): objA = referencia objB = obj2 distancia = sqrt( (objB[0] - objA[0])**2 + (objB[1] - objA[1])**2 + (objB[2] - objA[2])**2 ) return distancia for i in range(len(verts)): vertAtual = verts[i] distanciaVert = DistanciaObjs(ponto, vertAtual) listaDist.append([distanciaVert, i]) listaFin = sorted(listaDist) print("MAIS PRÓXIMO!", listaFin[0]) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.object.mode_set(mode = 'OBJECT') obj.data.vertices[listaFin[0][1]].select = True bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_linked() bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.delete(type='VERT') bpy.ops.object.mode_set(mode = 'OBJECT') class SegmentaLinked(bpy.types.Operator): """Tooltip""" bl_idname = "object.segmenta_linked" bl_label = "SegmentaLinked" def execute(self, context): SegmentaLinkedDef(self, context) return {'FINISHED'} # WEIGHTS def Weight1Def(self, context): bpy.ops.object.mode_set(mode='WEIGHT_PAINT') bpy.data.brushes["Draw"].vertex_tool = 'DRAW' bpy.ops.brush.curve_preset(shape='MAX') bpy.context.scene.tool_settings.unified_paint_settings.weight = 1 class Weight1(bpy.types.Operator): """Tooltip""" bl_idname = "object.weight_1" bl_label = "Change Weight to 1" def execute(self, context): Weight1Def(self, context) return {'FINISHED'} def Weight0Def(self, context): bpy.ops.object.mode_set(mode='WEIGHT_PAINT') bpy.data.brushes["Draw"].vertex_tool = 'DRAW' bpy.ops.brush.curve_preset(shape='MAX') bpy.context.scene.tool_settings.unified_paint_settings.weight = 0 class Weight0(bpy.types.Operator): """Tooltip""" bl_idname = "object.weight_0" bl_label = "Change Weight to 0" def execute(self, context): Weight0Def(self, context) return {'FINISHED'} # Segmentação por pintura - Apaga Azul def MantemPintadoDef(self, context): bpy.ops.object.mode_set(mode = 'OBJECT') bpy.context.object.name = "ObjSplint" # Seleciona área interesse # Which group to find? groupName = 'Group' # Use the active object obj = bpy.context.view_layer.objects.active # Make sure you're in edit mode bpy.ops.object.mode_set(mode='EDIT') # Deselect all verts bpy.ops.mesh.select_all(action='DESELECT') # Make sure the active group is the one we want bpy.ops.object.vertex_group_set_active(group=groupName) # Select the verts bpy.ops.object.vertex_group_select() bpy.ops.object.vertex_group_assign() bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.delete(type='VERT') bpy.ops.object.mode_set(mode = 'OBJECT') class MantemPintado(bpy.types.Operator): """Tooltip""" bl_idname = "object.mantem_pintado" bl_label = "MantemPintado" def execute(self, context): MantemPintadoDef(self, context) return {'FINISHED'} # Segmentação por pintura - Apaga Vermelho def ApagaPintadoDef(self, context): bpy.ops.object.mode_set(mode = 'OBJECT') bpy.context.object.name = "ObjSplint" # Seleciona área interesse # Which group to find? groupName = 'Group' # Use the active object obj = bpy.context.view_layer.objects.active # Make sure you're in edit mode bpy.ops.object.mode_set(mode='EDIT') # Deselect all verts bpy.ops.mesh.select_all(action='DESELECT') # Make sure the active group is the one we want bpy.ops.object.vertex_group_set_active(group=groupName) # Select the verts bpy.ops.object.vertex_group_select() bpy.ops.object.vertex_group_assign() # bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.delete(type='VERT') bpy.ops.object.mode_set(mode = 'OBJECT') class ApagaPintado(bpy.types.Operator): """Tooltip""" bl_idname = "object.apaga_pintado" bl_label = "ApagaPintado" def execute(self, context): ApagaPintadoDef(self, context) return {'FINISHED'} # SEGMENTA DESENHO def SegmentaDesenhoDef(self, context): context = bpy.context obj = context.active_object scn = context.scene #bpy.ops.gpencil.convert(type='POLY') #bpy.ops.gpencil.convert(type='POLY', use_normalize_weights=True, radius_multiplier=1.0, use_link_strokes=False, timing_mode='FULL', frame_range=100, start_frame=1, use_realtime=False, end_frame=250, gap_duration=0.0, gap_randomness=0.0, seed=0, use_timing_data=False) # Desenha bpy.ops.gpencil.convert_old_files() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.convert(type='POLY', use_timing_data=True) # Seleciona linha e converte em mesh bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['Note'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['Note'] bpy.ops.object.convert(target='MESH') # bpy.ops.gpencil.layer_remove() # bpy.ops.object.editmode_toggle() # bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.select_all(action='DESELECT') linha.select_set(True) obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode='EDIT') # bpy.ops.object.editmode_toggle() mesh=bmesh.from_edit_mesh(bpy.context.object.data) # for v in mesh.verts: for v in mesh.verts and mesh.faces: #print(v) v.select = True # v.select = True bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active # Atualiza viewport # bpy.ops.mesh.flip_normals() # Inverter para funcionar o Knife fora a fora bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.mesh.select_mode(type='FACE') bpy.ops.mesh.knife_project(cut_through=True) # CUIDADO! Seleciona apenas a parte de trás # bpy.context.scene.objects.active = bpy.context.scene.objects.active bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.separate(type='SELECTED') # bpy.ops.mesh.delete(type='FACE') bpy.ops.mesh.select_all(action = 'SELECT') # bpy.ops.mesh.flip_normals() bpy.ops.mesh.select_mode(type='VERT') bpy.ops.object.editmode_toggle() bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['GP_Scene'].select_set(True) bpy.ops.object.delete() bpy.data.objects['Note'].select_set(True) # bpy.context.object.name = "Cut_Line" bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['Note'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['Note'] bpy.context.object.name = "Cutline_to_Delete" bpy.ops.wm.tool_set_by_id(name="builtin.select_box") # bpy.ops.object.delete() class SegmentaDesenho(bpy.types.Operator): """Tooltip""" bl_idname = "object.segmenta_desenho" bl_label = "Segmenta Desenho" def execute(self, context): SegmentaDesenhoDef(self, context) return {'FINISHED'} def DesenhaBooleanaDentroDef(self, context): context = bpy.context objOrigi = context.active_object scn = context.scene #bpy.ops.gpencil.convert(type='POLY') #bpy.ops.gpencil.convert(type='POLY', use_normalize_weights=True, radius_multiplier=1.0, use_link_strokes=False, timing_mode='FULL', frame_range=100, start_frame=1, use_realtime=False, end_frame=250, gap_duration=0.0, gap_randomness=0.0, seed=0, use_timing_data=False) # Centraliza no selecionado # bpy.ops.view3d.snap_cursor_to_selected() # Desenha bpy.ops.gpencil.convert_old_files() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.convert(type='POLY', use_timing_data=True) # Seleciona linha e converte em mesh bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['Note'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['Note'] bpy.ops.object.convert(target='MESH') bpy.context.object.name = "BoolCorte" # EXTRUSÃO # bpy.ops.view3d.snap_cursor_to_selected() # NAO USAR SENAÔ MUDA O CENTER!!! bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.edge_face_add() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":300, "use_even_offset":False, "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":False, "use_accurate":False}) bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.edge_face_add() # bpy.ops.mesh.fill() bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":300, "use_even_offset":False, "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":False, "use_accurate":False}) bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.flip_normals() bpy.ops.object.mode_set(mode = 'OBJECT') objBool = context.active_object objOrigi.select_set(True) objBool.select_set(True) bpy.context.view_layer.objects.active = objBool bpy.ops.object.booleana_osteo_geral() bpy.ops.wm.tool_set_by_id(name="builtin.select_box") ''' # bpy.ops.gpencil.layer_remove() # bpy.ops.object.editmode_toggle() # bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.select_all(action='DESELECT') linha.select_set(True) obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode='EDIT') # bpy.ops.object.editmode_toggle() mesh=bmesh.from_edit_mesh(bpy.context.object.data) # for v in mesh.verts: for v in mesh.verts and mesh.faces: #print(v) v.select = True # v.select = True bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active # Atualiza viewport # bpy.ops.mesh.flip_normals() # Inverter para funcionar o Knife fora a fora bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.mesh.select_mode(type='FACE') bpy.ops.mesh.knife_project(cut_through=True) # CUIDADO! Seleciona apenas a parte de trás # bpy.context.scene.objects.active = bpy.context.scene.objects.active bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.separate(type='SELECTED') # bpy.ops.mesh.delete(type='FACE') bpy.ops.mesh.select_all(action = 'SELECT') # bpy.ops.mesh.flip_normals() bpy.ops.object.editmode_toggle() bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['GP_Scene'].select_set(True) bpy.ops.object.delete() bpy.data.objects['Note'].select_set(True) bpy.context.object.name = "Cut_Line" # bpy.ops.object.delete() ''' class DesenhaBooleanaDentro(bpy.types.Operator): """Tooltip""" bl_idname = "object.desenha_booleana_dentro" bl_label = "Segmenta Desenho" def execute(self, context): DesenhaBooleanaDentroDef(self, context) return {'FINISHED'} bpy.utils.register_class(DesenhaBooleanaDentro) def DesenhaBooleanaForaDef(self, context): context = bpy.context objOrigi = context.active_object scn = context.scene #bpy.ops.gpencil.convert(type='POLY') #bpy.ops.gpencil.convert(type='POLY', use_normalize_weights=True, radius_multiplier=1.0, use_link_strokes=False, timing_mode='FULL', frame_range=100, start_frame=1, use_realtime=False, end_frame=250, gap_duration=0.0, gap_randomness=0.0, seed=0, use_timing_data=False) # Centraliza no selecionado # bpy.ops.view3d.snap_cursor_to_selected() # Desenha bpy.ops.gpencil.convert_old_files() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.paintmode_toggle() bpy.ops.gpencil.convert(type='POLY', use_timing_data=True) # Seleciona linha e converte em mesh bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['Note'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['Note'] bpy.ops.object.convert(target='MESH') bpy.context.object.name = "BoolCorte" # EXTRUSÃO # bpy.ops.view3d.snap_cursor_to_selected() # NAO USAR SENAÔ MUDA O CENTER!!! bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.edge_face_add() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":300, "use_even_offset":False, "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":False, "use_accurate":False}) bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.edge_face_add() # bpy.ops.mesh.fill() bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":300, "use_even_offset":False, "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":False, "use_accurate":False}) bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.flip_normals() bpy.ops.object.mode_set(mode = 'OBJECT') objBool = context.active_object objOrigi.select_set(True) objBool.select_set(True) bpy.context.view_layer.objects.active = objBool bpy.ops.object.booleana_osteo_inter() bpy.ops.wm.tool_set_by_id(name="builtin.select_box") ''' # bpy.ops.gpencil.layer_remove() # bpy.ops.object.editmode_toggle() # bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.select_all(action='DESELECT') linha.select_set(True) obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode='EDIT') # bpy.ops.object.editmode_toggle() mesh=bmesh.from_edit_mesh(bpy.context.object.data) # for v in mesh.verts: for v in mesh.verts and mesh.faces: #print(v) v.select = True # v.select = True bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active # Atualiza viewport # bpy.ops.mesh.flip_normals() # Inverter para funcionar o Knife fora a fora bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.mesh.select_mode(type='FACE') bpy.ops.mesh.knife_project(cut_through=True) # CUIDADO! Seleciona apenas a parte de trás # bpy.context.scene.objects.active = bpy.context.scene.objects.active bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.separate(type='SELECTED') # bpy.ops.mesh.delete(type='FACE') bpy.ops.mesh.select_all(action = 'SELECT') # bpy.ops.mesh.flip_normals() bpy.ops.object.editmode_toggle() bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['GP_Scene'].select_set(True) bpy.ops.object.delete() bpy.data.objects['Note'].select_set(True) bpy.context.object.name = "Cut_Line" # bpy.ops.object.delete() ''' class DesenhaBooleanaFora(bpy.types.Operator): """Tooltip""" bl_idname = "object.desenha_booleana_fora" bl_label = "Segmenta Desenho Fora" def execute(self, context): DesenhaBooleanaForaDef(self, context) return {'FINISHED'} bpy.utils.register_class(DesenhaBooleanaFora) # Segmenta mandíbula import bpy import platform def ImportaSeparaMandibulaDef(self, context): context = bpy.context obj = context.active_object scn = context.scene if platform.system() == "Linux": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Collection\\" object = "Separa_Mandibula" if platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Collection\\" object = "Separa_Mandibula" if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Collection\\" object = "Separa_Mandibula" # if platform.system() == "Darwin": # dirScript = bpy.utils.user_resource('SCRIPTS') # blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" # section = "\\Group\\" # object = "SPLINT" filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) #ImportaSeparaMandibulaDef() class ImportaSeparaMandibula(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_separa_mandibula" bl_label = "Importa Separa Mandíbula" def execute(self, context): ImportaSeparaMandibulaDef(self, context) return {'FINISHED'} bpy.utils.register_class(ImportaSeparaMandibula) def MovePara(objOrigem, objMove): ObjetoOrigem = bpy.data.objects[objOrigem] ObjetoMove = bpy.data.objects[objMove] # bpy.ops.object.select_all(action='DESELECT') # ObjetoMove.select_set(True) # context.view_layer.objects.active = ObjetoMove ObjetoMove.location[0] = ObjetoOrigem.location[0] ObjetoMove.location[1] = ObjetoOrigem.location[1] ObjetoMove.location[2] = ObjetoOrigem.location[2] def AjustaMandibula(): MovePara("Condylar Process left", "EMP_Proc_Cond_esq") MovePara("Condylar Process right", "EMP_Proc_Cond_dir") MovePara("Coronoid Process left", "EMP_Proc_Cor_esq") MovePara("Coronoid Process right", "EMP_Proc_Cor_dir") MovePara("Mid Go-Ramus Fracure left", "EMP_Ang_Mand_esq") MovePara("Mid Go-Ramus Fracure right", "EMP_Ang_Mand_dir") MovePara("Go left", "EMP_Gon_esq") MovePara("Go right", "EMP_Gon_dir") MovePara("Mid Mandibula Angle left", "EMP_Meio_Mand_esq") MovePara("Mid Mandibula Angle right", "EMP_Meio_Mand_dir") MovePara("Gn point", "EMP_Protuberancia_down") MovePara("B point", "EMP_Protuberancia") MovePara("Mid Upper Incisors", "EMP_Protuberancia_up") def BooleanSeparaMandibula(): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.select_all(action='DESELECT') MandibulaBase = bpy.data.objects['MandibulaBase'] MandibulaBase.select_set(True) bpy.context.view_layer.objects.active = MandibulaBase obj = context.active_object bpy.ops.object.collection_link(collection='Collection') bpy.ops.object.select_all(action='DESELECT') Cranio = bpy.data.objects['Bones'] MandibulaBase = bpy.data.objects['MandibulaBase'] Cranio.select_set(True) MandibulaBase.select_set(True) bpy.context.view_layer.objects.active = MandibulaBase bpy.ops.object.booleana_osteo_inter() bpy.ops.object.select_all(action='DESELECT') ListaObjetos = ['EMP_Proc_Cor_dir', 'EMP_Proc_Cond_dir', 'EMP_Proc_Cor_esq', 'EMP_Proc_Cond_esq', 'EMP_Gon_dir', 'EMP_Ang_Mand_dir', 'EMP_Gon_esq', 'EMP_Ang_Mand_esq', 'EMP_Meio_Mand_esq', 'EMP_Meio_Mand_dir', 'EMP_Protuberancia_down', 'EMP_Protuberancia', 'EMP_Protuberancia_up', 'ArmatureMandibula', 'Condylar Process right', 'Coronoid Process right', 'Condylar Process left', 'Coronoid Process left', 'Mid Go-Ramus Fracure right', 'Go right', 'Mid Go-Ramus Fracure left', 'Go left', 'Mid Mandibula Angle right', 'Mid Mandibula Angle left', 'Gn point', 'B point', 'Mid Upper Incisors'] for i in ListaObjetos: bpy.data.objects[i].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[i] bpy.ops.object.delete(use_global=False) # Traz para Collection bpy.ops.object.select_all(action='DESELECT') Cranio.select_set(True) bpy.context.view_layer.objects.active = Cranio bpy.ops.object.collection_link(collection='Collection') Cranio.hide_viewport=False try: bpy.context.object.active_material.diffuse_color = (0.8, 0.684753, 0.470028, 0.5) except: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MaterialSkull") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.8, 0.684753, 0.470028, 0.5) #change color bpy.ops.object.select_all(action='DESELECT') try: objAct = bpy.data.objects["Result.001"] objAct.select_set(True) bpy.context.view_layer.objects.active = objAct except: objAct = bpy.data.objects["Result"] objAct.select_set(True) bpy.context.view_layer.objects.active = objAct class SeparacaoMandibula(bpy.types.Operator): """Tooltip""" bl_idname = "object.separacao_mandibula" bl_label = "Importa Separa Mandíbula" def execute(self, context): ImportaSeparaMandibulaDef(self, context) AjustaMandibula() BooleanSeparaMandibula() # bpy.ops.wm.tool_set_by_id(name="builtin.select_box") return {'FINISHED'} bpy.utils.register_class(SeparacaoMandibula) def SeparaMandibulaCranioDef(): bpy.ops.object.duplicate() bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action='SELECT') bpy.ops.transform.shrink_fatten(value=-0.35, use_even_offset=False, mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 8 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh") context = bpy.context Mandibula = context.active_object scn = context.scene bpy.ops.object.select_all(action='DESELECT') Cranio = bpy.data.objects['Bones'] Cranio.select_set(True) Mandibula.select_set(True) bpy.context.view_layer.objects.active = Mandibula bpy.ops.object.booleana_osteo_geral() class SeparaMandibulaCranio(bpy.types.Operator): """Tooltip""" bl_idname = "object.separacao_mandibula_cranio" bl_label = "Importa Separa Mandíbula Crânio" def execute(self, context): SeparaMandibulaCranioDef() return {'FINISHED'} bpy.utils.register_class(SeparaMandibulaCranio) class PreparaImpressao3D(bpy.types.Operator): """Tooltip""" bl_idname = "object.prepara_impressao_3d" bl_label = "Prepara Impressão 3D" def execute(self, context): bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 8 bpy.context.object.modifiers["Remesh"].scale = 0.99 return {'FINISHED'} bpy.utils.register_class(PreparaImpressao3D) def FecharBuracosTodosDef(): bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_non_manifold() bpy.ops.mesh.remove_doubles(threshold=0.2) bpy.ops.mesh.edge_face_add() bpy.ops.object.mode_set(mode='OBJECT') class FecharBuracosTodos(bpy.types.Operator): """Tooltip""" bl_idname = "object.fecha_buraco_todos" bl_label = "Prepara Impressão 3D" def execute(self, context): FecharBuracosTodosDef() return {'FINISHED'} bpy.utils.register_class(FecharBuracosTodos) def SeparaObjetoDef(): bpy.ops.mesh.select_mode(type="FACE") bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.separate(type='SELECTED') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.object.mode_set(mode='OBJECT') objSel = bpy.context.view_layer.objects.active bpy.ops.object.select_all(action='DESELECT') objSel.select_set(True) bpy.context.view_layer.objects.active = objSel class SeparaObjeto(bpy.types.Operator): """Tooltip""" bl_idname = "object.separa_objeto" bl_label = "Separa Ojeto" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects if bpy.context.active_object.mode == 'EDIT': return True else: if bpy.context.active_object.mode == 'OBJECT': return False def execute(self, context): SeparaObjetoDef() return {'FINISHED'} bpy.utils.register_class(SeparaObjeto) # SEGMENTA MICROSCÓPIO def SegmentaDesenhoMicrosDef(self, context): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.select_all(action='DESELECT') linha = bpy.data.objects['myCurve'] linha.select_set(True) # linha = bpy.context.view_layer.objects.active bpy.context.view_layer.objects.active = bpy.data.objects['myCurve'] bpy.ops.object.convert(target='MESH') # bpy.ops.gpencil.layer_remove() # bpy.ops.object.editmode_toggle() # bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.select_all(action='DESELECT') linha.select_set(True) obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode='EDIT') # bpy.ops.object.editmode_toggle() mesh=bmesh.from_edit_mesh(bpy.context.object.data) # for v in mesh.verts: for v in mesh.verts and mesh.faces: #print(v) v.select = True # v.select = True bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active # Atualiza viewport # bpy.ops.mesh.flip_normals() # Inverter para funcionar o Knife fora a fora bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.mesh.select_mode(type='FACE') bpy.ops.mesh.knife_project(cut_through=True) # CUIDADO! Seleciona apenas a parte de trás # bpy.context.scene.objects.active = bpy.context.scene.objects.active bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active bpy.ops.mesh.select_all(action='INVERT') bpy.ops.mesh.separate(type='SELECTED') # bpy.ops.mesh.delete(type='FACE') # Não é bom pois o usuário pode não querer apagar tudo # bpy.ops.mesh.select_all(action = 'SELECT') # bpy.ops.mesh.flip_normals() bpy.ops.mesh.select_mode(type='VERT') bpy.ops.object.editmode_toggle() bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['myCurve'].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects['myCurve'] #bpy.context.object.name = "Cutline_to_Delete" bpy.ops.object.delete(use_global=False) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.wm.tool_set_by_id(name="builtin.select_box") # bpy.ops.object.delete() class SegmentaDesenhoMicros(bpy.types.Operator): """Tooltip""" bl_idname = "object.segmenta_desenho_micros" bl_label = "Segmenta Desenho" def execute(self, context): SegmentaDesenhoMicrosDef(self, context) return {'FINISHED'} bpy.utils.register_class(SegmentaDesenhoMicros) ================================================ FILE: ForensicOnBlender.py ================================================ import bpy import platform from .__init__ import * from .ForensicTools import * from .Version import * class FORENSIC_PT_AtualizaAddonSec(bpy.types.Panel): bl_label = "Upgrade Script" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="VERSION: "+VERSION) row = layout.row() row.operator("object.atualiza_script", text="UPGRADE FORENSIC!", icon="RECOVER_LAST") bpy.utils.register_class(FORENSIC_PT_AtualizaAddonSec) class FORENSIC_PT_NomeReconstrucao(bpy.types.Panel): bl_label = "Reconstruction Data" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render # row = layout.row() # row.label(text="CT-Scan Reconstruction:") # col = layout.column(align=True) # col.prop(scn.my_tool, "path", text="") row = layout.row() # row.operator("object.tomo_heli", text="CT-Scan") # row.operator("object.tomo_cone", text="CBCT") col = self.layout.column(align = True) col.prop(context.scene, "nome_paciente") col = self.layout.column(align = True) col.prop(context.scene, "sobrenome_paciente") box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(FORENSIC_PT_NomeReconstrucao) class FORENSIC_PT_Fotogrametria(bpy.types.Panel): bl_label = "Photogrammetry Start" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="OpenMVG+OpenMVS:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") col = self.layout.column(align = True) col.alignment = 'RIGHT' col.prop(context.scene, "d_factorForensic") col.prop(context.scene, "smooth_factorForensic") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.gera_modelo_foto", text="Start Photogrammetry!", icon="IMAGE_DATA") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_fotogram", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(FORENSIC_PT_Fotogrametria) bpy.types.Scene.d_factorForensic = bpy.props.StringProperty \ ( name = "D FactorForensic", description = "D FactorForensic", default = "5" ) bpy.types.Scene.smooth_factorForensic = bpy.props.StringProperty \ ( name = "Smooth Factor", description = "Smooth Factor", default = "5" ) class FORENSIC_PT_AlinhaFace(bpy.types.Panel): bl_label = "Photogrammetry - Align & Scale" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Align Points:") row = layout.row() linha=row.operator("object.emp1b", text="Point A", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp2b", text="Point B", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp3b", text="Align Point", icon="SORTBYEXT") # row = layout.row() # row.operator("object.cria_tres_pontos", text="3 Points Click", icon="OUTLINER_OB_MESH") row = self.layout.row(align = True) row.label(text="Distance A<>B:") row.prop(context.scene, "medida_real2") row = layout.row() row.operator("object.alinha_forca", text="Align and Resize!", icon="ORIENTATION_LOCAL") row = layout.row() row = layout.row() row.label(text="Segmentation Cut Through:") row = layout.row() row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row = layout.row() linha=row.operator("object.segmenta_desenho", text="Cut Draw!", icon="FCURVE") row = layout.row() row = layout.row() row.label(text="Surface Cut:") row = layout.row() row.operator("wm.modal_cria_pontos", icon='CURVE_DATA', text="Create Points") row = layout.row() row.operator("mesh.add_curva_bezier_unido", icon='CURVE_BEZCIRCLE', text="Create Bezier Line") row = layout.row() circle=row.operator("object.bezier_corta", text="Cut Line!", icon="SCULPTMODE_HLT") row = layout.row() circle=row.operator("object.bezier_corta_dupla", text="Cut Line Double!", icon="MOD_THICKNESS") row = layout.row() row.label(text="Frankfurt Alignment:") row = layout.row() row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() circle=row.operator("object.renomeia_cranio", text="RENAME TO Bones!", icon="BONE_DATA") row = layout.row() row = layout.row() linha=row.operator("object.orbital_right_pt", text="Orbital right") linha=row.operator("object.orbital_left_pt", text="Orbital left") row = layout.row() linha=row.operator("object.n_pt", text="N point") linha=row.operator("object.po_left", text="Po left") row = layout.row() row.operator("object.alinha_cranio_frankfurt", text="Align!", icon="ORIENTATION_LOCAL") row = layout.row() row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_alinha_face", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(FORENSIC_PT_AlinhaFace) class FORENSIC_PT_ColocaMarcadores(bpy.types.Panel): bl_label = "Soft Tissue Markers" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" row = layout.row() row = layout.row() row.label(text="Create Custom Marker:") col = self.layout.column(align = True) col.prop(context.scene, "nome_marcador") col = self.layout.column(align = True) col.prop(context.scene, "dimensao_marcador") row = layout.row() linha=row.operator("object.adiciona_marcador", text="Create Marker", icon="EMPTY_SINGLE_ARROW") row = layout.row() row = layout.row() row = layout.row() row = layout.row() row.label(text="Import CSV Sheet:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathcsv", text="") row = layout.row() linha=row.operator("object.forensic_cria_botoes", text="Generate Soft Tissue Markers!", icon="EMPTY_SINGLE_ARROW") row = layout.row() row = layout.row() linha=row.operator("object.oculta_nomes", text="Hide Names", icon="HIDE_ON") row = layout.row() linha=row.operator("mesh.add_linhabase", text="Vertical Center Line", icon="SORT_DESC") linha.location=(0,-200,0) row = layout.row() linha=row.operator("object.engrossa_linha", text="Make Tube Line", icon="OUTLINER_OB_CURVE") row = layout.row() linha=row.operator("object.forensic_importa_luzes", text="ILLUMINATE!", icon="LIGHT_DATA") row = layout.row() row.label(text="1) Please select the skull.") row = layout.row() row.label(text="2) So, click on Skull Material Adjustment.") row = layout.row() linha=row.operator("object.ajusta_material_cranio", text="Skull Material Adjustment", icon="OUTLINER_OB_CURVE") row = layout.row() linha=row.operator("object.forensic_importa_olho", text="Import Eye", icon="HIDE_OFF") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_markers", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(FORENSIC_PT_ColocaMarcadores) bpy.types.Scene.nome_marcador = bpy.props.StringProperty \ ( name = "Name", description = "Object Size", default = "Marker" ) bpy.types.Scene.dimensao_marcador = bpy.props.StringProperty \ ( name = "Size", description = "Object Size", default = "None" ) class FORENSIC_PT_Musculos(bpy.types.Panel): bl_label = "Muscles" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() linha=row.operator("object.forensic_importa_temporalis", text="Temporalis") row = layout.row() linha=row.operator("object.forensic_importa_masseter", text="Masseter") row = layout.row() linha=row.operator("object.forensic_importa_orbicularis_oculi", text="Orbicularis Oculi") row = layout.row() linha=row.operator("object.forensic_importa_elevator_labii_superioris", text="Elevator Labii Superioris") row = layout.row() linha=row.operator("object.forensic_importa_nasalis", text="Nasalis") row = layout.row() linha=row.operator("object.forensic_importa_zygomaticus", text="Zygomaticus") row = layout.row() linha=row.operator("object.forensic_importa_orbicularis_oris", text="Orbicularis Oris") row = layout.row() linha=row.operator("object.forensic_importa_buccinator", text="Buccinator") row = layout.row() linha=row.operator("object.forensic_importa_mentalis", text="Mentalis+") row = layout.row() linha=row.operator("object.forensic_importa_sternocleidomastoid", text="Sternocleidomastoid+") row = layout.row() row.label(text="Deform Muscle:") row = layout.row() linha=row.operator("object.forensic_escultura_grab", text="Grab", icon="BRUSH_GRAB") row = layout.row() linha=row.operator("object.forensic_escultura_smooth", text="Smooth", icon="BRUSH_SMOOTH") row = layout.row() linha=row.operator("object.forensic_escultura_clay_strips", text="Clay Strips", icon="BRUSH_CLAY_STRIPS") row = layout.row() linha=row.operator("object.mode_set", text="OK! (Object Mode)", icon="META_CUBE").mode='OBJECT' row = layout.row() linha=row.operator("object.forensic_copia_espelha", text="Copy & Mirror", icon="MOD_TRIANGULATE") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_muscles", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(FORENSIC_PT_Musculos) class FORENSIC_PT_FaceBasica(bpy.types.Panel): bl_label = "Basic Face Sculpt" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="1) Put all structure in the origin of scene.") row = layout.row() row.label(text="2) Select all interest muscules.") row = layout.row() row.label(text="3) Create Basic Shape!") row = layout.row() linha=row.operator("object.forensic_cria_face_basica", text="Create Basic Shape!", icon="MESH_ICOSPHERE") row = layout.row() row.label(text="Sculpture:") row = layout.row() linha=row.operator("object.forensic_escultura_grab", text="Grab", icon="BRUSH_GRAB") row = layout.row() linha=row.operator("object.forensic_escultura_smooth", text="Smooth", icon="BRUSH_SMOOTH") row = layout.row() linha=row.operator("object.forensic_escultura_clay_strips", text="Clay Strips", icon="BRUSH_CLAY_STRIPS") row = layout.row() linha=row.operator("object.mode_set", text="OK! (Object Mode)", icon="META_CUBE").mode='OBJECT' row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_sculpt", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(FORENSIC_PT_FaceBasica) class FORENSIC_PT_Importa(bpy.types.Panel): bl_label = "Import Face" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Forensic" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.operator("object.forensic_gera_imagem", text="Render Viewport", icon="IMAGE_RGB_ALPHA") row = layout.row() row.label(text="Import OBJ:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathobj", text="") row = layout.row() row.operator("object.forensic_importa_obj", text="Import MakeHuman OBJ", icon="SCENE_DATA") bpy.utils.register_class(FORENSIC_PT_Importa) ================================================ FILE: ForensicTools.py ================================================ import bpy import re import platform import subprocess import tempfile from datetime import datetime from .PontosAnatomicos import * from .FerrImgTomo import * def AdicionaMarcadorDef(nome, distancia): bpy.ops.object.empty_add(type='SINGLE_ARROW', view_align=False) bpy.context.object.empty_display_size = distancia bpy.context.object.name = nome context = bpy.context obj = context.object scn = context.scene Marcador_EMP = obj # Marcador_EMP.select_set(True) # bpy.context.view_layer.objects.active = Marcador_EMP Marcador_EMP.location = bpy.context.scene.cursor.location Marcador_EMP.rotation_euler = bpy.context.scene.cursor.rotation_euler # bpy.context.scene.tool_settings.snap_elements = {'FACE'} # bpy.context.scene.tool_settings.use_snap_align_rotation = True # bpy.ops.wm.tool_set_by_id(name="builtin.rotate") # bpy.context.scene.transform_orientation_slots[0].type = 'NORMAL' # bpy.ops.view3d.view_selected(use_all_regions=False) # bpy.ops.view3d.view_center_cursor() class AdicionaMarcador(bpy.types.Operator): """Tooltip""" bl_idname = "object.adiciona_marcador" bl_label = "Add Soft Tissue Marker" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): NomePonto = bpy.context.scene.nome_marcador DistPonto = float(bpy.context.scene.dimensao_marcador) AdicionaMarcadorDef(NomePonto, DistPonto) return {'FINISHED'} bpy.utils.register_class(AdicionaMarcador) #----------------------------------- # Cria Botões Marcadores Tecido mole ''' with open('/home/linux3dcs/prj/Arc-Team_Santo/planilha.csv', 'r') as f: fileLines = f.readlines() for i in range(len(fileLines)): limpaFinalLinha = fileLines[i].strip() separa = limpaFinalLinha.split(',') print(separa) ''' def CriaBotoesDef(): context = bpy.context #obj = context.object scn = context.scene bpy.context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT' # Tem que estar assim senão o alinhamento dá errado! # with open('/home/linux3dcs/prj/Arc-Team_Santo/planilha.csv', 'r') as f: with open(scn.my_tool.filepathcsv, 'r') as f: fileLines = f.readlines() posicaoZ = 0 # Se vier do Excel if fnmatch.fnmatchcase(fileLines[0], '*;*'): separador = ";" # Se vier do LibreOffile if not fnmatch.fnmatchcase(fileLines[0], '*;*'): separador = "," # Se o arquivo tiver medidas com vírgula arquivoNovo = [] tmpdirCSV = tempfile.mkdtemp() if fnmatch.fnmatchcase(fileLines[0], '*\"*'): with open(tmpdirCSV+'/teste.csv', "a") as arq: for i in fileLines: linha = i.split("\"") valor1 = linha[0] valor2 = linha[1].replace(',','.') valor3 = '\n' linhaCompleta = valor1+valor2+valor3 #print(valor1,valor2,valor3) arq.write(linhaCompleta) arq.close() with open(tmpdirCSV+'/teste.csv', 'r') as f: fileLines = f.readlines() print(fileLines) Mk_Numero = len(fileLines) # Conta o número de itens, pois está invertido. for i in range(len(fileLines))[::-1]: limpaFinalLinha = fileLines[i].strip() separa = limpaFinalLinha.split(separador) #print(separa) # Cria def do botão Nome = str(Mk_Numero)+" "+separa[0] NomeClass = Nome.replace(" ", "") NomeMin = "object."+Nome.lower().replace(" ", "_") bpy.ops.object.empty_add(type='SINGLE_ARROW', view_align=False, location=(-150, 0, posicaoZ)) bpy.context.object.name = Nome bpy.context.object.empty_display_size = float(separa[1]) bpy.context.object.show_name = True bpy.ops.transform.rotate(value=1.5708, orient_axis='Y') posicaoZ += 10 Mk_Numero -= 1 # ENVIA COLLECTION obj2 = bpy.context.view_layer.objects.active ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Soft Tissue Markers" not in ListaColl: myCol = bpy.data.collections.new("Soft Tissue Markers") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Soft Tissue Markers') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Soft Tissue Markers') # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) bpy.context.scene.tool_settings.snap_elements = {'FACE'} bpy.context.scene.tool_settings.use_snap_align_rotation = True class CriaBotoes(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_cria_botoes" bl_label = "Cria Botões" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaBotoesDef() return {'FINISHED'} bpy.utils.register_class(CriaBotoes) def OcultaNomesDef(): context = bpy.context #obj = context.object scn = context.scene for i in bpy.context.selected_objects: i.show_name = False class OcultaNomes(bpy.types.Operator): """Tooltip""" bl_idname = "object.oculta_nomes" bl_label = "Hide Names" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): OcultaNomesDef() return {'FINISHED'} bpy.utils.register_class(OcultaNomes) def EngrossaLinhaDef(): context = bpy.context #obj = context.object scn = context.scene bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.convert(target='CURVE') bpy.context.object.data.bevel_depth = 0.84 class EngrossaLinha(bpy.types.Operator): """Tooltip""" bl_idname = "object.engrossa_linha" bl_label = "Make Tube Line" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): EngrossaLinhaDef() return {'FINISHED'} bpy.utils.register_class( EngrossaLinha) def ForensicImportaMuscleDef(nome, colecao): context = bpy.context obj = context.active_object scn = context.scene try: bpy.ops.object.mode_set(mode='OBJECT') except: print("Erro com o Object Mode!") if platform.system() == "Linux": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/ForensicObj.blend" # section = "\\Collection\\" # object = "SPLINT" section = "\\Object\\" object = nome if platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/ForensicObj.blend" section = "\\Object\\" object = nome if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/ForensicObj.blend" section = "\\Object\\" object = nome filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) ObjImportado = bpy.data.objects[nome] bpy.ops.object.select_all(action='DESELECT') ObjImportado.select_set(True) context.view_layer.objects.active = ObjImportado # Coloca na camada obj2 = bpy.context.view_layer.objects.active ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if colecao not in ListaColl: myCol = bpy.data.collections.new(colecao) bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection=colecao) # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) else: bpy.ops.object.collection_link(collection=colecao) # mainCol = bpy.data.collections['Collection'] # bpy.context.scene.collection.children.unlink(mainCol) bpy.data.collections['Collection'].objects.unlink(obj2) class ForensicImportaTemporalis(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_temporalis" bl_label = "Import Temporalis" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Temporalis' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Temporalis", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaTemporalis) class ForensicImportaMasseter(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_masseter" bl_label = "Import Masseter" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Masseter' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Masseter", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaMasseter) class ForensicImportaOrbicularisOculi(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_orbicularis_oculi" bl_label = "Import Orbicularis Oculi" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Orbicularis Oculi' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Orbicularis Oculi", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaOrbicularisOculi) class ForensicImportaElevatorLabiiSuperioris(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_elevator_labii_superioris" bl_label = "Import Elevator Labii Superioris" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Elevator Labii Superioris' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Elevator Labii Superioris", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaElevatorLabiiSuperioris) class ForensicImportaNasalis(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_nasalis" bl_label = "Import Nasalis" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Nasalis' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Nasalis", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaNasalis) class ForensicImportaZygomaticus(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_zygomaticus" bl_label = "Import Zygomaticus" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Zygomaticus' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Zygomaticus", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaZygomaticus) class ForensicImportaOrbicularisOris(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_orbicularis_oris" bl_label = "Import Orbicularis Oris" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Orbicularis Oris' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Orbicularis Oris", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaOrbicularisOris) class ForensicImportaBuccinator(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_buccinator" bl_label = "Import Buccinator" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Buccinator' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Buccinator", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaBuccinator) class ForensicImportaMentalis(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_mentalis" bl_label = "Import Mentalis" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mentalis+' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Mentalis+", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaMentalis) class ForensicImportaSternocleidomastoid(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_sternocleidomastoid" bl_label = "Import Sternocleidomastoid" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Sternocleidomastoid+' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Sternocleidomastoid+", "Muscle") return {'FINISHED'} bpy.utils.register_class(ForensicImportaSternocleidomastoid) class ForensicImportaOlho(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_olho" bl_label = "Import Eye" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Eye' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("Eye", "Eyes") return {'FINISHED'} bpy.utils.register_class(ForensicImportaOlho) def CopiaEspelhaDef(): context = bpy.context obj = context.active_object scn = context.scene bpy.ops.object.transform_apply(location=False, rotation=True, scale=False) bpy.ops.object.mode_set(mode='OBJECT') bpy.context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT' bpy.ops.object.duplicate_move() bpy.ops.transform.mirror(orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) class CopiaEspelha(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_copia_espelha" bl_label = "Copy and Mirror" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CopiaEspelhaDef() return {'FINISHED'} bpy.utils.register_class(CopiaEspelha) def ForensicEsculturaGrabDef(): context = bpy.context scn = context.scene # bpy.context.space_data.shading.type = 'MATERIAL' bpy.ops.object.mode_set(mode = 'SCULPT') bpy.ops.wm.tool_set_by_id(name="builtin_brush.Grab") bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False class ForensicEsculturaGrab(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_escultura_grab" bl_label = "Change to Grab" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT' or bpy.context.mode == 'SCULPT': return True else: return False else: return False def execute(self, context): ForensicEsculturaGrabDef() return {'FINISHED'} bpy.utils.register_class(ForensicEsculturaGrab) def ForensicEsculturaClayStripsDef(): context = bpy.context scn = context.scene # bpy.context.space_data.shading.type = 'MATERIAL' bpy.ops.object.mode_set(mode = 'SCULPT') bpy.ops.wm.tool_set_by_id(name="builtin_brush.Clay Strips") bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False class ForensicEsculturaClayStrips(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_escultura_clay_strips" bl_label = "Change to Grab" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT' or bpy.context.mode == 'SCULPT': return True else: return False else: return False def execute(self, context): ForensicEsculturaClayStripsDef() return {'FINISHED'} bpy.utils.register_class(ForensicEsculturaClayStrips) def ForensicEsculturaSmoothDef(): context = bpy.context scn = context.scene # bpy.context.space_data.shading.type = 'MATERIAL' bpy.ops.object.mode_set(mode = 'SCULPT') bpy.ops.wm.tool_set_by_id(name="builtin_brush.Smooth") bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False class ForensicEsculturaSmooth(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_escultura_smooth" bl_label = "Change to Smooth" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT' or bpy.context.mode == 'SCULPT': return True else: return False else: return False def execute(self, context): ForensicEsculturaSmoothDef() return {'FINISHED'} bpy.utils.register_class(ForensicEsculturaSmooth) def GeraBaseSculptDef(): # Usuário seleciona tudo bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((0, 0, 0), (0, 0, 0), (0, 0, 0)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}) bpy.ops.object.join() bpy.context.object.name = "Muscles" # Adiciona esfera bpy.ops.mesh.primitive_uv_sphere_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0)) bpy.ops.transform.resize(value=(180, 180, 180), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=34.004) # Joga na colação Face Scupting obj2 = bpy.context.view_layer.objects.active ListaColl = [] for i in bpy.data.collections: ListaColl.append(i.name) if "Face Sculpting" not in ListaColl: myCol = bpy.data.collections.new("Face Sculpting") bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection='Face Sculpting') ColecaoAtual = bpy.context.collection ColecaoAtual.objects.unlink(obj2) else: bpy.ops.object.collection_link(collection='Face Sculpting') ColecaoAtual = bpy.context.collection ColecaoAtual.objects.unlink(obj2) bpy.ops.object.modifier_add(type='SHRINKWRAP') bpy.context.object.modifiers["Shrinkwrap"].target = bpy.data.objects["Muscles"] bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Shrinkwrap") # Sistema de Escultura #bpy.ops.object.mode_set(mode='SCULPT') bpy.ops.object.forensic_escultura_clay_strips() bpy.ops.sculpt.dynamic_topology_toggle() bpy.context.scene.tool_settings.sculpt.detail_size = 3 class GeraBaseSculpt(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_cria_face_basica" bl_label = "Create Basic Face Sculpting" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): GeraBaseSculptDef() return {'FINISHED'} bpy.utils.register_class(GeraBaseSculpt) class RenomeiaCranio(bpy.types.Operator): """Tooltip""" bl_idname = "object.renomeia_cranio" bl_label = "Rename Skull" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Bones' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): bpy.context.object.name = "Bones" return {'FINISHED'} bpy.utils.register_class(RenomeiaCranio) class ForensicImportaLuzes(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_luzes" bl_label = "Import Forensic Lights" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ForensicLight' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): ForensicImportaMuscleDef("ForensicLight", "Lights") ForensicImportaMuscleDef("ForensicLight.001", "Lights") ForensicImportaMuscleDef("ForensicLight.002", "Lights") ForensicImportaMuscleDef("ForensicLight.003", "Lights") ForensicImportaMuscleDef("ForensicLight.004", "Lights") bpy.context.scene.eevee.use_gtao = True bpy.context.scene.eevee.gtao_distance = 8 bpy.context.scene.eevee.use_gtao_bent_normals = False # bpy.context.scene.eevee.use_bloom = True # NÃO FICA BOM! bpy.context.scene.eevee.use_sss = True bpy.context.scene.eevee.use_ssr = True bpy.context.scene.eevee.use_ssr_refraction = True bpy.context.scene.eevee.ssr_thickness = 3 bpy.context.scene.render.hair_type = 'STRIP' bpy.context.scene.eevee.shadow_method = 'ESM' bpy.context.scene.eevee.shadow_cube_size = '512' bpy.context.scene.eevee.shadow_cascade_size = '512' bpy.context.scene.eevee.use_soft_shadows = True bpy.context.scene.eevee.light_threshold = 0.013 bpy.context.scene.view_settings.exposure = 0.2 bpy.context.space_data.shading.type = 'RENDERED' bpy.context.scene.render.engine = 'BLENDER_EEVEE' bpy.context.space_data.overlay.show_extras = False # Oculta gráficos das luzes return {'FINISHED'} bpy.utils.register_class(ForensicImportaLuzes) def CriaMaterialOssosDef(): context = bpy.context obj = context.object scn = context.scene Cranio = obj.name m = Material() # m.set_cycles() # from chapter 1 of [DRM protected book, could not copy author/title] m.make_material("Final_Bones") # image_path = TmpDirPNG+"/"+Arquivo ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') bpy.data.objects[Cranio].active_material_index = 0 MaterialPeleNativo = bpy.data.objects[Cranio].active_material NomeTextura = MaterialPeleNativo.node_tree.nodes['Image Texture'].image.name ImageTexture.image = bpy.data.images[NomeTextura] #ImageTexture.image = bpy.data.images["scene_dense_mesh_texture_material_0_map_Kd.jpg"] diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs["Base Color"].default_value = [0.2, 0.2, 0.2, 1] materialOutput = m.nodes['Material Output'] mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.dump_node(mixShader) mixShader.inputs['Fac'].default_value = 0.3 mixShader2 = m.makeNode('ShaderNodeMixShader', 'Mix Shader 2') mixShader2.inputs['Fac'].default_value = 0.015 sssShader = m.makeNode('ShaderNodeSubsurfaceScattering', 'Subsurface Scattering') sssShader.inputs[1].default_value = 20 glossyShader = m.makeNode('ShaderNodeBsdfGlossy', 'Glossy BSDF') glossyShader.inputs[1].default_value = .15 m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(sssShader, 'BSSRDF', mixShader, 1) m.link(glossyShader, 'BSDF', mixShader2, 2) m.link(mixShader, 'Shader', mixShader2, 1) m.link(mixShader2, 'Shader', materialOutput, 'Surface') m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') m.link(ImageTexture, 'Color', sssShader, 'Color') bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects["Bones"].active_material = bpy.data.materials["Final_Bones"] # bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["Final_Bones"] class CriaMaterialOssos(bpy.types.Operator): """Tooltip""" bl_idname = "object.ajusta_material_cranio" bl_label = "Skull Material Adjustament" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = bpy.data.objects["Bones"].active_material.name if found == "Final_Bones": return False else: if found != "Final_Bones": return True def execute(self, context): CriaMaterialOssosDef() return {'FINISHED'} bpy.utils.register_class(CriaMaterialOssos) def ForensicGeraImagemDef(): context = bpy.context scn = context.scene homeDir = expanduser("~") NomeArquivoImagem = "IMG_"+str(datetime.now()).replace(",","").replace(":","").replace(".","-").replace(" ","-")+".png" NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteDir = homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Render" # if found == False: if not os.path.exists(NomePacienteDir): print("Patience Dir does not exist!") try: os.mkdir(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Render") bpy.ops.render.opengl() bpy.data.images['Render Result'].save_render(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Render/"+NomeArquivoImagem) CaminhoCompletoImagem = homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Render/"+NomeArquivoImagem if platform.system() == 'Darwin': subprocess.call(('open', CaminhoCompletoImagem)) elif platform.system() == 'Windows': os.startfile(CaminhoCompletoImagem) else: subprocess.call(('xdg-open', CaminhoCompletoImagem)) except: print("Não rolou a renderização!") else: if os.path.exists(NomePacienteDir): #shutil.copytree(Origem, NomePacienteDir+"/Render") bpy.ops.render.opengl() bpy.data.images['Render Result'].save_render(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Render/"+NomeArquivoImagem) CaminhoCompletoImagem = homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Render/"+NomeArquivoImagem if platform.system() == 'Darwin': subprocess.call(('open', CaminhoCompletoImagem)) elif platform.system() == 'Windows': os.startfile(CaminhoCompletoImagem) else: subprocess.call(('xdg-open', CaminhoCompletoImagem)) class ForensicGeraImagem(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_gera_imagem" bl_label = "Forensic Render Image" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ForensicGeraImagemDef() return {'FINISHED'} bpy.utils.register_class(ForensicGeraImagem) def ForensicImportaOBJDef(): context = bpy.context obj = context.object scn = context.scene bpy.ops.import_scene.obj(filepath=scn.my_tool.filepathobj, filter_glob="*.obj;*.mtl", use_edges=True, use_smooth_groups=True, use_split_objects=True, use_split_groups=False, use_groups_as_vgroups=False, use_image_search=True, split_mode='ON', global_clight_size=0, axis_forward='-Z', axis_up='Y') bpy.ops.transform.resize(value=(101, 101, 101), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) if platform.system() == "Linux" or platform.system() == "Darwin": NomeOBJ = scn.my_tool.filepathobj.split("/")[-1].split(".")[0] # Separa o nome do objeto print("NOME HUMANO:", NomeOBJ) if platform.system() == "Windows": NomeOBJ = scn.my_tool.filepathobj.split("\\")[-1].split(".")[0] # Separa o nome do objeto print("NOME HUMANO:", NomeOBJ) bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[NomeOBJ].select_set(True) context.view_layer.objects.active = bpy.data.objects[NomeOBJ] bpy.ops.transform.translate(value=(0, 0, -1481.77), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) # Apaga olhos bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') ListaMaterial = [] for i in bpy.data.objects[NomeOBJ].material_slots: ListaMaterial.append(i.name) IndexMaterial = ListaMaterial.index('Eye_brown') bpy.data.objects[NomeOBJ].active_material_index = IndexMaterial bpy.ops.object.material_slot_select() bpy.ops.mesh.delete(type='VERT') bpy.ops.object.mode_set(mode='OBJECT') # Atribui modificadores bpy.ops.object.shade_smooth() bpy.ops.object.modifier_add(type='MULTIRES') bpy.ops.object.multires_subdivide(modifier="Multires") bpy.ops.view3d.view_all(center=False) # Criando material da pele bpy.data.objects[NomeOBJ].active_material_index = 0 MaterialPeleNativo = bpy.data.objects[NomeOBJ].active_material NomeTextura = MaterialPeleNativo.node_tree.nodes['Image Texture'].image.name m = Material() m.make_material("Final_Skin") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images[NomeTextura] diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs["Base Color"].default_value = [0.2, 0.2, 0.2, 1] materialOutput = m.nodes['Material Output'] mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.dump_node(mixShader) mixShader.inputs['Fac'].default_value = 0.3 mixShader2 = m.makeNode('ShaderNodeMixShader', 'Mix Shader 2') mixShader2.inputs['Fac'].default_value = 0.07 # Glossy sssShader = m.makeNode('ShaderNodeSubsurfaceScattering', 'Subsurface Scattering') sssShader.inputs[1].default_value = 20 glossyShader = m.makeNode('ShaderNodeBsdfGlossy', 'Glossy BSDF') glossyShader.inputs[1].default_value = .35 m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(sssShader, 'BSSRDF', mixShader, 1) m.link(glossyShader, 'BSDF', mixShader2, 2) m.link(mixShader, 'Shader', mixShader2, 1) m.link(mixShader2, 'Shader', materialOutput, 'Surface') m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') m.link(ImageTexture, 'Color', sssShader, 'Color') bpy.ops.object.material_slot_add() bpy.data.objects[NomeOBJ].active_material = bpy.data.materials["Final_Skin"] # Atribui material bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') bpy.data.objects[NomeOBJ].active_material_index = 0 bpy.ops.object.material_slot_select() ListaMaterial2 = [] for i in bpy.data.objects[NomeOBJ].material_slots: ListaMaterial2.append(i.name) IndexMaterial2 = ListaMaterial2.index('Final_Skin') bpy.data.objects[NomeOBJ].active_material_index = IndexMaterial2 bpy.ops.object.material_slot_assign() bpy.ops.object.mode_set(mode='OBJECT') # Criando material dos cílios try: bpy.data.objects[NomeOBJ].active_material_index = 4 MaterialSobrancelhaNativo = bpy.data.objects[NomeOBJ].active_material NomeTextura = MaterialSobrancelhaNativo.node_tree.nodes['Image Texture'].image.name m = Material() m.make_material("Final_Eyelashes") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images[NomeTextura] diffuseBSDF = m.nodes['Principled BSDF'] materialOutput = m.nodes['Material Output'] transpBSDF = m.makeNode('ShaderNodeBsdfTransparent', 'Transparent BSDF') mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') m.link(transpBSDF, 'BSDF', mixShader, 1) m.link(ImageTexture, 'Alpha', mixShader, 0) m.link(mixShader, 'Shader', materialOutput, 'Surface') bpy.ops.object.material_slot_add() bpy.data.objects[NomeOBJ].active_material = bpy.data.materials["Final_Eyelashes"] bpy.context.object.active_material.blend_method = 'HASHED' if platform.system() == "Windows": bpy.context.object.active_material.transparent_shadow_method = 'NONE' if platform.system() == "Linux" or platform.system() == "Darwin": bpy.context.object.active_material.shadow_method = 'NONE' # Atribui material bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') bpy.data.objects[NomeOBJ].active_material_index = 4 bpy.ops.object.material_slot_select() ListaMaterial3 = [] for i in bpy.data.objects[NomeOBJ].material_slots: ListaMaterial3.append(i.name) IndexMaterial3 = ListaMaterial3.index('Final_Eyelashes') bpy.data.objects[NomeOBJ].active_material_index = IndexMaterial3 bpy.ops.object.material_slot_assign() bpy.ops.object.mode_set(mode='OBJECT') except: print("Problema com o material!") # Criando material da sobrancelha bpy.data.objects[NomeOBJ].active_material_index = 3 MaterialSobrancelhaNativo = bpy.data.objects[NomeOBJ].active_material NomeTextura = MaterialSobrancelhaNativo.node_tree.nodes['Image Texture'].image.name m = Material() m.make_material("Final_Eyebrow") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images[NomeTextura] diffuseBSDF = m.nodes['Principled BSDF'] materialOutput = m.nodes['Material Output'] transpBSDF = m.makeNode('ShaderNodeBsdfTransparent', 'Transparent BSDF') mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') m.link(transpBSDF, 'BSDF', mixShader, 1) m.link(ImageTexture, 'Alpha', mixShader, 0) m.link(mixShader, 'Shader', materialOutput, 'Surface') bpy.ops.object.material_slot_add() bpy.data.objects[NomeOBJ].active_material = bpy.data.materials["Final_Eyebrow"] bpy.context.object.active_material.blend_method = 'HASHED' if platform.system() == "Windows": bpy.context.object.active_material.transparent_shadow_method = 'NONE' if platform.system() == "Linux" or platform.system() == "Darwin": bpy.context.object.active_material.shadow_method = 'NONE' # Atribui material bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') bpy.data.objects[NomeOBJ].active_material_index = 3 bpy.ops.object.material_slot_select() ListaMaterial4 = [] for i in bpy.data.objects[NomeOBJ].material_slots: ListaMaterial4.append(i.name) IndexMaterial4 = ListaMaterial4.index('Final_Eyebrow') bpy.data.objects[NomeOBJ].active_material_index = IndexMaterial4 bpy.ops.object.material_slot_assign() bpy.ops.object.mode_set(mode='OBJECT') # Criando material dos cabelos bpy.data.objects[NomeOBJ].active_material_index = 1 MaterialSobrancelhaNativo = bpy.data.objects[NomeOBJ].active_material NomeTextura = MaterialSobrancelhaNativo.node_tree.nodes['Image Texture'].image.name m = Material() m.make_material("Final_Hair") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images[NomeTextura] diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs["Specular"].default_value = 0.0 materialOutput = m.nodes['Material Output'] transpBSDF = m.makeNode('ShaderNodeBsdfTransparent', 'Transparent BSDF') mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') m.link(transpBSDF, 'BSDF', mixShader, 1) m.link(ImageTexture, 'Alpha', mixShader, 0) m.link(mixShader, 'Shader', materialOutput, 'Surface') bpy.ops.object.material_slot_add() bpy.data.objects[NomeOBJ].active_material = bpy.data.materials["Final_Hair"] bpy.context.object.active_material.blend_method = 'HASHED' if platform.system() == "Windows": bpy.context.object.active_material.transparent_shadow_method = 'NONE' if platform.system() == "Linux" or platform.system() == "Darwin": bpy.context.object.active_material.shadow_method = 'NONE' # Atribui material bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') bpy.data.objects[NomeOBJ].active_material_index = 1 bpy.ops.object.material_slot_select() ListaMaterial5 = [] for i in bpy.data.objects[NomeOBJ].material_slots: ListaMaterial5.append(i.name) IndexMaterial5 = ListaMaterial5.index('Final_Hair') bpy.data.objects[NomeOBJ].active_material_index = IndexMaterial5 bpy.ops.object.material_slot_assign() bpy.ops.object.mode_set(mode='OBJECT') class ForensicImportaOBJ(bpy.types.Operator): """Tooltip""" bl_idname = "object.forensic_importa_obj" bl_label = "Forensic Import OBJ" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ForensicImportaOBJDef() return {'FINISHED'} bpy.utils.register_class(ForensicImportaOBJ) ================================================ FILE: FotogrametriaMeshroom.py ================================================ import bpy import subprocess import platform from os.path import expanduser import shutil import tempfile from os import listdir from os.path import isfile, join import exifread import re import os import bmesh from .FerrImgTomo import * def GeraModeloFotoMeshroomDef(self, context): scn = context.scene tmpdir = tempfile.mkdtemp() homeall = expanduser("~") # Database mypath = scn.my_tool.path_photo # Tem que ter o / no final # mypathFotos = mypath+'*' # print("Caminho:"+mypathFotos) onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] try: with open(mypath + FotoTeste, 'rb') as f_jpg: tags = exifread.process_file(f_jpg, details=True) print (tags['Image Model']) CamModel = str(tags['Image Model']) #print("CamModel:", CamModel) except: print("Não rolou!") # subprocess.call([os.system('cd'+mypath), '&&', homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh']) if platform.system() == "Linux": os.system('cd '+mypath+' && '+homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh') if platform.system() == "Darwin": os.system('cd '+mypath+' && /OrtogOnBlender/openMVGMACelcap/ExifTool.sh') if platform.system() == "Windows": print(mypath) subprocess.call(['C:\OrtogOnBlender\ExitTool\exiftool.exe', '-overwrite_original', '-Model="Z00AD"', '-FocalLength=4', mypath+'*']) # Solução colocando o 4 sem as aspas duplas! print("Resolvido!") with open(mypath + FotoTeste, 'rb') as f_jpg: tags = exifread.process_file(f_jpg, details=True) print (tags['Image Model']) CamModel = str(tags['Image Model'])+";" # Inscreve no Banco de dados if platform.system() == "Linux": camDatabase = homeall+"/Programs/OrtogOnBlender/Meshroom/aliceVision/share/aliceVision/cameraSensors.db" if platform.system() == "Windows": camDatabase = "C:/OrtogOnBlender/Meshroom/aliceVision/share/aliceVision/cameraSensors.db" infile = open(camDatabase, "r") numlines = 0 found = 0 for line in infile: numlines += 1 while 1: str_found_at = line.find(CamModel) if str_found_at == -1: # string not found in line ... # go to next (ie break out of the while loop) break else: # string found in line found += 1 # more than once in this line? # lets strip string and anything prior from line and # then go through the testing loop again line = line[str_found_at + len(CamModel):] infile.close() print(CamModel, "was found", found, "times in", numlines, "lines") if found == 0: print("Nao apareceu!") with open(camDatabase, 'a') as file: inputCam = CamModel,CamModel, "3.80;devicespecifications" print(inputCam) # if platform.system() == "Darwin" or platform.system() == "Windows": # file.write("\n") file.write("\n") file.writelines(inputCam) # Escreve o modelo de camera no arquivo # GERA FOTOGRAMETRIA if platform.system() == "Linux": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i '+tmpdir+'/JPG/; done ', shell=True) subprocess.call('~/Programs/OrtogOnBlender/Meshroom/meshroom_photogrammetry --input '+tmpdir+'/JPG/ --output '+tmpdir+' --scale 2 --save '+tmpdir+'/PipelineOrtogOnBlender.txt', shell=True) if platform.system() == "Windows": print("TENTA COPIAR") subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f '+tmpdir+'\JPG', shell=True) print("TENTA RODAR MESHROOM") subprocess.call('C:/OrtogOnBlender/Meshroom/meshroom_photogrammetry --input '+tmpdir+'/JPG/ --output '+tmpdir+' --scale 2 --save '+tmpdir+'/PipelineOrtogOnBlender.txt', shell=True) with open(tmpdir+'/PipelineOrtogOnBlender.txt', 'r') as fd: txt = fd.read() txt = txt.replace('"iterations": 5','"iterations": 16') txt = txt.replace('"maxInputPoints": 50000000','"maxInputPoints": 5000000', 1) txt = txt.replace('"maxPoints": 5000000','"maxPoints": 500000', 1) with open(tmpdir+'/PipelineOrtogOnBlender.txt', 'w') as fd: fd.write(txt) print("ARQUIVO CRIADO!") if platform.system() == "Linux": subprocess.call('~/Programs/OrtogOnBlender/Meshroom/meshroom_photogrammetry --input '+tmpdir+'/JPG/ --output '+tmpdir+' --scale 2 --pipeline '+tmpdir+'/PipelineOrtogOnBlender.txt', shell=True) if platform.system() == "Windows": subprocess.call('C:/OrtogOnBlender/Meshroom/meshroom_photogrammetry --input '+tmpdir+'/JPG/ --output '+tmpdir+' --scale 2 --pipeline '+tmpdir+'/PipelineOrtogOnBlender.txt', shell=True) tmpOBJface = tmpdir+'/texturedMesh.obj' bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") texturedMesh = bpy.data.objects['texturedMesh'] bpy.ops.object.select_all(action='DESELECT') texturedMesh.select_set(True) bpy.context.view_layer.objects.active = texturedMesh bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') bpy.ops.view3d.view_all(center=False) bpy.ops.file.pack_all() # UNIFICA UV MAP print("FIX MESHROOM SURFACE AND MAP") ob = bpy.context.active_object me = ob.data Faces = len(me.polygons) Fator = 500000 / Faces bpy.ops.object.modifier_add(type='DECIMATE') bpy.context.object.modifiers["Decimate"].ratio = Fator bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate") photogrammetry_original = bpy.context.active_object #bpy.ops.object.duplicate() bpy.ops.object.duplicate_move() photogrammetry_original.select_set(False) photogrammetry_copy = bpy.context.active_object print(photogrammetry_original) print(photogrammetry_copy) # Entra em modo de edição e seleciona todos os vértices ob = bpy.context.active_object # FATOR DECIMATE me = ob.data Faces = len(me.polygons) Fator = 100000 / Faces bpy.ops.object.modifier_add(type='DECIMATE') bpy.context.object.modifiers["Decimate"].ratio = Fator bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate") #Apaga todos os materiais for i in range(len(ob.material_slots)): bpy.ops.object.material_slot_remove({'object': ob}) bpy.ops.object.mode_set(mode = 'EDIT') mesh = bmesh.from_edit_mesh(ob.data) for v in mesh.verts: v.select = True # Cria UV map com espaço entre os grupos bpy.ops.uv.smart_project(island_margin=0.03) # bpy.ops.uv.smart_project(island_margin=0.3) bpy.ops.object.mode_set(mode='OBJECT') #Cria imagem bpy.ops.image.new(name='UV_FACE', width=2048, height=2048, color=(0.5, 0.5, 0.5, 1), alpha=True, generated_type='BLANK', float=False, use_stereo_3d=False) #Cria material m = Material() m.set_cycles() # from chapter 1 of [DRM protected book, could not copy author/title] m.make_material("FaceUVunic") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images['UV_FACE'] diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs[5].default_value = 0 m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["FaceUVunic"] # BAKE ob.data.uv_layers['UVMap'].active = True # bpy.data.scenes["Scene"].cycles.bake_type = 'UV' bpy.context.scene.cycles.bake_type = 'DIFFUSE' bpy.context.scene.render.bake.use_pass_direct = False bpy.context.scene.render.bake.use_pass_indirect = False bpy.context.scene.render.bake.use_selected_to_active = True bpy.context.scene.render.bake.margin = 2 bpy.context.scene.render.bake.cage_extrusion = 0.32 photogrammetry_original.select_set(True) bpy.ops.object.bake(type='DIFFUSE') bpy.data.images['UV_FACE'].pack() bpy.ops.file.pack_all() # Oculta original photogrammetry_original.hide_viewport=True # MODIFICADORES bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 3 bpy.context.object.modifiers["Smooth"].show_viewport = False #bpy.ops.object.convert(target='MESH') # MultRes bpy.ops.object.modifier_add(type='MULTIRES') bpy.context.object.modifiers["Multires"].show_viewport = False bpy.ops.object.multires_subdivide(modifier="Multires") context = bpy.context obj = context.active_object heightTex = bpy.data.textures.new('Texture name', type='IMAGE') # heightTex.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] heightTex.image = bpy.data.images['UV_FACE'] dispMod = obj.modifiers.new("Displace", type='DISPLACE') dispMod.texture = heightTex bpy.context.object.modifiers["Displace"].texture_coords = 'UV' bpy.context.object.modifiers["Displace"].strength = 3.2 bpy.context.object.modifiers["Displace"].mid_level = 0.5 bpy.context.object.modifiers["Displace"].show_viewport = False #Comprime modificadores bpy.context.object.modifiers["Smooth"].show_expanded = False bpy.context.object.modifiers["Multires"].show_expanded = False bpy.context.object.modifiers["Displace"].show_expanded = False bpy.ops.object.shade_smooth() bpy.context.space_data.shading.type = 'MATERIAL' class GeraModeloFotoMeshroom(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelo_foto_meshroom" bl_label = "Gera Modelos Foto Meshroom" def execute(self, context): GeraModeloFotoMeshroomDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraModeloFotoMeshroom) ================================================ FILE: FotogrametriaOpenMVG.py ================================================ import bpy import subprocess import platform from os.path import expanduser import shutil import tempfile from os import listdir from os.path import isfile, join import multiprocessing import exifread import re import os # MENSAGENS class MessageFaltaFotos(bpy.types.Operator): bl_idname = "object.dialog_operator_falta_foto" bl_label = "Doesn't have photo path!" def execute(self, context): message = ("Doesn't have photo path!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageFaltaFotos) ''' # ERROS def ERROruntimeFotosDef(self, context): self.layout.label("Doesn't have photo path!") def ERROTermFoto(): CRED = '\033[91m' CEND = '\033[0m' print(CRED + "Doesn't have photo path!" + CEND) ''' # Converte JPG def ConverteHEICtoJPG(): context = bpy.context scn = context.scene tmpdir = tempfile.mkdtemp() mypath = scn.my_tool.path_photo onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] print("Listando arquivos...") Testajpg = ".jpg" in FotoTeste TestaHEIC = ".HEIC" in FotoTeste Testaheic = ".heic" in FotoTeste Testajpeg = ".jpeg" in FotoTeste TestaJPEG = ".JPEG" in FotoTeste # Copia arquivos tmp if Testajpg == True or TestaHEIC == True or Testaheic == True or Testajpeg == True or TestaJPEG == True: tmpFotos = tempfile.mkdtemp() print("COPIANDO ARQUIOS...") print("tmpFotos:", tmpFotos) os.chdir(scn.my_tool.path_photo) if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('cp * '+tmpFotos, shell=True) scn.my_tool.path_photo = tmpFotos+"/" if platform.system() == "Windows": subprocess.call('copy *.* '+tmpFotos, shell=True) scn.my_tool.path_photo = tmpFotos+"\\" os.chdir(scn.my_tool.path_photo) else: print("Algo deu errado com a cópia dos arquivos...") # TESTA ARQUIVOS mypath = scn.my_tool.path_photo # Novamente para atualizar onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] print("Listando arquivos...") Testajpg = ".jpg" in FotoTeste TestaHEIC = ".HEIC" in FotoTeste Testaheic = ".heic" in FotoTeste Testajpeg = ".jpeg" in FotoTeste TestaJPEG = ".JPEG" in FotoTeste if TestaHEIC == True or Testaheic == True: if platform.system() == "Linux": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do heif-convert $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && mogrify -format jpg *.HEIC && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if Testajpeg == True: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Windows" : subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f %f.jpg & move *.jpg '+tmpdir+'\JPG', shell=True) scn.my_tool.path_photo = tmpdir+'\JPG\\' # Se não colocar as duas barras não funciona! if TestaJPEG == True: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Windows" : subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f %f.jpg & move *.jpg '+tmpdir+'\JPG', shell=True) scn.my_tool.path_photo = tmpdir+'\JPG\\' # Se não colocar as duas barras não funciona! # PREPARA CENA def PreparaCenaFotogramDef(self, context): try: bpy.ops.object.select_all(action='SELECT') objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] for i in objetos_selecionados: i.hide_viewport = True except: print("Cena já preparada.") class PreparaCenaFotogram(bpy.types.Operator): """Tooltip""" bl_idname = "object.prepara_cena_fotogram" bl_label = "Photogrammetry Scene Setup" def execute(self, context): PreparaCenaFotogramDef(self, context) return {'FINISHED'} bpy.utils.register_class(PreparaCenaFotogram) # MODELOS def GeraModeloFotoDef(self, context): scn = context.scene #CRIA OU SETA DIRETÓRIO TEMPORÁRIO # if platform.system() == "Linux": tmpdir = tempfile.mkdtemp() # else: # tmpdir = tempfile.gettempdir() dFactor = scn.d_factor smoothFactor = scn.smooth_factor homeall = expanduser("~") ''' mypath = scn.my_tool.path_photo onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] print("Listando arquivos...") Testajpg = ".jpg" in FotoTeste TestaHEIC = ".HEIC" in FotoTeste Testaheic = ".heic" in FotoTeste Testajpeg = ".jpeg" in FotoTeste TestaJPEG = ".JPEG" in FotoTeste # Copia arquivos tmp if Testajpg == True or TestaHEIC == True or Testaheic == True or Testajpeg == True or TestaJPEG == True: tmpFotos = tempfile.mkdtemp() print("COPIANDO ARQUIOS...") print("tmpFotos:", tmpFotos) os.chdir(scn.my_tool.path_photo) if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('cp * '+tmpFotos, shell=True) scn.my_tool.path_photo = tmpFotos+"/" if platform.system() == "Windows": subprocess.call('copy *.* '+tmpFotos, shell=True) scn.my_tool.path_photo = tmpFotos+"\\" os.chdir(scn.my_tool.path_photo) else: print("Algo deu errado com a cópia dos arquivos...") # TESTA ARQUIVOS mypath = scn.my_tool.path_photo # Novamente para atualizar onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] print("Listando arquivos...") Testajpg = ".jpg" in FotoTeste TestaHEIC = ".HEIC" in FotoTeste Testaheic = ".heic" in FotoTeste Testajpeg = ".jpeg" in FotoTeste TestaJPEG = ".JPEG" in FotoTeste if TestaHEIC == True or Testaheic == True: if platform.system() == "Linux": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do heif-convert $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && mogrify -format jpg *.HEIC && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if Testajpeg == True: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Windows" : subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f %f.jpg & move *.jpg '+tmpdir+'\JPG', shell=True) scn.my_tool.path_photo = tmpdir+'\JPG\\' # Se não colocar as duas barras não funciona! if TestaJPEG == True: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Windows" : subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f %f.jpg & move *.jpg '+tmpdir+'\JPG', shell=True) scn.my_tool.path_photo = tmpdir+'\JPG\\' # Se não colocar as duas barras não funciona! ''' ConverteHEICtoJPG() # REDUZ FOTOS ------------------------------------------------------------ if bpy.context.scene.my_tool.imagem_bool == True: print("REDUZ FOTOS") print("bpy.context.scene.my_tool.path_photo", bpy.context.scene.my_tool.path_photo) tmpdirFotos = tempfile.mkdtemp() Origem = bpy.context.scene.my_tool.path_photo # Copia imagens para temporário ListaImagens = sorted(os.listdir(Origem)) ImagContador = 0 for ImagemAtual in ListaImagens: shutil.copyfile(Origem+ImagemAtual, tmpdirFotos+"/"+str(ImagContador)+".jpg") ImagContador += 1 print("Copiando:", Origem+ImagemAtual, "para:", tmpdirFotos+"/"+str(ImagContador)+".jpg") bpy.context.scene.my_tool.path_photo = Origem # Reduz imagens ListaArquivos = sorted(os.listdir(tmpdirFotos)) # print("ORIGEM:", Origem) print("FOOOOOOOOOOOOOOOOI") tmpdirIMagemgick = tempfile.mkdtemp() for ArquivoAtual in ListaArquivos: print("Reduzindo",ArquivoAtual) bpy.ops.image.open(filepath=tmpdirFotos+ArquivoAtual, directory=tmpdirFotos, files=[{"name":ArquivoAtual, "name":ArquivoAtual}], relative_path=False, show_multiview=False) ImgDim0 = bpy.data.images[ArquivoAtual].size[0] ImgDim1 = bpy.data.images[ArquivoAtual].size[1] LadoMaior = max(ImgDim0, ImgDim1) CpuNum = multiprocessing.cpu_count() if CpuNum >= 8: FatorPixel = 2536 if CpuNum == 6: FatorPixel = 2536 if CpuNum == 4: FatorPixel = 2536 if CpuNum == 2: FatorPixel = 2200 if CpuNum == 1: FatorPixel = 2200 if LadoMaior > FatorPixel: print("Maior que "+str(FatorPixel)+"!") FatorDivisao = LadoMaior/FatorPixel # bpy.data.images[ArquivoAtual].scale( int(ImgDim0/FatorDivisao), int(ImgDim1/FatorDivisao) ) if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('convert -resize '+str(100/FatorDivisao)+'% '+tmpdirFotos+"/"+ArquivoAtual+' '+tmpdirIMagemgick+"/"+ArquivoAtual, shell=True) #bpy.data.images[ArquivoAtual].save() bpy.context.scene.my_tool.path_photo = tmpdirIMagemgick+"/" if platform.system() == "Windows": subprocess.call('C:\OrtogOnBlender\ImageMagick\convert -resize '+str(100/FatorDivisao)+'% '+tmpdirFotos+'\\'+ArquivoAtual+' '+tmpdirIMagemgick+'\\'+ArquivoAtual, shell=True) # O convert zoa os dados do EXIF no Windows! #bpy.data.images[ArquivoAtual].save() bpy.context.scene.my_tool.path_photo = tmpdirIMagemgick+"/" # TESTA CAMERA # if platform.system() == "Windows": if bpy.context.scene.my_tool.path_photo == "": bpy.ops.object.dialog_operator_falta_foto('INVOKE_DEFAULT') else: mypath = scn.my_tool.path_photo # Tem que ter o / no final # mypathFotos = mypath+'*' # print("Caminho:"+mypathFotos) onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] try: with open(mypath + FotoTeste, 'rb') as f_jpg: tags = exifread.process_file(f_jpg, details=True) print (tags['Image Model']) CamModel = str(tags['Image Model']) #print("CamModel:", CamModel) except: print("Não rolou!") # subprocess.call([os.system('cd'+mypath), '&&', homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh']) if platform.system() == "Linux": os.system('cd '+mypath+' && '+homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh') if platform.system() == "Darwin": os.system('cd '+mypath+' && '+homeall+'/Programs/OrtogOnBlender/openMVGMACelcap/ExifTool.sh') if platform.system() == "Windows": print(mypath) subprocess.call(['C:\OrtogOnBlender\ExitTool\exiftool.exe', '-all=', mypath]) # Necessário pq o convert zoa os dados do EXIF no Windows! print("Exif apagado tudo!") subprocess.call(['C:\OrtogOnBlender\ExitTool\exiftool.exe', '-overwrite_original', '-Model=Z00AD', '-FocalLength=4', mypath+'*']) # Solução colocando o 4 sem as aspas duplas! print("Resolvido!") try: with open(mypath + FotoTeste, 'rb') as f_jpg: tags = exifread.process_file(f_jpg, details=True) print (tags['Image Model']) CamModel = str(tags['Image Model'])+";" # TESTA MODELO CAMERA if platform.system() == "Linux": camDatabase = homeall+"/Programs/OrtogOnBlender/openMVG/sensor_width_camera_database.txt" if platform.system() == "Darwin": camDatabase = homeall+"/Programs/OrtogOnBlender/openMVGMACelcap/sensor_width_camera_database.txt" if platform.system() == "Windows": camDatabase = "C:/OrtogOnBlender/openMVGWIN/sensor_width_camera_database.txt" infile = open(camDatabase, "r") numlines = 0 found = 0 for line in infile: numlines += 1 while 1: str_found_at = line.find(CamModel) if str_found_at == -1: # string not found in line ... # go to next (ie break out of the while loop) break else: # string found in line found += 1 # more than once in this line? # lets strip string and anything prior from line and # then go through the testing loop again line = line[str_found_at + len(CamModel):] infile.close() print(CamModel, "was found", found, "times in", numlines, "lines") if found == 0: print("Nao apareceu!") with open(camDatabase, 'a') as file: inputCam = CamModel, " 3.80" print(inputCam) # if platform.system() == "Darwin" or platform.system() == "Windows": # file.write("\n") file.write("\n") file.writelines(inputCam) # Escreve o modelo de camera no arquivo except: print("Algum problema com o Modelo de Câmera!") # GERA FOTOGRAMETRIA # try: # if scn.my_tool.path_photo == "": # ERROTermFoto() # bpy.context.window_manager.popup_menu(ERROruntimeFotosDef, title="Attention!", icon='INFO') # else: OpenMVGtmpDir = tmpdir+'/OpenMVG' tmpOBJface = tmpdir+'/MVS/scene_dense_mesh_texture.obj' if platform.system() == "Linux": OpenMVGPath = homeall+'/Programs/OrtogOnBlender/openMVG/software/SfM/SfM_SequentialPipeline.py' OpenMVSPath = homeall+'/Programs/OrtogOnBlender/openMVS/OpenMVS' print("É Linux") if platform.system() == "Windows": OpenMVGPath = 'C:/OrtogOnBlender/openMVGWin/software/SfM/SfM_SequentialPipeline.py' OpenMVSPath = 'C:/OrtogOnBlender/openMVSWin/OpenMVS.bat' if platform.system() == "Darwin": # if platform.release() == '15.6.0': # OpenMVGPath = '/OrtogOnBlender/openMVGMACelcap/SfM_SequentialPipeline.py' # OpenMVSPath = '/OrtogOnBlender/openMVSMACelcap/openMVSMAC.sh' # if platform.release() == '17.5.0': # OpenMVGPath = '/OrtogOnBlender/openMVGMACelcap/SfM_SequentialPipeline.py' # OpenMVSPath = '/OrtogOnBlender/openMVSMACelcap/openMVSMAC.sh' # else: # OpenMVGPath = '/OrtogOnBlender/openMVGMAC/SfM_SequentialPipeline.py' # OpenMVSPath = '/OrtogOnBlender/openMVSMAC/openMVSMAC.sh' OpenMVGPath = homeall+'/Programs/OrtogOnBlender/openMVGMACelcap/SfM_SequentialPipeline.py' OpenMVSPath = homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/openMVSMAC.sh' shutil.rmtree(tmpdir+'/OpenMVG', ignore_errors=True) shutil.rmtree(tmpdir+'/MVS', ignore_errors=True) # if os.name=='posix': # shutil.rmtree(tmpdir+'/OpenMVG') # shutil.rmtree(tmpdir+'/MVS') # if os.name=='nt': # subprocess.call(['rmdir', '/Q', '/S', tmpdir+'/OpenMVG']) # subprocess.call(['rmdir', '/Q', '/S', tmpdir+'/MVS']) if platform.system() == "Linux": with open("/etc/issue") as f: Versao = str(f.read().lower().split()[1]) if Versao == "18.04": subprocess.call(['python', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) if Versao == "20.04.1" or Versao == "20.04": subprocess.call(['python2', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) if platform.system() == "Windows": subprocess.call(['C:/OrtogOnBlender/Python27/python', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) if platform.system() == "Darwin": subprocess.call(['python', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) #subprocess.call(OpenMVSPath , shell=True) if platform.system() == "Linux": with open("/etc/issue") as f: Versao = str(f.read().lower().split()[1]) if Versao == "18.04": subprocess.call('cd '+tmpdir+' && mkdir MVS && ~/Programs/OrtogOnBlender/openMVG/./openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && ~/Programs/OrtogOnBlender/openMVS/./DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && ~/Programs/OrtogOnBlender/openMVS/./ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && ~/Programs/OrtogOnBlender/openMVS/./TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) if Versao == "20.04": subprocess.call('cd '+tmpdir+' && mkdir MVS && ~/Programs/OrtogOnBlender/openMVG/./openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && ~/Programs/OrtogOnBlender/openMVS_ubuntu_2004/./DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && ~/Programs/OrtogOnBlender/openMVS_ubuntu_2004/./ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && ~/Programs/OrtogOnBlender/openMVS_ubuntu_2004/./TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) if platform.system() == "Darwin": subprocess.call('cd '+tmpdir+' && mkdir MVS && '+homeall+'/Programs/OrtogOnBlender/openMVGMACelcap/openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && '+homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/./DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && '+homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/./ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && '+homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/./TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) if platform.system() == "Windows": subprocess.call('cd '+tmpdir+' && mkdir MVS && C:\OrtogOnBlender\openMVGWin\openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && C:\OrtogOnBlender\openMVSWin\DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && C:\OrtogOnBlender\openMVSWin\ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && C:\OrtogOnBlender\openMVSWin\TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) # else: # subprocess.call(OpenMVSPath , shell=True) #subprocess.call([ 'meshlabserver', '-i', tmpdir+'scene_dense_mesh_texture.ply', '-o', tmpdir+'scene_dense_mesh_texture.obj', '-om', 'vn', 'wt' ]) bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") scene_dense_mesh_texture = bpy.data.objects['scene_dense_mesh_texture'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = scene_dense_mesh_texture bpy.data.objects['scene_dense_mesh_texture'].select_set(True) bpy.context.object.data.use_auto_smooth = False # bpy.context.object.active_material.specular_hardness = 60 # bpy.context.object.active_material.diffuse_intensity = 0.6 # bpy.context.object.active_material.specular_intensity = 0.3 bpy.context.object.active_material.specular_color = (0.233015, 0.233015, 0.233015) # bpy.ops.object.modifier_add(type='SMOOTH') # bpy.context.object.modifiers["Smooth"].factor = 2 # bpy.context.object.modifiers["Smooth"].iterations = 3 # bpy.ops.object.convert(target='MESH') # bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Smooth") bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') #bpy.ops.view3d.view_all(center=False) # Centraliza zoom for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) bpy.ops.file.pack_all() bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 3 bpy.context.object.modifiers["Smooth"].show_viewport = False #bpy.ops.object.convert(target='MESH') # MultRes bpy.ops.object.modifier_add(type='MULTIRES') bpy.context.object.modifiers["Multires"].show_viewport = False bpy.ops.object.multires_subdivide(modifier="Multires") context = bpy.context obj = context.active_object heightTex = bpy.data.textures.new('Texture name', type='IMAGE') # heightTex.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] heightTex.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] dispMod = obj.modifiers.new("Displace", type='DISPLACE') dispMod.texture = heightTex bpy.context.object.modifiers["Displace"].texture_coords = 'UV' bpy.context.object.modifiers["Displace"].strength = 3.2 bpy.context.object.modifiers["Displace"].mid_level = 0.5 bpy.context.object.modifiers["Displace"].show_viewport = False #Comprime modificadores bpy.context.object.modifiers["Smooth"].show_expanded = False bpy.context.object.modifiers["Multires"].show_expanded = False bpy.context.object.modifiers["Displace"].show_expanded = False bpy.ops.object.shade_smooth() bpy.context.space_data.shading.type = 'SOLID' bpy.context.space_data.shading.color_type = 'TEXTURE' class GeraModeloFoto(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelo_foto" bl_label = "Gera Modelos Foto" def execute(self, context): GeraModeloFotoDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraModeloFoto) ================================================ FILE: FotogrametriaOpenMVGWinWSL.py ================================================ import bpy import subprocess import platform from os.path import expanduser import shutil import tempfile from os import listdir from os.path import isfile, join import multiprocessing import exifread import re import os # MENSAGENS class MessageFaltaFotos(bpy.types.Operator): bl_idname = "object.dialog_operator_falta_foto" bl_label = "Doesn't have photo path!" def execute(self, context): message = ("Doesn't have photo path!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageFaltaFotos) ''' # ERROS def ERROruntimeFotosDef(self, context): self.layout.label("Doesn't have photo path!") def ERROTermFoto(): CRED = '\033[91m' CEND = '\033[0m' print(CRED + "Doesn't have photo path!" + CEND) ''' # PREPARA CENA def PreparaCenaFotogramDef(self, context): try: bpy.ops.object.select_all(action='SELECT') objetos_selecionados = [ o for o in bpy.context.scene.objects if o.select_get() == True ] for i in objetos_selecionados: i.hide_viewport = True except: print("Cena já preparada.") class PreparaCenaFotogram(bpy.types.Operator): """Tooltip""" bl_idname = "object.prepara_cena_fotogram" bl_label = "Photogrammetry Scene Setup" def execute(self, context): PreparaCenaFotogramDef(self, context) return {'FINISHED'} bpy.utils.register_class(PreparaCenaFotogram) # MODELOS def GeraModeloFotoDef(self, context): scn = context.scene #CRIA OU SETA DIRETÓRIO TEMPORÁRIO # if platform.system() == "Linux": tmpdir = tempfile.mkdtemp() # else: # tmpdir = tempfile.gettempdir() dFactor = scn.d_factor smoothFactor = scn.smooth_factor homeall = expanduser("~") # TESTA ARQUIVOS mypath = scn.my_tool.path_photo onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] TestaHEIC = ".HEIC" in FotoTeste if TestaHEIC == True: if platform.system() == "Linux": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do heif-convert $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && mogrify -format jpg *.HEIC && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' Testajpeg = ".jpeg" in FotoTeste if Testajpeg == True: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Windows" : subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f %f.jpg & move *.jpg '+tmpdir+'\JPG', shell=True) scn.my_tool.path_photo = tmpdir+'\JPG\\' # Se não colocar as duas barras não funciona! TestaJPEG = ".JPEG" in FotoTeste if TestaJPEG == True: if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('mkdir '+tmpdir+'/JPG && cd '+mypath+' && for i in *; do cp $i $i.jpg; done && mv *.jpg '+tmpdir+'/JPG/', shell=True) scn.my_tool.path_photo = tmpdir+'/JPG/' if platform.system() == "Windows" : subprocess.call('mkdir '+tmpdir+'\JPG & cd '+mypath+' & for %f in (*) do copy %f %f.jpg & move *.jpg '+tmpdir+'\JPG', shell=True) scn.my_tool.path_photo = tmpdir+'\JPG\\' # Se não colocar as duas barras não funciona! # REDUZ FOTOS print("REDUZ FOTOS") print("bpy.context.scene.my_tool.path_photo", bpy.context.scene.my_tool.path_photo) tmpdirFotos = tempfile.mkdtemp() Origem = bpy.context.scene.my_tool.path_photo # Copia imagens para temporário ListaImagens = sorted(os.listdir(Origem)) ImagContador = 0 for ImagemAtual in ListaImagens: shutil.copyfile(Origem+ImagemAtual, tmpdirFotos+"/"+str(ImagContador)+".jpg") ImagContador += 1 print("Copiando:", Origem+ImagemAtual, "para:", tmpdirFotos+"/"+str(ImagContador)+".jpg") bpy.context.scene.my_tool.path_photo = Origem # Reduz imagens ListaArquivos = sorted(os.listdir(tmpdirFotos)) # print("ORIGEM:", Origem) print("FOOOOOOOOOOOOOOOOI") tmpdirIMagemgick = tempfile.mkdtemp() for ArquivoAtual in ListaArquivos: print("Reduzindo",ArquivoAtual) bpy.ops.image.open(filepath=tmpdirFotos+ArquivoAtual, directory=tmpdirFotos, files=[{"name":ArquivoAtual, "name":ArquivoAtual}], relative_path=False, show_multiview=False) ImgDim0 = bpy.data.images[ArquivoAtual].size[0] ImgDim1 = bpy.data.images[ArquivoAtual].size[1] LadoMaior = max(ImgDim0, ImgDim1) CpuNum = multiprocessing.cpu_count() if CpuNum >= 8: FatorPixel = 2536 if CpuNum == 6: FatorPixel = 2536 if CpuNum == 4: FatorPixel = 2536 if CpuNum == 2: FatorPixel = 2200 if CpuNum == 1: FatorPixel = 2200 if LadoMaior > FatorPixel: print("Maior que "+str(FatorPixel)+"!") FatorDivisao = LadoMaior/FatorPixel # bpy.data.images[ArquivoAtual].scale( int(ImgDim0/FatorDivisao), int(ImgDim1/FatorDivisao) ) if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('convert -resize '+str(100/FatorDivisao)+'% '+tmpdirFotos+"/"+ArquivoAtual+' '+tmpdirIMagemgick+"/"+ArquivoAtual, shell=True) #bpy.data.images[ArquivoAtual].save() bpy.context.scene.my_tool.path_photo = tmpdirIMagemgick+"/" if platform.system() == "Windows": #subprocess.call('C:\OrtogOnBlender\ImageMagick\convert -resize '+str(100/FatorDivisao)+'% '+tmpdirFotos+'\\'+ArquivoAtual+' '+tmpdirIMagemgick+'\\'+ArquivoAtual, shell=True) # O convert zoa os dados do EXIF no Windows! FotosAtual = str(tmpdirFotos+"/"+ArquivoAtual).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") MagickAtual = str(tmpdirIMagemgick+"/"+ArquivoAtual).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") subprocess.call("wsl \"convert\" -resize \""+str(100/FatorDivisao)+"%\" \""+FotosAtual+"\" \""+MagickAtual+"\"", shell=True) print("Reduzido com convert") #bpy.data.images[ArquivoAtual].save() bpy.context.scene.my_tool.path_photo = tmpdirIMagemgick+"/" # TESTA CAMERA # if platform.system() == "Windows": if bpy.context.scene.my_tool.path_photo == "": bpy.ops.object.dialog_operator_falta_foto('INVOKE_DEFAULT') else: mypath = scn.my_tool.path_photo # Tem que ter o / no final # mypathFotos = mypath+'*' # print("Caminho:"+mypathFotos) onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] FotoTeste = onlyfiles[1] try: with open(mypath + FotoTeste, 'rb') as f_jpg: tags = exifread.process_file(f_jpg, details=True) print (tags['Image Model']) CamModel = str(tags['Image Model']) #print("CamModel:", CamModel) except: print("Não rolou!") # subprocess.call([os.system('cd'+mypath), '&&', homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh']) if platform.system() == "Linux": os.system('cd '+mypath+' && '+homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh') if platform.system() == "Darwin": os.system('cd '+mypath+' && '+homeall+'/Programs/OrtogOnBlender/openMVGMACelcap/ExifTool.sh') if platform.system() == "Windows": print(mypath) #subprocess.call(['C:\OrtogOnBlender\ExitTool\exiftool.exe', '-all=', mypath]) # Necessário pq o convert zoa os dados do EXIF no Windows! #print("Exif apagado tudo!") subprocess.call(['C:\OrtogOnBlender\ExitTool\exiftool.exe', '-overwrite_original', '-Model=Z00AD', '-FocalLength=4', mypath+'*']) # Solução colocando o 4 sem as aspas duplas! # CASO SEJA NECESSARIO EXIFTOOL WINDOWS tmpdirNovo = str(tmpdir).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") print("COMANDO EXIFTOOL") print("wsl \"exiftool \" -overwrite_original -Model=\"Z00AD\" -FocalLength=\"3.8 mm\" \""+tmpdirNovo+"/*\"") subprocess.call("wsl \"exiftool \" -overwrite_original -Model=\"Z00AD\" -FocalLength=\"3.8 mm\" \""+tmpdirNovo+"/*\"" , shell=True) print("Resolvido!") with open(mypath + FotoTeste, 'rb') as f_jpg: tags = exifread.process_file(f_jpg, details=True) print (tags['Image Model']) CamModel = str(tags['Image Model'])+";" # TESTA MODELO CAMERA if platform.system() == "Linux": camDatabase = homeall+"/Programs/OrtogOnBlender/openMVG/sensor_width_camera_database.txt" if platform.system() == "Darwin": camDatabase = homeall+"/Programs/OrtogOnBlender/openMVGMACelcap/sensor_width_camera_database.txt" if platform.system() == "Windows": camDatabase = "C:/OrtogOnBlender/openMVGWIN/sensor_width_camera_database.txt" infile = open(camDatabase, "r") numlines = 0 found = 0 for line in infile: numlines += 1 while 1: str_found_at = line.find(CamModel) if str_found_at == -1: # string not found in line ... # go to next (ie break out of the while loop) break else: # string found in line found += 1 # more than once in this line? # lets strip string and anything prior from line and # then go through the testing loop again line = line[str_found_at + len(CamModel):] infile.close() print(CamModel, "was found", found, "times in", numlines, "lines") if found == 0: print("Nao apareceu!") with open(camDatabase, 'a') as file: inputCam = CamModel, " 3.80" print(inputCam) # if platform.system() == "Darwin" or platform.system() == "Windows": # file.write("\n") file.write("\n") file.writelines(inputCam) # Escreve o modelo de camera no arquivo # GERA FOTOGRAMETRIA # try: # if scn.my_tool.path_photo == "": # ERROTermFoto() # bpy.context.window_manager.popup_menu(ERROruntimeFotosDef, title="Attention!", icon='INFO') # else: OpenMVGtmpDir = tmpdir+'/OpenMVG' tmpOBJface = tmpdir+'/MVS/scene_dense_mesh_texture.obj' if platform.system() == "Linux": OpenMVGPath = homeall+'/Programs/OrtogOnBlender/openMVG/software/SfM/SfM_SequentialPipeline.py' OpenMVSPath = homeall+'/Programs/OrtogOnBlender/openMVS/OpenMVS' print("É Linux") if platform.system() == "Windows": OpenMVGPath = 'C:/OrtogOnBlender/openMVGWin/software/SfM/SfM_SequentialPipeline.py' OpenMVSPath = 'C:/OrtogOnBlender/openMVSWin/OpenMVS.bat' if platform.system() == "Darwin": # if platform.release() == '15.6.0': # OpenMVGPath = '/OrtogOnBlender/openMVGMACelcap/SfM_SequentialPipeline.py' # OpenMVSPath = '/OrtogOnBlender/openMVSMACelcap/openMVSMAC.sh' # if platform.release() == '17.5.0': # OpenMVGPath = '/OrtogOnBlender/openMVGMACelcap/SfM_SequentialPipeline.py' # OpenMVSPath = '/OrtogOnBlender/openMVSMACelcap/openMVSMAC.sh' # else: # OpenMVGPath = '/OrtogOnBlender/openMVGMAC/SfM_SequentialPipeline.py' # OpenMVSPath = '/OrtogOnBlender/openMVSMAC/openMVSMAC.sh' OpenMVGPath = homeall+'/Programs/OrtogOnBlender/openMVGMACelcap/SfM_SequentialPipeline.py' OpenMVSPath = homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/openMVSMAC.sh' shutil.rmtree(tmpdir+'/OpenMVG', ignore_errors=True) shutil.rmtree(tmpdir+'/MVS', ignore_errors=True) # if os.name=='posix': # shutil.rmtree(tmpdir+'/OpenMVG') # shutil.rmtree(tmpdir+'/MVS') # if os.name=='nt': # subprocess.call(['rmdir', '/Q', '/S', tmpdir+'/OpenMVG']) # subprocess.call(['rmdir', '/Q', '/S', tmpdir+'/MVS']) if platform.system() == "Linux": subprocess.call(['python', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) if platform.system() == "Windows": OpenMVGtmpDir = tmpdir+'/OpenMVG/' Fotos = str(scn.my_tool.path_photo).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") Saida = str(OpenMVGtmpDir).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") subprocess.call("wsl \"python\" \"/mnt/c/OrtogOnBlender/OpenMVGLinux/openMVG/software/SfM/SfM_SequentialPipeline.py\" \""+Fotos+"\" \""+Saida+"\"" , shell=True) #subprocess.call(['C:/OrtogOnBlender/Python27/python', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) if platform.system() == "Darwin": subprocess.call(['python', OpenMVGPath , scn.my_tool.path_photo , OpenMVGtmpDir]) #subprocess.call(OpenMVSPath , shell=True) if platform.system() == "Linux": subprocess.call('cd '+tmpdir+' && mkdir MVS && ~/Programs/OrtogOnBlender/openMVG/./openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && ~/Programs/OrtogOnBlender/openMVS/./DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && ~/Programs/OrtogOnBlender/openMVS/./ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && ~/Programs/OrtogOnBlender/openMVS/./TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) if platform.system() == "Darwin": subprocess.call('cd '+tmpdir+' && mkdir MVS && '+homeall+'/Programs/OrtogOnBlender/openMVGMACelcap/openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && '+homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/./DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && '+homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/./ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && '+homeall+'/Programs/OrtogOnBlender/openMVSMACelcap/./TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) if platform.system() == "Windows": #subprocess.call('cd '+tmpdir+' && mkdir MVS && C:\OrtogOnBlender\openMVGWin\openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs && C:\OrtogOnBlender\openMVSWin\DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs && C:\OrtogOnBlender\openMVSWin\ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs && C:\OrtogOnBlender\openMVSWin\TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) #print("CONVERTE WINDOWS!!!") #subprocess.call('cd '+tmpdir+' && mkdir MVS && C:\OrtogOnBlender\openMVGWin\openMVG_main_openMVG2openMVS -i '+tmpdir+'/OpenMVG/reconstruction_sequential/sfm_data.bin -o '+tmpdir+'/MVS/scene.mvs', shell = True) tmpdirNovo = str(tmpdir).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") subprocess.call("wsl \"mkdir\" "+tmpdirNovo+"\"/MVS\"", shell=True) os.chdir(tmpdir) # Se não trocar o diretóri ele gera os distrts e demais dentro do dir do Blender e dá erro! subprocess.call("wsl \"/mnt/c/OrtogOnBlender/OpenMVGLinux/openMVG/./openMVG_main_openMVG2openMVS\" -i \""+tmpdirNovo+"/OpenMVG/reconstruction_sequential/sfm_data.bin\" -o \""+tmpdirNovo+"/MVS/scene.mvs\"", shell=True) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/OpenMVGLinux/openMVS/./DensifyPointCloud\" --estimate-normals \"1\" \""+tmpdirNovo+"/MVS/scene.mvs\"", shell=True) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/OpenMVGLinux/openMVS/./ReconstructMesh\" -d \""+dFactor+"\" --smooth "+smoothFactor+" "+tmpdirNovo+"/MVS/scene_dense.mvs", shell=True) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/OpenMVGLinux/openMVS/./TextureMesh\" --export-type \"obj\" \""+tmpdirNovo+"/MVS/scene_dense_mesh.mvs\"" , shell=True) #print("MVS WINDOWS!!!") #print("DENSIFY") #subprocess.call('C:\OrtogOnBlender\openMVSWin\DensifyPointCloud --estimate-normals 1 '+tmpdir+'/MVS/scene.mvs', shell=True) #print("RECONMESH") #subprocess.call('C:\OrtogOnBlender\openMVSWin\ReconstructMesh -d '+dFactor+' --smooth '+smoothFactor+' '+tmpdir+'/MVS/scene_dense.mvs', shell=True) #print("TEXTURING") #subprocess.call('C:\OrtogOnBlender\openMVSWin\TextureMesh --export-type obj '+tmpdir+'/MVS/scene_dense_mesh.mvs', shell=True) # subprocess.call("wsl \"cd "+tmpdirNovo+" && mkdir MVS && /mnt/c/OrtogOnBlender/OpenMVGLinux/openMVG/./openMVG_main_openMVG2openMVS -i "+tmpdirNovo+"/OpenMVG/reconstruction_sequential/sfm_data.bin -o "+tmpdirNovo+"/MVS/scene.mvs && /mnt/c/OrtogOnBlender/OpenMVGLinux/openMVS/./DensifyPointCloud --estimate-normals 1 "+tmpdirNovo+"/MVS/scene.mvs && /mnt/c/OrtogOnBlender/OpenMVGLinux/openMVS/./ReconstructMesh -d "+dFactor+" --smooth "+smoothFactor+" "+tmpdirNovo+"/MVS/scene_dense.mvs && /mnt/c/OrtogOnBlender/OpenMVGLinux/openMVS/./TextureMesh --export-type obj "+tmpdirNovo+"/MVS/scene_dense_mesh.mvs\"" , shell=True) # else: # subprocess.call(OpenMVSPath , shell=True) #subprocess.call([ 'meshlabserver', '-i', tmpdir+'scene_dense_mesh_texture.ply', '-o', tmpdir+'scene_dense_mesh_texture.obj', '-om', 'vn', 'wt' ]) bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") scene_dense_mesh_texture = bpy.data.objects['scene_dense_mesh_texture'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = scene_dense_mesh_texture bpy.data.objects['scene_dense_mesh_texture'].select_set(True) bpy.context.object.data.use_auto_smooth = False # bpy.context.object.active_material.specular_hardness = 60 # bpy.context.object.active_material.diffuse_intensity = 0.6 # bpy.context.object.active_material.specular_intensity = 0.3 bpy.context.object.active_material.specular_color = (0.233015, 0.233015, 0.233015) # bpy.ops.object.modifier_add(type='SMOOTH') # bpy.context.object.modifiers["Smooth"].factor = 2 # bpy.context.object.modifiers["Smooth"].iterations = 3 # bpy.ops.object.convert(target='MESH') # bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Smooth") bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') #bpy.ops.view3d.view_all(center=False) # Centraliza zoom for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) bpy.ops.file.pack_all() bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 3 bpy.context.object.modifiers["Smooth"].show_viewport = False #bpy.ops.object.convert(target='MESH') # MultRes bpy.ops.object.modifier_add(type='MULTIRES') bpy.context.object.modifiers["Multires"].show_viewport = False bpy.ops.object.multires_subdivide(modifier="Multires") context = bpy.context obj = context.active_object heightTex = bpy.data.textures.new('Texture name', type='IMAGE') # heightTex.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] heightTex.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] dispMod = obj.modifiers.new("Displace", type='DISPLACE') dispMod.texture = heightTex bpy.context.object.modifiers["Displace"].texture_coords = 'UV' bpy.context.object.modifiers["Displace"].strength = 3.2 bpy.context.object.modifiers["Displace"].mid_level = 0.5 bpy.context.object.modifiers["Displace"].show_viewport = False #Comprime modificadores bpy.context.object.modifiers["Smooth"].show_expanded = False bpy.context.object.modifiers["Multires"].show_expanded = False bpy.context.object.modifiers["Displace"].show_expanded = False bpy.ops.object.shade_smooth() bpy.context.space_data.shading.type = 'SOLID' bpy.context.space_data.shading.color_type = 'TEXTURE' class GeraModeloFoto(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelo_foto_win" bl_label = "Gera Modelos Foto Win" def execute(self, context): GeraModeloFotoDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraModeloFoto) ================================================ FILE: FotogrametriaSMVS.py ================================================ import bpy import subprocess import platform from os.path import expanduser import shutil import tempfile import bmesh from os import listdir from os.path import isfile, join from .FerrImgTomo import * from .FotogrametriaOpenMVG import * # ERROS def ERROruntimeFotosDef(self, context): self.layout.label("Doesn't have photo path!") def ERROTermFoto(): CRED = '\033[91m' CEND = '\033[0m' print(CRED + "Doesn't have photo path!" + CEND) def GeraModeloFotoSMVSDef(self, context): context = bpy.context obj = context.active_object scn = context.scene tmpdir = tempfile.mkdtemp() tmpOBJface = tmpdir+'/scene/scene_dense_mesh_texture2.obj' # subprocess.call(['rm /tmp/DIRETORIO_FOTOS.txt'], shell=True) homeall = expanduser("~") ConverteHEICtoJPG() # Inicia os trabalhos if scn.my_tool.path_photo == "": ERROTermFoto() bpy.context.window_manager.popup_menu(ERROruntimeFotosDef, title="Attention!", icon='INFO') else: if platform.system() == "Linux": with open("/etc/issue") as f: Versao = str(f.read().lower().split()[1]) if Versao == "18.04": SMVSPath = homeall+"/Programs/OrtogOnBlender/SMVS/" subprocess.call(['rm', '-rf', tmpdir+'/scene']) subprocess.call([SMVSPath+'./makescene', '-i', scn.my_tool.path_photo, tmpdir+'/scene']) subprocess.call([SMVSPath+'./sfmrecon', tmpdir+'/scene']) subprocess.call([SMVSPath+'./smvsrecon', '-s2', tmpdir+'/scene']) subprocess.call(['meshlabserver', '-i', tmpdir+'/scene/smvs-B2.ply', '-o', tmpdir+'/scene/meshlab.ply', '-s', SMVSPath+'SMVSmeshlab.mlx', '-om']) subprocess.call([SMVSPath+'./texrecon', '--data_term=area', '--skip_global_seam_leveling', '--outlier_removal=gauss_damping', tmpdir+'/scene::undistorted', tmpdir+'/scene/meshlab.ply', tmpdir+'/scene/scene_dense_mesh_texture2']) bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") scene_dense_mesh_texture2 = bpy.data.objects['scene_dense_mesh_texture2'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = scene_dense_mesh_texture2 bpy.data.objects['scene_dense_mesh_texture2'].select_set(True) bpy.ops.view3d.view_all(center=False) bpy.ops.file.pack_all() if Versao == "20.04.1" or Versao == "20.04": SMVSPath = homeall+"/Programs/OrtogOnBlender/SMVS/" subprocess.call(['rm', '-rf', tmpdir+'/scene']) subprocess.call([SMVSPath+'./makescene', '-i', scn.my_tool.path_photo, tmpdir+'/scene']) subprocess.call([SMVSPath+'./sfmrecon', tmpdir+'/scene']) subprocess.call([SMVSPath+'./smvsrecon', '-s2', tmpdir+'/scene']) subprocess.call([SMVSPath+'./fssrecon', tmpdir+'/scene/smvs-B2.ply', tmpdir+'/scene/smvs-surface.ply']) subprocess.call([SMVSPath+'./meshclean', '-p10', tmpdir+'/scene/smvs-surface.ply', tmpdir+'/scene/smvs-surface-clean.ply']) subprocess.call([SMVSPath+'./texrecon', '--data_term=area', '--skip_global_seam_leveling', '--outlier_removal=gauss_damping', tmpdir+'/scene::undistorted', tmpdir+'/scene/smvs-surface-clean.ply', tmpdir+'/scene/scene_dense_mesh_texture2']) bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") scene_dense_mesh_texture2 = bpy.data.objects['scene_dense_mesh_texture2'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = scene_dense_mesh_texture2 bpy.data.objects['scene_dense_mesh_texture2'].select_set(True) bpy.ops.view3d.view_all(center=False) bpy.ops.file.pack_all() if platform.system() == "Windows": SMVSPath = 'C:/OrtogOnBlender/SMVS/' # shutil.rmtree(tmpdir+'/scene') SMVSPathLinux = 'C:/OrtogOnBlender/SMVSlinux/' Fotos = str(scn.my_tool.path_photo).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") print("FOTOS: ", Fotos) Saida = str(tmpdir).replace("\\", "/").replace('\\', "/").replace("C:", "/mnt/c") # subprocess.call([SMVSPath+'./makescene', '-i', scn.my_tool.path_photo, tmpdir+'/scene']) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/SMVSlinux/makescene\" -i \""+Fotos+"\" \""+Saida+"/scene\"", shell=True) #subprocess.call([SMVSPath+'./sfmrecon', tmpdir+'/scene']) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/SMVSlinux/sfmrecon\" \""+Saida+"/scene\"", shell=True) #subprocess.call([SMVSPath+'./smvsrecon', '-s2', tmpdir+'/scene']) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/SMVSlinux/smvsrecon\" -s2 \""+Saida+"/scene\"", shell=True) subprocess.call([SMVSPath+'./fssrecon', tmpdir+'/scene/smvs-B2.ply', tmpdir+'/scene/smvs-surface.ply']) subprocess.call([SMVSPath+'./meshclean', '-p10', tmpdir+'/scene/smvs-surface.ply', tmpdir+'/scene/smvs-surface-clean.ply']) #subprocess.call('C:\OrtogOnBlender\MeshLab\meshlabserver -i '+tmpdir+'/scene/smvs-B2.ply -o '+tmpdir+'/scene/meshlab.ply -s '+SMVSPathLinux+'SMVSmeshlab.mlx', shell=True) subprocess.call("wsl \"/mnt/c/OrtogOnBlender/SMVSlinux/texrecon\" \"--data_term=area\" \"--skip_global_seam_leveling\" \"--outlier_removal=gauss_damping\" \""+Saida+"/scene::undistorted\" \""+Saida+"/scene/smvs-surface-clean.ply\" \""+Saida+"/scene/scene_dense_mesh_texture2\"", shell=True) bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") scene_dense_mesh_texture2 = bpy.data.objects['scene_dense_mesh_texture2'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = scene_dense_mesh_texture2 bpy.data.objects['scene_dense_mesh_texture2'].select_set(True) bpy.ops.view3d.view_all(center=False) bpy.ops.file.pack_all() ''' tmpPLYface = tmpdir+'/scene/smvs-surface-clean.ply' bpy.ops.import_mesh.ply(filepath=tmpPLYface, filter_glob="*.ply") smvs_surface_clean = bpy.data.objects['smvs-surface-clean'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = smvs_surface_clean bpy.data.objects['smvs-surface-clean'].select_set(True) bpy.ops.view3d.view_all(center=False) bpy.ops.file.pack_all() ''' if platform.system() == "Darwin": homemac = expanduser("~") SMVSPath = homemac+'/Programs/OrtogOnBlender/SMVSMAC/' subprocess.call(['rm', '-Rf', tmpdir+'/scene']) subprocess.call([SMVSPath+'./makescene', '-i', scn.my_tool.path_photo, tmpdir+'/scene']) subprocess.call([SMVSPath+'./sfmrecon', tmpdir+'/scene']) subprocess.call([SMVSPath+'./smvsrecon', '-s2', tmpdir+'/scene']) subprocess.call([SMVSPath+'./fssrecon', '-s4', tmpdir+'/scene/smvs-B2.ply', tmpdir+'/scene/smvs-surface.ply']) subprocess.call([SMVSPath+'./meshclean', '-p10', tmpdir+'/scene/smvs-surface.ply', tmpdir+'/scene/smvs-clean.ply']) subprocess.call(['rm', '-Rf', tmpdir+'/scene/tmp']) subprocess.call([SMVSPath+'./texrecon', '--data_term=area', '--skip_global_seam_leveling', '--outlier_removal=gauss_damping', tmpdir+'/scene::undistorted', tmpdir+'/scene/smvs-clean.ply', tmpdir+'/scene/scene_dense_mesh_texture2']) bpy.ops.import_scene.obj(filepath=tmpOBJface, filter_glob="*.obj;*.mtl") scene_dense_mesh_texture2 = bpy.data.objects['scene_dense_mesh_texture2'] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = scene_dense_mesh_texture2 bpy.data.objects['scene_dense_mesh_texture2'].select_set(True) bpy.ops.view3d.view_all(center=False) bpy.ops.file.pack_all() bpy.ops.object.modifier_add(type='DECIMATE') #bpy.context.object.modifiers["Decimate"].ratio = 0.25 bpy.context.object.modifiers["Decimate"].ratio = 0.35 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate") print("FIX SMVS SURFACE AND MAP") photogrammetry_original = bpy.context.active_object #bpy.ops.object.duplicate() bpy.ops.object.duplicate_move() photogrammetry_original.select_set(False) photogrammetry_copy = bpy.context.active_object print(photogrammetry_original) print(photogrammetry_copy) # Entra em modo de edição e seleciona todos os vértices ob = bpy.context.active_object #Apaga todos os materiais for i in range(len(ob.material_slots)): bpy.ops.object.material_slot_remove({'object': ob}) bpy.ops.object.mode_set(mode = 'EDIT') mesh = bmesh.from_edit_mesh(ob.data) for v in mesh.verts: v.select = True # Cria UV map com espaço entre os grupos bpy.ops.uv.smart_project(island_margin=0.03) # bpy.ops.uv.smart_project(island_margin=0.3) bpy.ops.object.mode_set(mode='OBJECT') #Cria imagem bpy.ops.image.new(name='UV_FACE', width=2048, height=2048, color=(0.5, 0.5, 0.5, 1), alpha=True, generated_type='BLANK', float=False, use_stereo_3d=False) #Cria material m = Material() m.set_cycles() # from chapter 1 of [DRM protected book, could not copy author/title] m.make_material("FaceUVunic") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images['UV_FACE'] diffuseBSDF = m.nodes['Principled BSDF'] diffuseBSDF.inputs[5].default_value = 0 m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["FaceUVunic"] # BAKE ob.data.uv_layers['UVMap'].active = True # bpy.data.scenes["Scene"].cycles.bake_type = 'UV' bpy.context.scene.cycles.bake_type = 'DIFFUSE' bpy.context.scene.render.bake.use_pass_direct = False bpy.context.scene.render.bake.use_pass_indirect = False bpy.context.scene.render.bake.use_selected_to_active = True bpy.context.scene.render.bake.margin = 2 bpy.context.scene.render.bake.cage_extrusion = 0.32 photogrammetry_original.select_set(True) bpy.ops.object.bake(type='DIFFUSE') # Oculta original photogrammetry_original.hide_viewport=True # MODIFICADORES # Smooth bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 3 bpy.context.object.modifiers["Smooth"].show_viewport = False # MultRes bpy.ops.object.modifier_add(type='MULTIRES') bpy.context.object.modifiers["Multires"].show_viewport = False bpy.ops.object.multires_subdivide(modifier="Multires") context = bpy.context obj = context.active_object heightTex = bpy.data.textures.new('Texture name', type='IMAGE') heightTex.image = bpy.data.images['UV_FACE'] # heightTex.image = bpy.data.images['scene_dense_mesh_texture2_material0000_map_Kd.png'] dispMod = obj.modifiers.new("Displace", type='DISPLACE') dispMod.texture = heightTex bpy.context.object.modifiers["Displace"].texture_coords = 'UV' bpy.context.object.modifiers["Displace"].strength = 2.2 bpy.context.object.modifiers["Displace"].mid_level = 0.5 bpy.context.object.modifiers["Displace"].show_viewport = False #Comprime modificadores bpy.context.object.modifiers["Smooth"].show_expanded = False bpy.context.object.modifiers["Multires"].show_expanded = False bpy.context.object.modifiers["Displace"].show_expanded = False bpy.ops.object.shade_flat() bpy.context.space_data.shading.type = 'MATERIAL' if platform.system() == "Linux" or platform.system() == "Darwin": bpy.data.images['UV_FACE'].pack() print("Empacotou as imagens!") if platform.system() == "Windows": bpy.data.images['UV_FACE'].pack(as_png=True) print("Empacotou as imagens!") bpy.ops.file.pack_all() class GeraModeloFotoSMVS(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelo_foto_smvs" bl_label = "Gera Modelos Foto" def execute(self, context): GeraModeloFotoSMVSDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraModeloFotoSMVS) class DisplaceSMVS(bpy.types.Operator): """Tooltip""" bl_idname = "object.displace_smvs" bl_label = "Displace SMVS" def execute(self, context): DisplaceSMVSDef(self, context) return {'FINISHED'} bpy.utils.register_class(DisplaceSMVS) ================================================ FILE: GeraModelosTomo.py ================================================ import bpy import platform import tempfile import subprocess import multiprocessing import os import pydicom import shutil import numpy as np from os.path import expanduser from random import randint from .ImportaObjMat import * from .AjustaTomo import * from .ConfOsteotomiaAuto import * # MENSAGENS def GeraModeloTomoAutoMoleDef(): context = bpy.context #obj = context.object scn = context.scene # Organiza a tomografia e fornece os dados pelas variáveis globais bpy.ops.object.ajusta_tomo() # Puxa as variáveis globais do ajusta_tomo para fornecer o endereço das fatias do mole arquivo = open(scn.my_tool.path+'/AUTOEXPDIR.txt', 'r') endereco = arquivo.readline() scn.my_tool.path = endereco bpy.ops.object.gera_modelo_tomo_manual() class GeraModeloTomoAutoMole(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelotomo_auto_mole" bl_label = "CT-Scan reconstruction automatic SoftTissue" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): try: GeraModeloTomoAutoMoleDef() except: bpy.ops.object.corrige_dicom() GeraModeloTomoAutoMoleDef() return {'FINISHED'} bpy.utils.register_class(GeraModeloTomoAutoMole) class MessageFaltaDICOM(bpy.types.Operator): bl_idname = "object.dialog_operator_informe_dicom" bl_label = "Doesn't have DICOM path!" def execute(self, context): message = ("Doesn't have DICOM path!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageFaltaDICOM) class MessageFaltaObjeto(bpy.types.Operator): bl_idname = "object.dialog_operator_falta_objeto" bl_label = "Doesn't have one or more objects!" def execute(self, context): message = ("Doesn't have one or more objects!") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(MessageFaltaObjeto) ''' def ERROruntimeDICOMDef(self, context): self.UILayout.label("Doesn't have DICOM path!") # self.layout.label("Doesn't have DICOM path!") def ERROTermDICOM(): CRED = '\033[91m' CEND = '\033[0m' print(CRED + "Doesn't have DICOM path!" + CEND) ''' # GERA MODELOS TOMO def GeraModelosTomoDef(self, context): context = bpy.context obj = context.object scn = context.scene if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} # scene = context.scene # rd = scene.render else: interesseOssos = bpy.context.scene.interesse_ossos interesseMole = bpy.context.scene.interesse_mole interesseDentes = bpy.context.scene.interesse_dentes # Calcula número de CPUs CpuNum = multiprocessing.cpu_count() if CpuNum >= 8: DecimFactor = '0.90' if CpuNum == 6: DecimFactor = '0.90' if CpuNum == 4: DecimFactor = '0.95' if CpuNum == 2: DecimFactor = '0.98' if CpuNum == 1: DecimFactor = '0.99' try: print("Processadores", CpuNum) except: print("Erro na contagem de processadores!") DecimFactor = '0.95' ReconTomo(scn.my_tool.path, interesseOssos, 'Bones', DecimFactor) ReconTomo(scn.my_tool.path, interesseMole, 'SoftTissue', DecimFactor) ReconTomo(scn.my_tool.path, interesseDentes, 'Teeth', DecimFactor) a = bpy.data.objects['Bones'] b = bpy.data.objects['SoftTissue'] c = bpy.data.objects['Teeth'] bpy.ops.object.select_all(action='DESELECT') a.select_set(True) context.view_layer.objects.active = a #bpy.context.scene.objects.active = a bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') # bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') # bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') bpy.ops.object.select_all(action='DESELECT') b.select_set(True) # bpy.context.scene.objects.active = b context.view_layer.objects.active = b bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.select_all(action='DESELECT') c.select_set(True) # bpy.context.scene.objects.active = c context.view_layer.objects.active = c bpy.ops.object.shade_smooth() bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') bpy.ops.object.select_all(action='DESELECT') a.select_set(True) b.select_set(True) c.select_set(True) # bpy.context.scene.objects.active = a context.view_layer.objects.active = a bpy.ops.object.parent_set() #bpy.ops.transform.rotate(value=3.14159) bpy.ops.transform.rotate(value=3.14159, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) a.location[0] = 0 a.location[1] = 0 a.location[2] = 0 bpy.ops.view3d.view_all(center=False) bpy.ops.object.select_all(action='DESELECT') reconst = bpy.data.objects['Bones'] reconst.select_set(True) context.view_layer.objects.active = reconst CriaMaterialOsteotomia("SCATTER_bone", 0.8, 0.7, 0.5) bpy.ops.object.select_all(action='DESELECT') reconst = bpy.data.objects['SoftTissue'] reconst.select_set(True) context.view_layer.objects.active = reconst CriaMaterialOsteotomia("SCATTER_skin", 0.8, 0.3, 0.15) bpy.ops.object.select_all(action='DESELECT') reconst = bpy.data.objects['Teeth'] reconst.select_set(True) context.view_layer.objects.active = reconst CriaMaterialOsteotomia("SCATTER_teeth", 0.5, 0.6, 1) ''' impMaterial = 'SCATTER_bone' SelObj = 'Bones' ImportaMaterial(impMaterial, SelObj) impMaterial = 'SCATTER_skin' SelObj = 'SoftTissue' ImportaMaterial(impMaterial, SelObj) impMaterial = 'SCATTER_teeth' SelObj = 'Teeth' ImportaMaterial(impMaterial, SelObj) ''' bpy.ops.object.select_all(action='DESELECT') a.select_set(True) # bpy.context.scene.objects.active = a context.view_layer.objects.active = a class GeraModelosTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelos_tomo" bl_label = "Prepara Impressao" def execute(self, context): GeraModelosTomoDef(self, context) return {'FINISHED'} # GERA MODELO ARCADA def GeraModelosTomoArcDef(self, context): context = bpy.context obj = context.object scn = context.scene if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: # scene = context.scene # rd = scene.render interesseArco = bpy.context.scene.interesse_arco ReconTomo(scn.my_tool.path, interesseArco, 'Arch','0.70') obj = context.object bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj bpy.ops.object.shade_smooth() bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') def ReconTomo(pathdir, interes, saida, simplif): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render tmpdir = tempfile.mkdtemp() tmpSTL = tmpdir+'/'+saida+'.stl' homeall = expanduser("~") # capturaEndereco = bpy.data.scenes['Scene'].my_tool['path'] # dirAtual = os.getcwd() # print("DIRETÓRIO ATUAL:", dirAtual) # os.chdir(dirAtual) if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: if platform.system() == "Linux": dicom2DtlPath = homeall+'/Programs/OrtogOnBlender/Dicom2Mesh/dicom2mesh' if platform.system() == "Windows": dicom2DtlPath = 'C:/OrtogOnBlender/DicomToMeshWin/dicom2mesh.exe' if platform.system() == "Darwin": dicom2DtlPath = homeall+'/Programs/OrtogOnBlender/DicomToMeshMAC/dicom2mesh' subprocess.call([dicom2DtlPath, '-i', pathdir, '-r', simplif, '-s', '-t', interes, '-o', tmpSTL]) bpy.ops.import_mesh.stl(filepath=tmpSTL, filter_glob="*.stl", files=[{"name":saida+".stl", "name":saida+".stl"}], directory=tmpdir) # bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') # bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') # bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN', center='MEDIAN') bpy.ops.view3d.view_all(center=False) def CopiaTomoDir(Origem): context = bpy.context scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteDir = homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente # if found == False: if not os.path.exists(NomePacienteDir): print("Patience Dir does not exist!") else: if os.path.exists(NomePacienteDir): shutil.copytree(Origem, NomePacienteDir+"/CT-Scan") def ReduzDimDICOMDef(): context = bpy.context scn = context.scene print("FATIAAAAAAAAA222") ListaArquivos = sorted(os.listdir(scn.my_tool.path)) os.chdir(scn.my_tool.path) for fatia in range(len(ListaArquivos)): ds = pydicom.dcmread(str(ListaArquivos[fatia]), force=True) ArquivoAtual = str(ListaArquivos[fatia]) DimPixelsX = ds.Rows DimPixelsY = ds.Columns print("FATIAAAAAAAAA222") print("DimPixelsX", DimPixelsX) print("DimPixelsY", DimPixelsY) if DimPixelsX > 512 or DimPixelsY > 512: ListaDim = [ DimPixelsX, DimPixelsY ] ElementoFator = float(max(ListaDim)) Fator = str( 512 / ElementoFator ) # DimPixelsXFinal = str(int(DimPixelsX * Fator)) # DimPixelsYFinal = str(int(DimPixelsY * Fator)) # print("DimPixelsX", DimPixelsX) # print("DimPixelsY", DimPixelsY) # print("Fator:", Fator) # print("DimPixelsXFinal", DimPixelsXFinal) # print("DimPixelsYFinal", DimPixelsYFinal) if not os.path.exists("REDUC"): os.mkdir("REDUC") print("Diretorio REDUC criado") if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('dcmscale -v +Sxf '+Fator+' +Syf '+Fator+' '+ArquivoAtual+' REDUC/'+ArquivoAtual, shell=True) if platform.system() == "Windows": subprocess.call('C:/OrtogOnBlender/dcmtk/dcmscale.exe -v +Sxf '+Fator+' +Syf '+Fator+' '+ArquivoAtual+' REDUC/'+ArquivoAtual, shell=True) scn.my_tool.path = os.getcwd()+"/REDUC/" class ReduzDimDICOM(bpy.types.Operator): """Tooltip""" bl_idname = "object.reduz_dimensao_dicom" bl_label = "Reduz Dimensao DICOM" def execute(self, context): ReduzDimDICOMDef() return {'FINISHED'} bpy.utils.register_class(ReduzDimDICOM) def IdentificaTomografo(Arquivo): context = bpy.context scn = context.scene # Lê arquivo DICOM ds = pydicom.dcmread(Arquivo) # Separa Manufacturer ManufacturerComplete = ds.data_element("Manufacturer") ManufacturerLimpa1 = str(ManufacturerComplete).split('LO: ') ManufacturerLimpo = str(ManufacturerLimpa1[1]).strip('"') print("ManufacturerComplete:", ManufacturerComplete) print("ManufacturerLimpa1:", ManufacturerLimpa1) print("ManufacturerLimpo:", ManufacturerLimpo) try: # Separa StationName StationNameComplete = ds.data_element("StationName") StationNameLimpa1 = str(StationNameComplete).split('SH: ') StationNameLimpo = str(StationNameLimpa1[1]).strip('"') print("StationNameComplete:", StationNameComplete) print("StationNameLimpa1:", StationNameLimpa1) print("StationNameLimpo:", StationNameLimpo) except: print("Sem StationNam") try: # Separa ManufacturerModelName ManufacturerModelNameComplete = ds.data_element("ManufacturerModelName") ManufacturerModelNameLimpa1 = str(ManufacturerModelNameComplete).split('LO: ') ManufacturerModelNameLimpo = str(ManufacturerModelNameLimpa1[1]).strip('"') print("ManufacturerModelName:", ManufacturerModelNameComplete) print("ManufacturerModelNameLimpa1:", ManufacturerModelNameLimpa1) print("ManufacturerModelNameLimpo:", ManufacturerModelNameLimpo) return ManufacturerModelName except: print("Sem ManufacturerModelName") if ManufacturerLimpo == "'TOSHIBA'" and StationNameLimpo == "'ACTIVION_16'": print("USA FIXED!") print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") try: # Seleciona diretório e corrige biblio os.chdir(scn.my_tool.path+"/3") except: os.chdir(scn.my_tool.path+"/1005") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() #bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() # TOMO FAKE if ManufacturerLimpo == "'Unknown manufacturer'" and ManufacturerModelNameLimpo == "'Unknown model'": print("FAKE CT-SCAN") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "100" bpy.context.scene.interesse_mole = "65" bpy.context.scene.interesse_dentes = "200" bpy.ops.object.gera_modelos_tomo() # ROTACIONA bpy.ops.transform.rotate(value=3.14159, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'TC01'" and ManufacturerModelNameLimpo == "'BrightSpeed'": os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and StationNameLimpo == "'ID_STATION'" and ManufacturerModelNameLimpo == "'Aquilion Lightning'": print("USA FIXED!") print("SÉRIE 3") print("Bone: 250") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # Seleciona diretório e corrige biblio os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() #bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "250" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'J.Morita.Mfg.Corp.'": os.chdir(scn.my_tool.path+"/1007002") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "245" bpy.context.scene.interesse_mole = "-315" bpy.context.scene.interesse_dentes = "585" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and StationNameLimpo == "'ID_STATION'" and ManufacturerModelNameLimpo == "'Activion16'": print("USA FIXED!") print("SÉRIE 5") # ou 6 print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # Seleciona diretório e corrige biblio #os.chdir(scn.my_tool.path+"/6") # outra configuração os.chdir(scn.my_tool.path+"/5") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() #bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'MyRay'" and StationNameLimpo == "'NT'": if ManufacturerModelNameLimpo == "'HYB'": print("SÉRIE 1") print("Bone: 850") print("SoftTissue: -360") print("Teeth: 1735") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "850" bpy.context.scene.interesse_mole = "-360" bpy.context.scene.interesse_dentes = "1735" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'IMAGING-F708FEC'" and ManufacturerModelNameLimpo == "'17-19'": os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-565" bpy.context.scene.interesse_dentes = "530" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICATSERVER'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 0") print("Bone: 400") print("SoftTissue: -700") print("Teeth: 820") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "400" bpy.context.scene.interesse_mole = "-700" bpy.context.scene.interesse_dentes = "820" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'TOMO'" and ManufacturerModelNameLimpo == "'17-19'": os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") bpy.context.scene.interesse_ossos = "320" bpy.context.scene.interesse_mole = "-545" bpy.context.scene.interesse_dentes = "890" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'IMAGINGS-915FE2'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 0") print("Bone: 205") print("SoftTissue: -770") print("Teeth: 1295") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "205" bpy.context.scene.interesse_mole = "-770" bpy.context.scene.interesse_dentes = "1295" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'IMAGING-53246DF'": print("SÉRIE 0") print("Bone: 200") print("SoftTissue: -600") print("Teeth: 800") print("Condylus: 655") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() #bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "800" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICAT-1A73805376'": print("SÉRIE 0") print("Bone: 480") print("SoftTissue: -550") print("Teeth: 1060") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "480" bpy.context.scene.interesse_mole = "-550" bpy.context.scene.interesse_dentes = "1060" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICAT-8D9DCF422B'": print("USA FIXED!") print("SÉRIE 0") print("Bone: 345") print("SoftTissue: -600") print("Teeth: 972") print("Condylus: 655") try: os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "345" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "972" bpy.ops.object.gera_modelos_tomo() except: try: os.chdir(scn.my_tool.path+"/2000") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "345" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "972" bpy.ops.object.gera_modelos_tomo() except: print("Sem modelo!") if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICAT-6BHI1BTQFF'": print("USA FIXED!") print("SÉRIE 0") print("Bone: 200") print("SoftTissue: -600") print("Teeth: 1000") print("Condylus: 655") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "1000" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'CONEPEAM'": print("SÉRIE 0") print("Bone: 250") print("SoftTissue: -950") print("Teeth: 711") print("Condylus: MODELO LIMITADO") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "250" bpy.context.scene.interesse_mole = "-950" bpy.context.scene.interesse_dentes = "711" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICAT_TOMO'": print("SÉRIE 1") print("Bone: 485") print("SoftTissue: -480") print("Teeth: 1030") print("Condylus: MODELO LIMITADO") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "485" bpy.context.scene.interesse_mole = "-480" bpy.context.scene.interesse_dentes = "1030" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'NIM'" and StationNameLimpo == "'NT'": print("Modifica o FIXED! Usar o 67821") print("SÉRIE 67821") print("Bone: 1300") print("SoftTissue: -1") print("Teeth: 1260") print("Condylus: 1260") os.chdir(scn.my_tool.path+"/67821") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "1300" bpy.context.scene.interesse_mole = "-1" bpy.context.scene.interesse_dentes = "1260" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'PreXion'" and StationNameLimpo == "'CT-02'": print("SÉRIE 1000") print("Bone: 287") print("SoftTissue: -724") print("Teeth: 1807") print("Condylus: APENAS DENTES, ÁREA LIMITADA.") os.chdir(scn.my_tool.path+"/1000") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "287" bpy.context.scene.interesse_mole = "-724" bpy.context.scene.interesse_dentes = "1807" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'PreXion'" and StationNameLimpo == "'CT-01'" and ManufacturerModelNameLimpo == "'PreXion3D'": print("SÉRIE 1000") print("Bone: 340") print("SoftTissue: -650") print("Teeth: 1200") print("Condylus: APENAS DENTES, ÁREA LIMITADA.") os.chdir(scn.my_tool.path+"/1000") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "340" bpy.context.scene.interesse_mole = "-650" bpy.context.scene.interesse_dentes = "1200" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and StationNameLimpo == "'Alexion 16'": print("USA FIXED!") print("SÉRIE 3") print("Bone: 593") print("SoftTissue: -562") print("Teeth: 1862") print("Condylus: 655") print("----") print("USA FIXED!") print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and ManufacturerModelNameLimpo == "'Aquilion ONE'": print("USA FIXED!") print("SÉRIE 3") print("Bone: 593") print("SoftTissue: -562") print("Teeth: 1862") print("Condylus: 655") print("----") print("USA FIXED!") print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and ManufacturerModelNameLimpo == "'Aquilion PRIME'" and StationNameLimpo == "'PRIME 160'": ''' print("USA FIXED!") print("SÉRIE 5") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") ''' print("USA FIXED!") print("SÉRIE 6") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/6") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and ManufacturerModelNameLimpo == "'Aquilion'" and StationNameLimpo == "'HCUV_TC_01'": print("SÉRIE 6") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/6") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and ManufacturerModelNameLimpo == "'Aquilion'" and StationNameLimpo == "'ID_STATION'": print("SÉRIE 5") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/5") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'TOSHIBA'" and ManufacturerModelNameLimpo == "'Alexion'": print("USA FIXED!") print("SÉRIE 3") print("Bone: 593") print("SoftTissue: -562") print("Teeth: 1862") print("Condylus: 655") print("----") print("USA FIXED!") print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'inrad_ct3'" and ManufacturerModelNameLimpo == "'LightSpeed Ultra'": os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'ctbay99'" and ManufacturerModelNameLimpo == "'LightSpeed VCT'": os.chdir(scn.my_tool.path+"/601") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'CTGE'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'CT04'" and ManufacturerModelNameLimpo == "'Discovery CT750 HD'": os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-620" bpy.context.scene.interesse_dentes = "550" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'Optima'" and ManufacturerModelNameLimpo == 'Optima CT660': print("SÉRIE 2") print("Bone: 800") print("SoftTissue: -300") print("Teeth: 1500") print("Condylus: 655") os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "800" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1500" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'vct1'" and ManufacturerModelNameLimpo == "'LightSpeed VCT'": os.chdir(scn.my_tool.path+"/303") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() ''' if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'Optima'": print("SÉRIE 303") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/303") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() ''' if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'CT99'" and ManufacturerModelNameLimpo == "'BrightSpeed'": os.chdir(scn.my_tool.path+"/900") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "270" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "985" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Hitachi Medical Corporation'" and StationNameLimpo == "'HITACHI Scenaria'": # ManufacturerModelNameLimpo == 'SCENARIA' print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") try: os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() except: os.chdir(scn.my_tool.path+"/5") # SÓ FUNCIONA NO WINDOWS!!! O CORRIGE DICOM DE LÁ CORRIGE, O DO LINUX NÃO!!! scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "485" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Siemens Healthineers'" and StationNameLimpo == "'CT108213'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT80588" and ManufacturerModelNameLimpo == "'Emotion 16 (2010)'": os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "620" bpy.context.scene.interesse_mole = "-390" bpy.context.scene.interesse_dentes = "980" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'ctawp64127'" and ManufacturerModelNameLimpo == "'SOMATOM Definition AS+'": print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT3SQ'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT4SQ'" and ManufacturerModelNameLimpo == "'SOMATOM Definition Flash'": print("SÉRIE 1") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT80781'" and ManufacturerModelNameLimpo == "'Emotion 16 (2010)'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP96599'" and ManufacturerModelNameLimpo == "'SOMATOM Definition AS+'": print("SÉRIE 3") print("Bone: 295") print("SoftTissue: -300") print("Teeth: 780") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "295" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "780" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP96809'" and ManufacturerModelNameLimpo == "'SOMATOM Definition AS+'": os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "450" bpy.context.scene.interesse_mole = "-500" bpy.context.scene.interesse_dentes = "1600" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT2SQ'" and ManufacturerModelNameLimpo == "'SOMATOM Definition AS+'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP65987'" and ManufacturerModelNameLimpo == "'SOMATOM Definition AS'": print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT80741'": # ManufacturerModelNameLimpo == 'Emotion 16 (2010)' print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT54551'": print("USA FIXED!") print("SÉRIE ") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("----") print("USA FIXED!") print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT44308'": print("SÉRIE ") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP65910'": print("SÉRIE ") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP96482'": print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP66507'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'PETCT'": # print("USA FIXED!") print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("----") # print("USA FIXED!") print("SÉRIE 4") print("Bone: 400") print("SoftTissue: -300") print("Teeth: 1665") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório CopiaTomoDir(scn.my_tool.path) # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'ct01'": # print("USA FIXED!") print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório CopiaTomoDir(scn.my_tool.path) # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP92145'": print("USA FIXED!") print("SÉRIE 3") print("Bone: 710") print("SoftTissue: -460") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "710" bpy.context.scene.interesse_mole = "-460" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT70522'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT108213'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP65585'": # print("USA FIXED!") print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("----") # print("USA FIXED!") print("SÉRIE 3") print("Bone: 613") print("SoftTissue: -230") print("Teeth: 1320") print("Condylus: 655") os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório CopiaTomoDir(scn.my_tool.path) # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'FEN-TOMO16'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 1") print("Bone: 180") print("SoftTissue: -545") print("Teeth: 585") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "180" bpy.context.scene.interesse_mole = "-545" bpy.context.scene.interesse_dentes = "585" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'LAUDO002'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 1") print("Bone: 245") print("SoftTissue: -615") print("Teeth: 580") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "245" bpy.context.scene.interesse_mole = "-615" bpy.context.scene.interesse_dentes = "580" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'DESKTOP4139'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") bpy.context.scene.interesse_ossos = "420" bpy.context.scene.interesse_mole = "-870" bpy.context.scene.interesse_dentes = "655" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'EXAME-02'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 250") print("SoftTissue: -965") print("Teeth: 680") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "250" bpy.context.scene.interesse_mole = "-965" bpy.context.scene.interesse_dentes = "680" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'EXAME-01'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 390") print("SoftTissue: -920") print("Teeth: 703") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "390" bpy.context.scene.interesse_mole = "-920" bpy.context.scene.interesse_dentes = "703" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'FNL-TOMO08'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 200") print("SoftTissue: -960") print("Teeth: 690") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-960" bpy.context.scene.interesse_dentes = "690" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'SUPERVISOR01'" and ManufacturerModelNameLimpo == "'17-19'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 350") print("SoftTissue: -705") print("Teeth: 660") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "350" bpy.context.scene.interesse_mole = "-705" bpy.context.scene.interesse_dentes = "660" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'EVOL01'" and ManufacturerModelNameLimpo == "'17-19'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 200") print("SoftTissue: -600") print("Teeth: 340") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "340" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'TOMO-EXAME3'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 230") print("SoftTissue: -965") print("Teeth: 385") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "230" bpy.context.scene.interesse_mole = "-965" bpy.context.scene.interesse_dentes = "385" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'EXAME-11'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 350") print("SoftTissue: -925") print("Teeth: 710") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "350" bpy.context.scene.interesse_mole = "-925" bpy.context.scene.interesse_dentes = "710" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'EXAME-10'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 350") print("SoftTissue: -965") print("Teeth: 750") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "350" bpy.context.scene.interesse_mole = "-965" bpy.context.scene.interesse_dentes = "750" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'TOMO'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 305") print("SoftTissue: -808") print("Teeth: 1085") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "305" bpy.context.scene.interesse_mole = "-808" bpy.context.scene.interesse_dentes = "1085" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'ICAT-60587E6B77'" and ManufacturerModelNameLimpo == "'i-CAT\\x99 3D Dental Imaging System'": # i-CAT\x99 (Original) --> i-CAT\\x99 (Modificado) print("SÉRIE 1") print("Bone: 350") print("SoftTissue: -910") print("Teeth: 840") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() #bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "350" bpy.context.scene.interesse_mole = "-910" bpy.context.scene.interesse_dentes = "840" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'FEN-TOMO08'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 1") print("Bone: 270") print("SoftTissue: -550") print("Teeth: 690") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "270" bpy.context.scene.interesse_mole = "-550" bpy.context.scene.interesse_dentes = "690" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'ICAT_TOMO2'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 1") print("Bone: 300") print("SoftTissue: -520") print("Teeth: 700") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "300" bpy.context.scene.interesse_mole = "-520" bpy.context.scene.interesse_dentes = "700" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'FNL-TOMO08'" and ManufacturerModelNameLimpo == "'17-19'": print("SÉRIE 1") print("Bone: 310") print("SoftTissue: -540") print("Teeth: 860") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "310" bpy.context.scene.interesse_mole = "-540" bpy.context.scene.interesse_dentes = "860" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'IMAGE-1856355FD'": print("SÉRIE 1") print("Bone: 250") print("SoftTissue: -630") print("Teeth: 977") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "250" bpy.context.scene.interesse_mole = "-630" bpy.context.scene.interesse_dentes = "977" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'TOMOGRAFIA'": print("SÉRIE 1") print("Bone: 545") print("SoftTissue: -960") print("Teeth: 1230") print("Condylus: 655") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "545" bpy.context.scene.interesse_mole = "-960" bpy.context.scene.interesse_dentes = "1230" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies'" and StationNameLimpo == "'Station'": print("SÉRIE 0") print("Bone: 438") print("SoftTissue: -975") print("Teeth: 1140") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "438" bpy.context.scene.interesse_mole = "-975" bpy.context.scene.interesse_dentes = "1140" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'FEN-TOMO07'": print("SÉRIE 1") print("Bone: 450") print("SoftTissue: -700") print("Teeth: 1440") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "450" bpy.context.scene.interesse_mole = "-700" bpy.context.scene.interesse_dentes = "1440" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies'" and StationNameLimpo == "'WS_ICAT'": print("SÉRIE 0") print("Bone: 580") print("SoftTissue: -811") print("Teeth: 1235") print("Condylus: 655") os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "580" bpy.context.scene.interesse_mole = "-811" bpy.context.scene.interesse_dentes = "1235" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'SERVER2'": print("SÉRIE 1") print("Bone: 320") print("SoftTissue: -680") print("Teeth: 1800") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "320" bpy.context.scene.interesse_mole = "-680" bpy.context.scene.interesse_dentes = "1800" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'FEN-TOMO05'": print("SÉRIE 1") print("Bone: 335") print("SoftTissue: -925") print("Teeth: 1070") print("Condylus: 525") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "335" bpy.context.scene.interesse_mole = "-925" bpy.context.scene.interesse_dentes = "1070" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Xoran Technologies ®'" and StationNameLimpo == "'ISI'": print("SÉRIE 1") print("Bone: 462") print("SoftTissue: 1688") print("Teeth: 4591") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "462" bpy.context.scene.interesse_mole = "1688" bpy.context.scene.interesse_dentes = "4591" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'CT'" and ManufacturerModelNameLimpo == "'Access CT'": # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/35881") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "320" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "860" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'IRIS'" and ManufacturerModelNameLimpo == "'Mx8000'": print("SÉRIE 3330") print("Bone: 335") print("SoftTissue: -300") print("Teeth: 750") print("Condylus: 800") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3330") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "335" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "750" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'HOST-100096'" and ManufacturerModelNameLimpo == "'iCT 256'": print("SÉRIE 5") print("Bone: 390") print("SoftTissue: -370") print("Teeth: 510") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/5") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "390" bpy.context.scene.interesse_mole = "-370" bpy.context.scene.interesse_dentes = "510" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'INGENUITY'": print("SÉRIE 202") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 800") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/202") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'HOST-52084'" and ManufacturerModelNameLimpo == "'Ingenuity Core'": print("SÉRIE 201") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 800") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/201") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP71027'" and ManufacturerModelNameLimpo == "'Biograph128'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT48679'" and ManufacturerModelNameLimpo == "'Biograph 16'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTHSL06'": print("SÉRIE 2") print("Bone: 250") print("SoftTissue: -300") print("Teeth: 1430") print("FIX!") print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP75938'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("SÉRIE 3") print("Bone: 323") print("SoftTissue: -668") print("Teeth: 1850") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'HOST-6163'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'SNDS_CT'": print("SÉRIE 4") print("Bone: 260") print("SoftTissue: -400") print("Teeth: 1270") print("USA FIXED!") print("SÉRIE 5") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/5") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" # ATENÇÃO!!! if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'CT01'" and ManufacturerModelNameLimpo == "'BrightSpeed'": print("SÉRIE 2") # 301 print("Bone: 300") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") # 301 scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "300" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'Ct01'" and ManufacturerModelNameLimpo == "'BrightSpeed'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'PT02'" and ManufacturerModelNameLimpo == "'Discovery 710'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() """ if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'ct99'" and ManufacturerModelNameLimpo == "'BrightSpeed S'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") """ if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'ct99'": print("SÉRIE 2") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("SÉRIE 4") print("Bone: 480") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("SÉRIE 5") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 try: os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() except: print("Não há o direório 2!") try: os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() except: print("Não há o direório 3!") #ManufacturerModelNameLimpo == "'BrightSpeed S'": try: os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() except: print("Não há o direório 4!") # ManufacturerModelNameLimpo == 'Optima CT660' try: os.chdir(scn.my_tool.path+"/5") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() except: print("Não há o direório 5!") try: os.chdir(scn.my_tool.path+"/700") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() except: print("Não há o direório 700!") if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT4SQ'": print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP65950'" and ManufacturerModelNameLimpo == "'SOMATOM Definition AS'": print("SÉRIE 3") # Pode ser o 2 print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT29290'": if ManufacturerModelNameLimpo == "'Emotion 6 (2007)'": print("SÉRIE 1") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() else: print("SÉRIE 3") print("Bone: 275") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "275" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'ct32571'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CTAWP93034'": print("USA FIXED!") print("SÉRIE 6") print("Bone: 370") print("SoftTissue: -360") print("Teeth: 1660") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/6") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "370" bpy.context.scene.interesse_mole = "-360" bpy.context.scene.interesse_dentes = "1660" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Sirona'" and StationNameLimpo == "'CRISTIANE-PC'": print("SÉRIE 100") print("Bone: 591") print("SoftTissue: -170") print("Teeth: 780") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/100") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "591" bpy.context.scene.interesse_mole = "-170" bpy.context.scene.interesse_dentes = "780" bpy.ops.object.gera_modelos_tomo() ''' if ManufacturerLimpo == "'TOSHIBA'" and StationNameLimpo == "'ID_STATION'": print("SÉRIE 3") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 976") print("Condylus: 917") print("UK") print("SÉRIE 3") print("Bone: 635") print("SoftTissue: -460") print("Teeth: 1865") # ManufacturerModelNameLimpo: 'Aquilion ONE' print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("SÉRIE 5") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") print("SÉRIE 7") print("Bone: 395") print("SoftTissue: -300") print("Teeth: 1140") print("Condylus: 851") # TAMBÉM FUNCIONA O 201 try: os.chdir(scn.my_tool.path+"/3") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" except: try: os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" except: os.chdir(scn.my_tool.path+"/7") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "590" bpy.context.scene.interesse_mole = "-430" bpy.context.scene.interesse_dentes = "1590" bpy.context.scene.interesse_ossos = "280" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() ''' if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'HOST-9121'": print("SÉRIE 2") print("Bone: 280") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'HOST-10703'" and ManufacturerModelNameLimpo == "'Brilliance 64'": os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Philips'" and StationNameLimpo == "'HOST-10662'": print("SÉRIE 2") print("Bone: 280") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'ctbay99'" and ManufacturerModelNameLimpo == "'Revolution EVO'": print("SÉRIE 4") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/4") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'TC_100'" and ManufacturerModelNameLimpo == "'Revolution EVO'": print("SÉRIE 2") print("Bone: 275") print("SoftTissue: -815") print("Teeth: 3064") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "275" bpy.context.scene.interesse_mole = "-815" bpy.context.scene.interesse_dentes = "3064" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'GE MEDICAL SYSTEMS'" and StationNameLimpo == "'CT'" and ManufacturerModelNameLimpo == "'HiSpeed'": print("SÉRIE 5") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/5") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICAT_TOMO2'" and ManufacturerModelNameLimpo == "'i-CAT'": print("SÉRIE 1") print("Bone: 630") print("SoftTissue: -472") print("Teeth: 1040") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "630" bpy.context.scene.interesse_mole = "-475" bpy.context.scene.interesse_dentes = "1040" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'IMAGE-1856355FD'" and ManufacturerModelNameLimpo == "'i-CAT'": print("SÉRIE 1") print("Bone: 390") print("SoftTissue: -600") print("Teeth: 870") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "390" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "870" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Imaging Sciences International'" and StationNameLimpo == "'ICAT'": print("SÉRIE 0") print("Bone: 360") print("SoftTissue: -600") print("Teeth: 992") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/0") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "360" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "992" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT79409'": print("SÉRIE 607") print("Bone: 200") print("SoftTissue: -300") print("Teeth: 1430") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/607") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1430" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'SIEMENS'" and StationNameLimpo == "'CT54945'": print("SÉRIE 2") print("Bone: 400") print("SoftTissue: -300") print("Teeth: 1350") print("Condylus: 655") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/2") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "400" bpy.context.scene.interesse_mole = "-300" bpy.context.scene.interesse_dentes = "1350" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'NewTom'" and StationNameLimpo == "'NT'" and ManufacturerModelNameLimpo == "'NTVGiMK4'": # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "670" bpy.context.scene.interesse_mole = "-450" bpy.context.scene.interesse_dentes = "950" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'NewTom'" and StationNameLimpo == "'NT'" and ManufacturerModelNameLimpo == "'NT5G'": print("SÉRIE 1") print("Bone: 520") print("SoftTissue: -440") print("Teeth: 950") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "520" bpy.context.scene.interesse_mole = "-440" bpy.context.scene.interesse_dentes = "950" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'NewTom'" and ManufacturerModelNameLimpo == "'NT5GXL'": print("SÉRIE 81") print("Bone: 650") print("SoftTissue: -610") print("Teeth: 1240") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/81") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "650" bpy.context.scene.interesse_mole = "-610" bpy.context.scene.interesse_dentes = "1240" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'NewTom'" and ManufacturerModelNameLimpo == "'NTVGiEVO'": print("SÉRIE 1") print("Bone: 570") print("SoftTissue: -600") print("Teeth: 1105") # TAMBÉM FUNCIONA O 201 os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "570" bpy.context.scene.interesse_mole = "-600" bpy.context.scene.interesse_dentes = "1105" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Planmeca'" and ManufacturerModelNameLimpo == "'ProMax'": print("SÉRIE 347885") print("Bone: 600") print("SoftTissue: -550") print("Teeth: 1100") print("Condylus: 145") # TAMBÉM FUNCIONA O 201 try: os.chdir(scn.my_tool.path+"/347885") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "600" bpy.context.scene.interesse_mole = "-550" bpy.context.scene.interesse_dentes = "1100" bpy.ops.object.gera_modelos_tomo() except: print("Não conta com diretório 347885") if ManufacturerLimpo == "'Planmeca'" and ManufacturerModelNameLimpo == "'ProMax'": print("SÉRIE 453970") print("Bone: 200") print("SoftTissue: -580") print("Teeth: 460") print("Condylus: 145") # TAMBÉM FUNCIONA O 201 try: os.chdir(scn.my_tool.path+"/453970") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-580" bpy.context.scene.interesse_dentes = "460" bpy.ops.object.gera_modelos_tomo() except: print("Não conta com diretório 453970") try: os.chdir(scn.my_tool.path+"/454156") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "450" bpy.context.scene.interesse_mole = "-450" bpy.context.scene.interesse_dentes = "1300" bpy.ops.object.gera_modelos_tomo() except: print("Não conta com diretório 454156") try: os.chdir(scn.my_tool.path+"/456750") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-580" bpy.context.scene.interesse_dentes = "460" bpy.ops.object.gera_modelos_tomo() except: print("Não conta com diretório 456750") try: os.chdir(scn.my_tool.path+"/134149") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-580" bpy.context.scene.interesse_dentes = "460" bpy.ops.object.gera_modelos_tomo() except: print("Não conta com diretório 134149") if ManufacturerLimpo == "'Carestream Health'" and ManufacturerModelNameLimpo == "'CS 9300'": print("SÉRIE 1") print("Bone: 452") print("SoftTissue: -580") print("Teeth: 1080") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "200" bpy.context.scene.interesse_mole = "-580" bpy.context.scene.interesse_dentes = "1080" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Dabi Atlante'" and ManufacturerModelNameLimpo == "'Eagle 3D'": print("SÉRIE 1") print("Bone: 575") print("SoftTissue: -377") print("Teeth: 1080") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() # bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "575" bpy.context.scene.interesse_mole = "-377" bpy.context.scene.interesse_dentes = "1080" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Carestream Health'" and ManufacturerModelNameLimpo == "'CS 9000'": print("SÉRIE 1") print("Bone: 446") print("SoftTissue: 536") print("Teeth: 982") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() # bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "446" bpy.context.scene.interesse_mole = "-536" bpy.context.scene.interesse_dentes = "982" bpy.ops.object.gera_modelos_tomo() if ManufacturerLimpo == "'Carestream Health'" and ManufacturerModelNameLimpo == "'CS 8100 3D'": print("SÉRIE 1") print("Bone: -522") print("SoftTissue: -680") print("Teeth: 982") os.chdir(scn.my_tool.path+"/1") scn.my_tool.path = os.getcwd() bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # Copia para o diretório try: CopiaTomoDir(scn.my_tool.path) except: print("Doesn't have Patient Dir") # Gera o 3D bpy.context.scene.interesse_ossos = "522" bpy.context.scene.interesse_mole = "-680" bpy.context.scene.interesse_dentes = "982" bpy.ops.object.gera_modelos_tomo() def GeraModeloTomoAutoDef(self, context): context = bpy.context scn = context.scene bpy.ops.object.ajusta_tomo() print("Original:", scn.my_tool.path) try: os.chdir(scn.my_tool.path+"/1") except: print("Dir 1 doesn't exist") try: os.chdir(scn.my_tool.path+"/2") except: print("Dir 2 doesn't exist") try: os.chdir(scn.my_tool.path+"/3") except: print("Dir 3 doesn't exist") try: os.chdir(scn.my_tool.path+"/4") except: print("Dir 4 doesn't exist") try: os.chdir(scn.my_tool.path+"/5") except: print("Dir 5 doesn't exist") try: os.chdir(scn.my_tool.path+"/6") except: print("Dir 6 doesn't exist") try: os.chdir(scn.my_tool.path+"/9") except: print("Dir 6 doesn't exist") try: os.chdir(scn.my_tool.path+"/0") except: print("Dir 0 doesn't exist") try: os.chdir(scn.my_tool.path+"/81") except: print("Dir 81 doesn't exist") try: os.chdir(scn.my_tool.path+"/100") except: print("Dir 81 doesn't exist") try: os.chdir(scn.my_tool.path+"/202") except: print("Dir 202 doesn't exist") try: os.chdir(scn.my_tool.path+"/303") except: print("Dir 303 doesn't exist") try: os.chdir(scn.my_tool.path+"/67821") except: print("Dir 67821 doesn't exist") try: os.chdir(scn.my_tool.path+"/134149") except: print("Dir 134149 doesn't exist") try: os.chdir(scn.my_tool.path+"/347885") except: print("Dir 347885 doesn't exist") try: os.chdir(scn.my_tool.path+"/453970") except: print("Dir 453970 doesn't exist") try: os.chdir(scn.my_tool.path+"/454156") except: print("Dir 454156 doesn't exist") try: os.chdir(scn.my_tool.path+"/456750") except: print("Dir 453970 doesn't exist") try: os.chdir(scn.my_tool.path+"/303") except: print("Dir 303 doesn't exist") try: os.chdir(scn.my_tool.path+"/601") except: print("Dir 601 doesn't exist") try: os.chdir(scn.my_tool.path+"/700") except: print("Dir 700 doesn't exist") try: os.chdir(scn.my_tool.path+"/900") except: print("Dir 900 doesn't exist") try: os.chdir(scn.my_tool.path+"/1000") except: print("Dir 1000 doesn't exist") try: os.chdir(scn.my_tool.path+"/1005") except: print("Dir 1005 doesn't exist") try: os.chdir(scn.my_tool.path+"/2000") except: print("Dir 1005 doesn't exist") try: os.chdir(scn.my_tool.path+"/3330") except: print("Dir 1005 doesn't exist") try: os.chdir(scn.my_tool.path+"/35881") except: print("Dir 1005 doesn't exist") try: os.chdir(scn.my_tool.path+"/1007002") except: print("Dir 1007002 doesn't exist") try: os.chdir(scn.my_tool.path+"/001006002") except: print("Dir 001006002 doesn't exist") # Não usar o 1, dá erro! try: print("Atual:", os.getcwd()) print (os.listdir(os.getcwd())[0]) ArquivoAtual = os.listdir(os.getcwd())[0] IdentificaTomografo(ArquivoAtual) except: print("Erro no DICOM, tentativa 2!") scn.my_tool.path = os.getcwd() global DirExportado DirExportado = scn.my_tool.path bpy.ops.object.corrige_dicom() scn.my_tool.path = os.getcwd()+"/FIXED/" ArquivoAtual = os.listdir(os.getcwd())[0] IdentificaTomografo(ArquivoAtual) class GeraModeloTomoAuto(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelos_tomo_auto" bl_label = "Gera Modelo Tomo" def execute(self, context): try: try: GeraModeloTomoAutoDef(self, context) except: GeraModeloTomoAutoDef(self, context) except: print("EROOOOO") if platform.system() == "Windows": context = bpy.context scn = context.scene os.chdir(DirExportado+"/Error/") os.makedirs("FIXED") path = DirExportado+"/Error/" dirs = os.listdir( path ) print("DIRRRRRRRR GLOBAL:", DirExportado) # print the files in given directory DCMNum = 0 for file in dirs: print (file) print("FIXED WINDOWS MANUAL!!!") try: os.system("C:\OrtogOnBlender\dicomtools\dicomtodicom --verbose -o FIXED "+file) shutil.move(DirExportado+"/Error/FIXED/IM-0001-0001.dcm", DirExportado+"/Error/FIXED/"+str(DCMNum)) DCMNum += 1 except: print("Arquivo corrompido ou não é um DICOM!") scn.my_tool.path = DirExportado+"/Error/FIXED/" GeraModeloTomoAutoDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraModeloTomoAuto) def DesagrupaTomoDef(self, context): context = bpy.context scn = context.scene if bpy.data.objects.get('Bones') and bpy.data.objects.get('SoftTissue') and bpy.data.objects.get('Teeth'): a = bpy.data.objects['Bones'] b = bpy.data.objects['SoftTissue'] c = bpy.data.objects['Teeth'] bpy.ops.object.select_all(action='DESELECT') bpy.data.objects['SoftTissue'].hide_viewport = False bpy.data.objects['Bones'].hide_viewport = False bpy.data.objects['Teeth'].hide_viewport = False a.select_set(True) b.select_set(True) c.select_set(True) context.view_layer.objects.active = a bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.ops.object.select_all(action='DESELECT') else: bpy.ops.object.dialog_operator_falta_objeto('INVOKE_DEFAULT') #return {'FINISHED'} class DesagrupaTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.desagrupa_tomo" bl_label = "Desagrupa Tomo" def execute(self, context): DesagrupaTomoDef(self, context) return {'FINISHED'} bpy.utils.register_class(DesagrupaTomo) def GeraModelosTomoManualDef(self, context): scn = context.scene if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: homeall = expanduser("~") os.chdir(scn.my_tool.path) DirAtual = os.getcwd() ArqAtual = os.listdir(os.getcwd())[0] print("Atual:", os.getcwd()) print (os.listdir(os.getcwd())[0]) # IDENTIFICA TOMOGRAFO # Lê arquivo DICOM ds = pydicom.dcmread(ArqAtual, force=True) try: # Separa Manufacturer ManufacturerComplete = ds.data_element("Manufacturer") ManufacturerLimpa1 = str(ManufacturerComplete).split('LO: ') ManufacturerLimpo = str(ManufacturerLimpa1[1]).strip('"') print("ManufacturerComplete:", ManufacturerComplete) print("ManufacturerLimpa1:", ManufacturerLimpa1) print("ManufacturerLimpo:", ManufacturerLimpo) except: print("Sem Manufacturer") try: # Separa StationName StationNameComplete = ds.data_element("StationName") StationNameLimpa1 = str(StationNameComplete).split('SH: ') StationNameLimpo = str(StationNameLimpa1[1]).strip('"') print("StationNameComplete:", StationNameComplete) print("StationNameLimpa1:", StationNameLimpa1) print("StationNameLimpo:", StationNameLimpo) except: print("Sem StationName") try: # Separa ManufacturerModelName ManufacturerModelNameComplete = ds.data_element("ManufacturerModelName") ManufacturerModelNameLimpa1 = str(ManufacturerModelNameComplete).split('LO: ') ManufacturerModelNameLimpo = str(ManufacturerModelNameLimpa1[1]).strip('"') print("ManufacturerModelName:", ManufacturerModelNameComplete) print("ManufacturerModelNameLimpa1:", ManufacturerModelNameLimpa1) print("ManufacturerModelNameLimpo:", ManufacturerModelNameLimpo) return ManufacturerModelName except: print("Sem ManufacturerModelName") # GERA MODELOS ListaArquivos = sorted(os.listdir(scn.my_tool.path)) os.chdir(scn.my_tool.path) ds = pydicom.dcmread(str(DirAtual+"/"+ArqAtual), force=True) DimPixelsX = ds.Rows DimPixelsY = ds.Columns print("TESTA FATIA...") print("DimPixelsX", DimPixelsX) print("DimPixelsY", DimPixelsY) # CAPTURA VALORES DOS FATORES FatorOssos = bpy.context.scene.interesse_ossos FatorMole = bpy.context.scene.interesse_mole FatorDentes = bpy.context.scene.interesse_dentes DiretorioTomo = scn.my_tool.path TmpDirTomografo = tempfile.mkdtemp() TmpTomograforFile = TmpDirTomografo+'/CT_Scan_tomograph.txt' try: with open(TmpTomograforFile, "a") as ModeloTomografo: ModeloTomografo.write('ManufacturerLimpo == '+'"'+str(ManufacturerLimpo)+'"'+"\n") ModeloTomografo.write('StationNameLimpo == '+'"'+str(StationNameLimpo)+'"'+"\n") ModeloTomografo.write('ManufacturerModelNameLimpo == '+'"'+str(ManufacturerModelNameLimpo)+'"'+"\n") if DimPixelsX > 512 or DimPixelsY > 512: ModeloTomografo.write("NECESSÁRIO REDUZIR!!!\n") else: ModeloTomografo.write("Não é necessário reduzir\n") ModeloTomografo.write('bpy.context.scene.interesse_ossos = '+'"'+str(FatorOssos)+'"'+"\n") ModeloTomografo.write('bpy.context.scene.interesse_mole = '+'"'+str(FatorMole)+'"'+"\n") ModeloTomografo.write('bpy.context.scene.interesse_dentes = '+'"'+str(FatorDentes)+'"'+"\n") ModeloTomografo.write('DiretorioTomo == '+str(DiretorioTomo)) # SCRIPT ModeloTomografo.write("\n") ModeloTomografo.write("\n") ModeloTomografo.write(" "+'if ManufacturerLimpo == '+'"'+str(ManufacturerLimpo)+'" and StationNameLimpo == '+'"'+str(StationNameLimpo)+'" and ManufacturerModelNameLimpo == '+'"'+str(ManufacturerModelNameLimpo)+'":'+"\n") ModeloTomografo.write("\n") ModeloTomografo.write(" "+'os.chdir(scn.my_tool.path+"'+"/"+str(DiretorioTomo).split('/')[-2]+'")'+"\n") ModeloTomografo.write("\n") ModeloTomografo.write(" "+'scn.my_tool.path = os.getcwd()'+"\n") ModeloTomografo.write(" "+'bpy.ops.object.corrige_dicom()'+"\n") ModeloTomografo.write("\n") if DimPixelsX > 512 or DimPixelsY > 512: ModeloTomografo.write(" "+'bpy.ops.object.reduz_dimensao_dicom()'+"\n") ModeloTomografo.write("\n") ModeloTomografo.write(" "+'try:'+"\n") ModeloTomografo.write(" "+'CopiaTomoDir(scn.my_tool.path)'+"\n") ModeloTomografo.write(" "+'except:'+"\n") ModeloTomografo.write(" "+'print("Doesn\'t have Patient Dir")'+"\n") ModeloTomografo.write(''+"\n") ModeloTomografo.write(" "+'bpy.context.scene.interesse_ossos = "'+str(FatorOssos)+'"'+"\n") ModeloTomografo.write(" "+'bpy.context.scene.interesse_mole = "'+str(FatorMole)+'"'+"\n") ModeloTomografo.write(" "+'bpy.context.scene.interesse_dentes = "'+str(FatorDentes)+'"'+"\n") ModeloTomografo.write(''+"\n") ModeloTomografo.write(" "+'bpy.ops.object.gera_modelos_tomo()'+"\n") ModeloTomografo.close() except: print("Não consta dados do tomógrafo.") # ABRE DIRETÓRIO if platform.system() == "Windows": os.startfile(TmpTomograforFile) elif platform.system() == "Darwin": subprocess.Popen(["open", TmpTomograforFile]) else: subprocess.Popen(["xdg-open", TmpTomograforFile]) if DimPixelsX > 512 or DimPixelsY > 512: print("MAIOR QUE 512!!! REDUZINDO...") bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # SÓ FUNCIONA SE FOR COMPATIVEL! POR ISSO O FIXED ANTES!!! bpy.ops.object.gera_modelos_tomo() else: print("MENOR OU IGUAL A 512...") bpy.ops.object.corrige_dicom() bpy.ops.object.gera_modelos_tomo() class GeraModelosTomoManual(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelo_tomo_manual" bl_label = "Gera Modelo Tomo Manual" def execute(self, context): GeraModelosTomoManualDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraModelosTomoManual) def GeraModelosTomoCustomlDef(): context = bpy.context scn = context.scene if scn.my_tool.path == "": bpy.ops.object.dialog_operator_informe_dicom('INVOKE_DEFAULT') return {'FINISHED'} else: homeall = expanduser("~") os.chdir(scn.my_tool.path) DirAtual = os.getcwd() ArqAtual = os.listdir(os.getcwd())[0] print("Atual:", os.getcwd()) print (os.listdir(os.getcwd())[0]) # IDENTIFICA TOMOGRAFO # Lê arquivo DICOM ds = pydicom.dcmread(ArqAtual) # Separa Manufacturer ManufacturerComplete = ds.data_element("Manufacturer") ManufacturerLimpa1 = str(ManufacturerComplete).split('LO: ') ManufacturerLimpo = str(ManufacturerLimpa1[1]).strip('"') print("ManufacturerComplete:", ManufacturerComplete) print("ManufacturerLimpa1:", ManufacturerLimpa1) print("ManufacturerLimpo:", ManufacturerLimpo) try: # Separa StationName StationNameComplete = ds.data_element("StationName") StationNameLimpa1 = str(StationNameComplete).split('SH: ') StationNameLimpo = str(StationNameLimpa1[1]).strip('"') print("StationNameComplete:", StationNameComplete) print("StationNameLimpa1:", StationNameLimpa1) print("StationNameLimpo:", StationNameLimpo) except: print("Sem StationNam") try: # Separa ManufacturerModelName ManufacturerModelNameComplete = ds.data_element("ManufacturerModelName") ManufacturerModelNameLimpa1 = str(ManufacturerModelNameComplete).split('LO: ') ManufacturerModelNameLimpo = str(ManufacturerModelNameLimpa1[1]).strip('"') print("ManufacturerModelName:", ManufacturerModelNameComplete) print("ManufacturerModelNameLimpa1:", ManufacturerModelNameLimpa1) print("ManufacturerModelNameLimpo:", ManufacturerModelNameLimpo) return ManufacturerModelName except: print("Sem ManufacturerModelName") # GERA MODELOS ListaArquivos = sorted(os.listdir(scn.my_tool.path)) os.chdir(scn.my_tool.path) ds = pydicom.dcmread(str(DirAtual+"/"+ArqAtual), force=True) DimPixelsX = ds.Rows DimPixelsY = ds.Columns print("TESTA FATIA...") print("DimPixelsX", DimPixelsX) print("DimPixelsY", DimPixelsY) if DimPixelsX > 512 or DimPixelsY > 512: print("MAIOR QUE 512!!! REDUZINDO...") bpy.ops.object.corrige_dicom() bpy.ops.object.reduz_dimensao_dicom() # SÓ FUNCIONA SE FOR COMPATIVEL! POR ISSO O FIXED ANTES!!! ReconTomo(scn.my_tool.path, bpy.context.scene.interesse_geral, bpy.context.scene.nome_objeto, bpy.context.scene.fator_simplificacao) bpy.ops.transform.rotate(value=3.14159, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) a = bpy.context.active_object a.location[0] = 0 a.location[1] = 0 a.location[2] = 0 bpy.ops.view3d.view_all(center=False) activeObject = bpy.context.active_object mat = bpy.data.materials.new(name=activeObject.name) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) else: print("MENOR OU IGUAL A 512...") bpy.ops.object.corrige_dicom() ReconTomo(scn.my_tool.path, bpy.context.scene.interesse_geral, bpy.context.scene.nome_objeto, bpy.context.scene.fator_simplificacao) bpy.ops.transform.rotate(value=3.14159, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) a = bpy.context.active_object a.location[0] = 0 a.location[1] = 0 a.location[2] = 0 bpy.ops.view3d.view_all(center=False) activeObject = bpy.context.active_object mat = bpy.data.materials.new(name=activeObject.name) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) class GeraModelosTomoCustom(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelo_tomo_custom" bl_label = "Gera Modelo Tomo Custom" def execute(self, context): GeraModelosTomoCustomlDef() return {'FINISHED'} bpy.utils.register_class(GeraModelosTomoCustom) ================================================ FILE: GeraRelatorio.py ================================================ import bpy import csv import tempfile import subprocess import openpyxl import platform from string import ascii_uppercase from openpyxl import Workbook from openpyxl.styles import Font, Fill from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment from .CalculaPontos import * from .AjustaTomo import * from .Cefalometria import * def DeslocamentoINIFIN(obj, obj1, obj2): objini = bpy.data.objects[obj1] objfin = bpy.data.objects[obj2] # if bpy.data.objects.get(obj) is not None: Xdes = str(round(objfin.location[0] - objini.location[0], 2)) Ydes = str(round(objfin.location[1] - objini.location[1], 2)) Zdes = str(round(objfin.location[2] - objini.location[2], 2)) a = [obj, str(Xdes), str(Ydes), str(Zdes)] return a def CapturaCefaloINI(): print("Nada") # global SNA_INI, SNB_INI, ANB_INI, Y_Cresc_INI, Y_Cresc_INI, SNPlO_INI, FMA_INI, FMIA_INI, IMPA_INI, NS_INI # bpy.ops.object.cefalo_calc_tudo() # SNA_INI = bpy.types.Scene.angulo_SNA[1]['default'] # SNB_INI = bpy.types.Scene.angulo_SNB[1]['default'] # ANB_INI = bpy.types.Scene.angulo_ANB[1]['default'] # Y_Cresc_INI = bpy.types.Scene.angulo_Y_Cresc[1]['default'] # SNPlO_INI = bpy.types.Scene.angulo_SNPlO[1]['default'] # FMA_INI = bpy.types.Scene.angulo_FMA[1]['default'] # FMIA_INI = bpy.types.Scene.angulo_FMIA[1]['default'] # IMPA_INI = bpy.types.Scene.angulo_IMPA[1]['default'] # NS_INI = bpy.types.Scene.angulo_NS[1]['default'] def CapturaCefaloFIN(): print("Nada") # global SNA_FIN, SNB_FIN, ANB_FIN, Y_Cresc_FIN, Y_Cresc_FIN, SNPlO_FIN, FMA_FIN, FMIA_FIN, IMPA_FIN, NS_FIN # bpy.ops.object.cefalo_calc_tudo() # SNA_FIN = bpy.types.Scene.angulo_SNA[1]['default'] # SNB_FIN = bpy.types.Scene.angulo_SNB[1]['default'] # ANB_FIN = bpy.types.Scene.angulo_ANB[1]['default'] # Y_Cresc_FIN = bpy.types.Scene.angulo_Y_Cresc[1]['default'] # SNPlO_FIN = bpy.types.Scene.angulo_SNPlO[1]['default'] # FMA_FIN = bpy.types.Scene.angulo_FMA[1]['default'] # FMIA_FIN = bpy.types.Scene.angulo_FMIA[1]['default'] # IMPA_FIN = bpy.types.Scene.angulo_IMPA[1]['default'] # NS_FIN = bpy.types.Scene.angulo_NS[1]['default'] def GeraRelatorioDef(self, context): context = bpy.context obj = context.active_object scn = context.scene # CAPTURA FRAME INICIAL frame1 = bpy.data.scenes["Scene"].frame_start obj_pre(frame1) CapturaCefaloINI() # CAPTURA FRAME INICIAL frame2 = bpy.data.scenes["Scene"].frame_end obj_pos(frame2) CapturaCefaloFIN() # Gera CSV tmpdir = tempfile.mkdtemp() ListaApagar = [] with open(tmpdir+'/Report_OrtogOnBlender.csv', mode='w') as centroid_file: report_writer = csv.writer(centroid_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) report_writer.writerow(['ORTOGONBLENDER']) report_writer.writerow(['']) try: Collection_Head = bpy.data.collections['Anatomical Points - Head'].all_objects report_writer.writerow(['HEAD']) report_writer.writerow(['ID', 'LocX', 'LocY', 'LocZ']) for ob in Collection_Head: report_writer.writerow(DeslocamentoINIFIN( ob.name+' : ', ob.name+'.INI', ob.name+'.FIN')) ListaApagar.append(ob.name+'.INI') ListaApagar.append(ob.name+'.FIN') except: print("Sem pontos da Cabeça.") try: Collection_Maxilla = bpy.data.collections['Anatomical Points - Maxilla'].all_objects report_writer.writerow(['']) report_writer.writerow(['MAXILLA']) report_writer.writerow(['ID', 'LocX', 'LocY', 'LocZ']) for ob in Collection_Maxilla: report_writer.writerow(DeslocamentoINIFIN( ob.name+' : ', ob.name+'.INI', ob.name+'.FIN')) ListaApagar.append(ob.name+'.INI') ListaApagar.append(ob.name+'.FIN') except: print("Sem pontos da Maxila.") try: Collection_Mandible = bpy.data.collections['Anatomical Points - Mandible'].all_objects report_writer.writerow(['']) report_writer.writerow(['MANDIBLE']) report_writer.writerow(['ID', 'LocX', 'LocY', 'LocZ']) for ob in Collection_Mandible: report_writer.writerow(DeslocamentoINIFIN( ob.name+' : ', ob.name+'.INI', ob.name+'.FIN')) ListaApagar.append(ob.name+'.INI') ListaApagar.append(ob.name+'.FIN') except: print("Sem pontos da Mandíbula.") try: Collection_Teeth = bpy.data.collections['Anatomical Points - Teeth'].all_objects report_writer.writerow(['']) report_writer.writerow(['TEETH']) report_writer.writerow(['ID', 'LocX', 'LocY', 'LocZ']) for ob in Collection_Teeth: report_writer.writerow(DeslocamentoINIFIN( ob.name+' : ', ob.name+'.INI', ob.name+'.FIN')) ListaApagar.append(ob.name+'.INI') ListaApagar.append(ob.name+'.FIN') except: print("Sem pontos dos Dentes.") try: Collection_SoftTissue = bpy.data.collections['Anatomical Points - Soft Tissue'].all_objects report_writer.writerow(['']) report_writer.writerow(['SOFT TISSUE']) report_writer.writerow(['ID', 'LocX', 'LocY', 'LocZ']) for ob in Collection_SoftTissue: report_writer.writerow(DeslocamentoINIFIN( ob.name+' : ', ob.name+'.INI', ob.name+'.FIN')) ListaApagar.append(ob.name+'.INI') ListaApagar.append(ob.name+'.FIN') except: print("Sem pontos do Tecido Mole.") ''' report_writer.writerow(['']) report_writer.writerow(['']) report_writer.writerow(['CEFALOMETRY']) report_writer.writerow(['ID', 'PRE', 'POST', 'RANGE']) report_writer.writerow(['SNA', str(SNA_INI), str(SNA_FIN), '80º - 84º']) report_writer.writerow(['SNB', str(SNB_INI), str(SNB_FIN), '78º - 82º']) report_writer.writerow(['ANB', str(ANB_INI), str(ANB_FIN), '0º - 4º']) report_writer.writerow(['Y_Cresc', str(Y_Cresc_INI), str(Y_Cresc_FIN), '65º - 69º']) report_writer.writerow(['SNPlO', str(SNPlO_INI), str(SNPlO_FIN), '12º - 16º']) report_writer.writerow(['FMA', str(FMA_INI), str(FMA_FIN), '23º - 27º']) report_writer.writerow(['FMIA', str(FMIA_INI), str(FMIA_FIN), '66º - 70º']) report_writer.writerow(['IMPA', str(IMPA_INI), str(IMPA_FIN), '85º - 89º']) report_writer.writerow(['1NS', str(NS_INI), str(NS_FIN), '101º - 105º']) ''' # Apaga try: for ob in ListaApagar: apagaObjeto(ob) except: print("Sem objetos INI e FIN na cena.") # subprocess.Popen("libreoffice "+tmpdir+"/Report_OrtogOnBlender.csv", shell=True) if platform.system() == "Linux": abrir_diretorio(tmpdir) subprocess.Popen("libreoffice "+tmpdir+"/Report_OrtogOnBlender.csv", shell=True) if platform.system() == "Windows": abrir_diretorio(tmpdir) subprocess.Popen('cd "C:/Program Files/LibreOffice/program/" & dir & soffice.bin '+tmpdir+"/Report_OrtogOnBlender.csv", shell=True) if platform.system() == "Darwin": abrir_diretorio(tmpdir) subprocess.Popen('/Applications/LibreOffice.app/Contents/MacOS/soffice '+tmpdir+"/Report_OrtogOnBlender.csv", shell=True) ''' # Converte em XLSX wb = Workbook() ws = wb.active with open(tmpdir+'/Report_OrtogOnBlender.csv', 'r') as f: for row in csv.reader(f): ws.append(row) wb.save(tmpdir+'/Report_OrtogOnBlender.xlsx') # AJUSTA OS TAMANHOS DAS CÉLULAS (AUTOFIT) newFile = tmpdir+'/Report_OrtogOnBlender.xlsx' wb = openpyxl.load_workbook(filename = newFile) worksheet = wb.active for col in worksheet.columns: max_length = 0 column = col[0].column # Get the column name for cell in col: try: # Necessary to avoid error on empty cells if len(str(cell.value)) > max_length: max_length = len(cell.value) except: pass adjusted_width = (max_length + 2) * 1.2 worksheet.column_dimensions[column].width = adjusted_width # wb.save(newFile) # STYLE listaFontes1 = ['A1','A3','A16','A26','A34'] for i in listaFontes1: c = worksheet[i] # c.font = Font(bold=True, name='Arial') c.font = Font(bold=True, name="Calibri") ListaCor1 = ['A3','B3','C3','D3','A16','B16','C16','D16','A26','B26','C26','D26','A34','B34','C34','D34'] for i in ListaCor1: d = worksheet[i] d.fill = PatternFill("solid", fgColor="b1e2e2") ListaCor2 = ['A4','B4','C4','D4','A17','B17','C17','D17','A27','B27','C27','D27','A35','B35','C35','D35'] for i in ListaCor2: d = worksheet[i] d.fill = PatternFill("solid", fgColor="fff9ae") wb.save(newFile) if platform.system() == "Linux": subprocess.Popen("libreoffice "+tmpdir+"/Report_OrtogOnBlender.xlsx", shell=True) if platform.system() == "Windows": abrir_diretorio(tmpdir) subprocess.Popen('cd "C:/Program Files/LibreOffice/program/" & dir & soffice.bin '+tmpdir+"/Report_OrtogOnBlender.xlsx", shell=True) if platform.system() == "Darwin": abrir_diretorio(tmpdir) subprocess.Popen('/Applications/LibreOffice.app/Contents/MacOS/soffice '+tmpdir+"/Report_OrtogOnBlender.xlsx", shell=True) ''' class GeraRelatorio(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_relatorio" bl_label = "Gera deslocamento de todos" def execute(self, context): GeraRelatorioDef(self, context) return {'FINISHED'} bpy.utils.register_class(GeraRelatorio) ================================================ FILE: ImportaObjMat.py ================================================ import bpy import platform def ImportaMaterial(impMaterial, SelObj): context = bpy.context obj = context.active_object scn = context.scene if platform.system() == "Linux" or platform.system() == "Darwin": dirScript = bpy.utils.user_resource('SCRIPTS') blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Material\\" object = impMaterial if platform.system() == "Windows": dirScript = 'C:/OrtogOnBlender/Blender280/2.80/scripts/' blendfile = dirScript+"addons/OrtogOnBlender-master/objetos.blend" section = "\\Material\\" object = impMaterial filepath = blendfile + section + object directory = blendfile + section filename = object bpy.ops.wm.append( filepath=filepath, filename=filename, directory=directory) # bpy.context.scene.render.engine = 'CYCLES' # Troca tipo renderização # Etapa de importação de material # objects = bpy.data.objects material_01 = bpy.data.materials[impMaterial] # Informa material à def obj = bpy.data.objects[SelObj] # Informa objeto à def bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) context.view_layer.objects.active = obj bpy.context.object.show_transparent = True bpy.ops.object.material_slot_add() obj.data.materials[0] = material_01 mensagem = "Beleza!" return mensagem ================================================ FILE: ListaArquivos.txt ================================================ /tmp/tmptqwi9nhvCOPY/IMG0074.dcm /tmp/tmptqwi9nhvCOPY/IMG0566.dcm /tmp/tmptqwi9nhvCOPY/IMG0574.dcm /tmp/tmptqwi9nhvCOPY/IMG0069.dcm /tmp/tmptqwi9nhvCOPY/IMG0046.dcm /tmp/tmptqwi9nhvCOPY/IMG0156.dcm /tmp/tmptqwi9nhvCOPY/IMG0135.dcm /tmp/tmptqwi9nhvCOPY/IMG0419.dcm /tmp/tmptqwi9nhvCOPY/IMG0064.dcm /tmp/tmptqwi9nhvCOPY/IMG0306.dcm /tmp/tmptqwi9nhvCOPY/IMG0254.dcm /tmp/tmptqwi9nhvCOPY/IMG0343.dcm /tmp/tmptqwi9nhvCOPY/IMG0514.dcm /tmp/tmptqwi9nhvCOPY/IMG0209.dcm /tmp/tmptqwi9nhvCOPY/IMG0024.dcm /tmp/tmptqwi9nhvCOPY/IMG0195.dcm /tmp/tmptqwi9nhvCOPY/IMG0299.dcm /tmp/tmptqwi9nhvCOPY/IMG0412.dcm /tmp/tmptqwi9nhvCOPY/IMG0421.dcm /tmp/tmptqwi9nhvCOPY/IMG0056.dcm /tmp/tmptqwi9nhvCOPY/IMG0369.dcm /tmp/tmptqwi9nhvCOPY/IMG0081.dcm /tmp/tmptqwi9nhvCOPY/IMG0404.dcm /tmp/tmptqwi9nhvCOPY/IMG0347.dcm /tmp/tmptqwi9nhvCOPY/IMG0411.dcm /tmp/tmptqwi9nhvCOPY/IMG0087.dcm /tmp/tmptqwi9nhvCOPY/IMG0501.dcm /tmp/tmptqwi9nhvCOPY/IMG0387.dcm /tmp/tmptqwi9nhvCOPY/IMG0482.dcm /tmp/tmptqwi9nhvCOPY/IMG0372.dcm /tmp/tmptqwi9nhvCOPY/IMG0546.dcm /tmp/tmptqwi9nhvCOPY/IMG0099.dcm /tmp/tmptqwi9nhvCOPY/IMG0222.dcm /tmp/tmptqwi9nhvCOPY/IMG0019.dcm /tmp/tmptqwi9nhvCOPY/IMG0393.dcm /tmp/tmptqwi9nhvCOPY/IMG0253.dcm /tmp/tmptqwi9nhvCOPY/IMG0152.dcm /tmp/tmptqwi9nhvCOPY/IMG0352.dcm /tmp/tmptqwi9nhvCOPY/IMG0132.dcm /tmp/tmptqwi9nhvCOPY/IMG0186.dcm /tmp/tmptqwi9nhvCOPY/IMG0242.dcm /tmp/tmptqwi9nhvCOPY/IMG0567.dcm /tmp/tmptqwi9nhvCOPY/IMG0447.dcm /tmp/tmptqwi9nhvCOPY/IMG0042.dcm /tmp/tmptqwi9nhvCOPY/IMG0053.dcm /tmp/tmptqwi9nhvCOPY/IMG0592.dcm /tmp/tmptqwi9nhvCOPY/IMG0250.dcm /tmp/tmptqwi9nhvCOPY/IMG0450.dcm /tmp/tmptqwi9nhvCOPY/IMG0353.dcm /tmp/tmptqwi9nhvCOPY/IMG0079.dcm /tmp/tmptqwi9nhvCOPY/IMG0119.dcm /tmp/tmptqwi9nhvCOPY/IMG0008.dcm /tmp/tmptqwi9nhvCOPY/IMG0216.dcm /tmp/tmptqwi9nhvCOPY/IMG0579.dcm /tmp/tmptqwi9nhvCOPY/IMG0062.dcm /tmp/tmptqwi9nhvCOPY/IMG0441.dcm /tmp/tmptqwi9nhvCOPY/IMG0258.dcm /tmp/tmptqwi9nhvCOPY/IMG0410.dcm /tmp/tmptqwi9nhvCOPY/IMG0374.dcm /tmp/tmptqwi9nhvCOPY/IMG0158.dcm /tmp/tmptqwi9nhvCOPY/IMG0149.dcm /tmp/tmptqwi9nhvCOPY/IMG0536.dcm /tmp/tmptqwi9nhvCOPY/IMG0114.dcm /tmp/tmptqwi9nhvCOPY/IMG0310.dcm /tmp/tmptqwi9nhvCOPY/IMG0106.dcm /tmp/tmptqwi9nhvCOPY/IMG0172.dcm /tmp/tmptqwi9nhvCOPY/IMG0206.dcm /tmp/tmptqwi9nhvCOPY/IMG0101.dcm /tmp/tmptqwi9nhvCOPY/IMG0039.dcm /tmp/tmptqwi9nhvCOPY/IMG0058.dcm /tmp/tmptqwi9nhvCOPY/IMG0040.dcm /tmp/tmptqwi9nhvCOPY/IMG0018.dcm /tmp/tmptqwi9nhvCOPY/IMG0431.dcm /tmp/tmptqwi9nhvCOPY/IMG0523.dcm /tmp/tmptqwi9nhvCOPY/IMG0287.dcm /tmp/tmptqwi9nhvCOPY/IMG0063.dcm /tmp/tmptqwi9nhvCOPY/IMG0544.dcm /tmp/tmptqwi9nhvCOPY/IMG0236.dcm /tmp/tmptqwi9nhvCOPY/IMG0500.dcm /tmp/tmptqwi9nhvCOPY/IMG0461.dcm /tmp/tmptqwi9nhvCOPY/IMG0273.dcm /tmp/tmptqwi9nhvCOPY/IMG0467.dcm /tmp/tmptqwi9nhvCOPY/IMG0354.dcm /tmp/tmptqwi9nhvCOPY/IMG0207.dcm /tmp/tmptqwi9nhvCOPY/IMG0015.dcm /tmp/tmptqwi9nhvCOPY/IMG0355.dcm /tmp/tmptqwi9nhvCOPY/IMG0423.dcm /tmp/tmptqwi9nhvCOPY/IMG0476.dcm /tmp/tmptqwi9nhvCOPY/IMG0462.dcm /tmp/tmptqwi9nhvCOPY/IMG0597.dcm /tmp/tmptqwi9nhvCOPY/IMG0521.dcm /tmp/tmptqwi9nhvCOPY/IMG0455.dcm /tmp/tmptqwi9nhvCOPY/IMG0255.dcm /tmp/tmptqwi9nhvCOPY/IMG0477.dcm /tmp/tmptqwi9nhvCOPY/IMG0388.dcm /tmp/tmptqwi9nhvCOPY/IMG0578.dcm /tmp/tmptqwi9nhvCOPY/IMG0227.dcm /tmp/tmptqwi9nhvCOPY/IMG0045.dcm /tmp/tmptqwi9nhvCOPY/IMG0377.dcm /tmp/tmptqwi9nhvCOPY/IMG0322.dcm /tmp/tmptqwi9nhvCOPY/IMG0538.dcm /tmp/tmptqwi9nhvCOPY/IMG0356.dcm /tmp/tmptqwi9nhvCOPY/IMG0555.dcm /tmp/tmptqwi9nhvCOPY/IMG0319.dcm /tmp/tmptqwi9nhvCOPY/IMG0506.dcm /tmp/tmptqwi9nhvCOPY/IMG0256.dcm /tmp/tmptqwi9nhvCOPY/IMG0213.dcm /tmp/tmptqwi9nhvCOPY/IMG0240.dcm /tmp/tmptqwi9nhvCOPY/IMG0233.dcm /tmp/tmptqwi9nhvCOPY/IMG0097.dcm /tmp/tmptqwi9nhvCOPY/IMG0530.dcm /tmp/tmptqwi9nhvCOPY/IMG0403.dcm /tmp/tmptqwi9nhvCOPY/IMG0147.dcm /tmp/tmptqwi9nhvCOPY/IMG0484.dcm /tmp/tmptqwi9nhvCOPY/IMG0145.dcm /tmp/tmptqwi9nhvCOPY/IMG0266.dcm /tmp/tmptqwi9nhvCOPY/IMG0537.dcm /tmp/tmptqwi9nhvCOPY/IMG0245.dcm /tmp/tmptqwi9nhvCOPY/IMG0175.dcm /tmp/tmptqwi9nhvCOPY/IMG0561.dcm /tmp/tmptqwi9nhvCOPY/IMG0312.dcm /tmp/tmptqwi9nhvCOPY/IMG0334.dcm /tmp/tmptqwi9nhvCOPY/IMG0384.dcm /tmp/tmptqwi9nhvCOPY/IMG0049.dcm /tmp/tmptqwi9nhvCOPY/IMG0562.dcm /tmp/tmptqwi9nhvCOPY/IMG0378.dcm /tmp/tmptqwi9nhvCOPY/IMG0420.dcm /tmp/tmptqwi9nhvCOPY/IMG0318.dcm /tmp/tmptqwi9nhvCOPY/IMG0089.dcm /tmp/tmptqwi9nhvCOPY/IMG0190.dcm /tmp/tmptqwi9nhvCOPY/IMG0272.dcm /tmp/tmptqwi9nhvCOPY/IMG0196.dcm /tmp/tmptqwi9nhvCOPY/IMG0103.dcm /tmp/tmptqwi9nhvCOPY/IMG0252.dcm /tmp/tmptqwi9nhvCOPY/IMG0122.dcm /tmp/tmptqwi9nhvCOPY/IMG0348.dcm /tmp/tmptqwi9nhvCOPY/IMG0188.dcm /tmp/tmptqwi9nhvCOPY/IMG0440.dcm /tmp/tmptqwi9nhvCOPY/IMG0449.dcm /tmp/tmptqwi9nhvCOPY/IMG0385.dcm /tmp/tmptqwi9nhvCOPY/IMG0047.dcm /tmp/tmptqwi9nhvCOPY/IMG0446.dcm /tmp/tmptqwi9nhvCOPY/IMG0333.dcm /tmp/tmptqwi9nhvCOPY/IMG0428.dcm /tmp/tmptqwi9nhvCOPY/IMG0350.dcm /tmp/tmptqwi9nhvCOPY/IMG0274.dcm /tmp/tmptqwi9nhvCOPY/IMG0111.dcm /tmp/tmptqwi9nhvCOPY/IMG0068.dcm /tmp/tmptqwi9nhvCOPY/IMG0307.dcm /tmp/tmptqwi9nhvCOPY/IMG0361.dcm /tmp/tmptqwi9nhvCOPY/IMG0159.dcm /tmp/tmptqwi9nhvCOPY/IMG0552.dcm /tmp/tmptqwi9nhvCOPY/IMG0485.dcm /tmp/tmptqwi9nhvCOPY/IMG0013.dcm /tmp/tmptqwi9nhvCOPY/IMG0210.dcm /tmp/tmptqwi9nhvCOPY/IMG0166.dcm /tmp/tmptqwi9nhvCOPY/IMG0309.dcm /tmp/tmptqwi9nhvCOPY/IMG0569.dcm /tmp/tmptqwi9nhvCOPY/IMG0025.dcm /tmp/tmptqwi9nhvCOPY/IMG0263.dcm /tmp/tmptqwi9nhvCOPY/IMG0478.dcm /tmp/tmptqwi9nhvCOPY/IMG0491.dcm /tmp/tmptqwi9nhvCOPY/IMG0284.dcm /tmp/tmptqwi9nhvCOPY/IMG0279.dcm /tmp/tmptqwi9nhvCOPY/IMG0535.dcm /tmp/tmptqwi9nhvCOPY/IMG0328.dcm /tmp/tmptqwi9nhvCOPY/IMG0407.dcm /tmp/tmptqwi9nhvCOPY/IMG0585.dcm /tmp/tmptqwi9nhvCOPY/IMG0533.dcm /tmp/tmptqwi9nhvCOPY/IMG0178.dcm /tmp/tmptqwi9nhvCOPY/IMG0594.dcm /tmp/tmptqwi9nhvCOPY/IMG0422.dcm /tmp/tmptqwi9nhvCOPY/IMG0073.dcm /tmp/tmptqwi9nhvCOPY/IMG0487.dcm /tmp/tmptqwi9nhvCOPY/IMG0054.dcm /tmp/tmptqwi9nhvCOPY/IMG0123.dcm /tmp/tmptqwi9nhvCOPY/IMG0231.dcm /tmp/tmptqwi9nhvCOPY/IMG0199.dcm /tmp/tmptqwi9nhvCOPY/IMG0436.dcm /tmp/tmptqwi9nhvCOPY/IMG0468.dcm /tmp/tmptqwi9nhvCOPY/IMG0078.dcm /tmp/tmptqwi9nhvCOPY/IMG0037.dcm /tmp/tmptqwi9nhvCOPY/IMG0550.dcm /tmp/tmptqwi9nhvCOPY/IMG0129.dcm /tmp/tmptqwi9nhvCOPY/IMG0143.dcm /tmp/tmptqwi9nhvCOPY/IMG0311.dcm /tmp/tmptqwi9nhvCOPY/IMG0105.dcm /tmp/tmptqwi9nhvCOPY/IMG0173.dcm /tmp/tmptqwi9nhvCOPY/IMG0475.dcm /tmp/tmptqwi9nhvCOPY/IMG0269.dcm /tmp/tmptqwi9nhvCOPY/IMG0002.dcm /tmp/tmptqwi9nhvCOPY/IMG0297.dcm /tmp/tmptqwi9nhvCOPY/IMG0324.dcm /tmp/tmptqwi9nhvCOPY/IMG0109.dcm /tmp/tmptqwi9nhvCOPY/IMG0575.dcm /tmp/tmptqwi9nhvCOPY/IMG0094.dcm /tmp/tmptqwi9nhvCOPY/IMG0497.dcm /tmp/tmptqwi9nhvCOPY/IMG0009.dcm /tmp/tmptqwi9nhvCOPY/IMG0367.dcm /tmp/tmptqwi9nhvCOPY/IMG0444.dcm /tmp/tmptqwi9nhvCOPY/IMG0150.dcm /tmp/tmptqwi9nhvCOPY/IMG0479.dcm /tmp/tmptqwi9nhvCOPY/IMG0465.dcm /tmp/tmptqwi9nhvCOPY/IMG0241.dcm /tmp/tmptqwi9nhvCOPY/IMG0383.dcm /tmp/tmptqwi9nhvCOPY/IMG0390.dcm /tmp/tmptqwi9nhvCOPY/IMG0185.dcm /tmp/tmptqwi9nhvCOPY/IMG0076.dcm /tmp/tmptqwi9nhvCOPY/IMG0362.dcm /tmp/tmptqwi9nhvCOPY/IMG0401.dcm /tmp/tmptqwi9nhvCOPY/IMG0003.dcm /tmp/tmptqwi9nhvCOPY/IMG0365.dcm /tmp/tmptqwi9nhvCOPY/IMG0118.dcm /tmp/tmptqwi9nhvCOPY/IMG0184.dcm /tmp/tmptqwi9nhvCOPY/IMG0259.dcm /tmp/tmptqwi9nhvCOPY/IMG0576.dcm /tmp/tmptqwi9nhvCOPY/IMG0330.dcm /tmp/tmptqwi9nhvCOPY/IMG0534.dcm /tmp/tmptqwi9nhvCOPY/IMG0221.dcm /tmp/tmptqwi9nhvCOPY/IMG0160.dcm /tmp/tmptqwi9nhvCOPY/IMG0522.dcm /tmp/tmptqwi9nhvCOPY/IMG0032.dcm /tmp/tmptqwi9nhvCOPY/IMG0059.dcm /tmp/tmptqwi9nhvCOPY/IMG0338.dcm /tmp/tmptqwi9nhvCOPY/IMG0486.dcm /tmp/tmptqwi9nhvCOPY/IMG0121.dcm /tmp/tmptqwi9nhvCOPY/IMG0408.dcm /tmp/tmptqwi9nhvCOPY/IMG0515.dcm /tmp/tmptqwi9nhvCOPY/IMG0179.dcm /tmp/tmptqwi9nhvCOPY/IMG0177.dcm /tmp/tmptqwi9nhvCOPY/IMG0473.dcm /tmp/tmptqwi9nhvCOPY/IMG0265.dcm /tmp/tmptqwi9nhvCOPY/IMG0205.dcm /tmp/tmptqwi9nhvCOPY/IMG0433.dcm /tmp/tmptqwi9nhvCOPY/IMG0571.dcm /tmp/tmptqwi9nhvCOPY/IMG0113.dcm /tmp/tmptqwi9nhvCOPY/IMG0451.dcm /tmp/tmptqwi9nhvCOPY/IMG0547.dcm /tmp/tmptqwi9nhvCOPY/IMG0329.dcm /tmp/tmptqwi9nhvCOPY/IMG0373.dcm /tmp/tmptqwi9nhvCOPY/IMG0601.dcm /tmp/tmptqwi9nhvCOPY/IMG0144.dcm /tmp/tmptqwi9nhvCOPY/IMG0285.dcm /tmp/tmptqwi9nhvCOPY/IMG0397.dcm /tmp/tmptqwi9nhvCOPY/IMG0291.dcm /tmp/tmptqwi9nhvCOPY/IMG0014.dcm /tmp/tmptqwi9nhvCOPY/IMG0531.dcm /tmp/tmptqwi9nhvCOPY/IMG0495.dcm /tmp/tmptqwi9nhvCOPY/IMG0581.dcm /tmp/tmptqwi9nhvCOPY/IMG0246.dcm /tmp/tmptqwi9nhvCOPY/IMG0358.dcm /tmp/tmptqwi9nhvCOPY/IMG0098.dcm /tmp/tmptqwi9nhvCOPY/IMG0088.dcm /tmp/tmptqwi9nhvCOPY/IMG0438.dcm /tmp/tmptqwi9nhvCOPY/IMG0060.dcm /tmp/tmptqwi9nhvCOPY/IMG0001.dcm /tmp/tmptqwi9nhvCOPY/IMG0075.dcm /tmp/tmptqwi9nhvCOPY/IMG0235.dcm /tmp/tmptqwi9nhvCOPY/IMG0104.dcm /tmp/tmptqwi9nhvCOPY/IMG0582.dcm /tmp/tmptqwi9nhvCOPY/IMG0043.dcm /tmp/tmptqwi9nhvCOPY/IMG0007.dcm /tmp/tmptqwi9nhvCOPY/IMG0549.dcm /tmp/tmptqwi9nhvCOPY/IMG0137.dcm /tmp/tmptqwi9nhvCOPY/IMG0472.dcm /tmp/tmptqwi9nhvCOPY/IMG0389.dcm /tmp/tmptqwi9nhvCOPY/IMG0474.dcm /tmp/tmptqwi9nhvCOPY/IMG0117.dcm /tmp/tmptqwi9nhvCOPY/IMG0202.dcm /tmp/tmptqwi9nhvCOPY/IMG0138.dcm /tmp/tmptqwi9nhvCOPY/IMG0036.dcm /tmp/tmptqwi9nhvCOPY/IMG0368.dcm /tmp/tmptqwi9nhvCOPY/IMG0092.dcm /tmp/tmptqwi9nhvCOPY/IMG0203.dcm /tmp/tmptqwi9nhvCOPY/IMG0427.dcm /tmp/tmptqwi9nhvCOPY/IMG0277.dcm /tmp/tmptqwi9nhvCOPY/IMG0165.dcm /tmp/tmptqwi9nhvCOPY/IMG0327.dcm /tmp/tmptqwi9nhvCOPY/IMG0217.dcm /tmp/tmptqwi9nhvCOPY/IMG0382.dcm /tmp/tmptqwi9nhvCOPY/IMG0041.dcm /tmp/tmptqwi9nhvCOPY/IMG0211.dcm /tmp/tmptqwi9nhvCOPY/IMG0090.dcm /tmp/tmptqwi9nhvCOPY/IMG0084.dcm /tmp/tmptqwi9nhvCOPY/IMG0357.dcm /tmp/tmptqwi9nhvCOPY/IMG0548.dcm /tmp/tmptqwi9nhvCOPY/IMG0151.dcm /tmp/tmptqwi9nhvCOPY/IMG0557.dcm /tmp/tmptqwi9nhvCOPY/IMG0435.dcm /tmp/tmptqwi9nhvCOPY/IMG0218.dcm /tmp/tmptqwi9nhvCOPY/IMG0187.dcm /tmp/tmptqwi9nhvCOPY/IMG0083.dcm /tmp/tmptqwi9nhvCOPY/IMG0512.dcm /tmp/tmptqwi9nhvCOPY/IMG0293.dcm /tmp/tmptqwi9nhvCOPY/IMG0116.dcm /tmp/tmptqwi9nhvCOPY/IMG0399.dcm /tmp/tmptqwi9nhvCOPY/IMG0174.dcm /tmp/tmptqwi9nhvCOPY/IMG0381.dcm /tmp/tmptqwi9nhvCOPY/IMG0021.dcm /tmp/tmptqwi9nhvCOPY/IMG0541.dcm /tmp/tmptqwi9nhvCOPY/IMG0257.dcm /tmp/tmptqwi9nhvCOPY/IMG0392.dcm /tmp/tmptqwi9nhvCOPY/IMG0051.dcm /tmp/tmptqwi9nhvCOPY/IMG0224.dcm /tmp/tmptqwi9nhvCOPY/IMG0080.dcm /tmp/tmptqwi9nhvCOPY/IMG0502.dcm /tmp/tmptqwi9nhvCOPY/IMG0208.dcm /tmp/tmptqwi9nhvCOPY/IMG0349.dcm /tmp/tmptqwi9nhvCOPY/IMG0336.dcm /tmp/tmptqwi9nhvCOPY/IMG0553.dcm /tmp/tmptqwi9nhvCOPY/IMG0276.dcm /tmp/tmptqwi9nhvCOPY/IMG0238.dcm /tmp/tmptqwi9nhvCOPY/IMG0228.dcm /tmp/tmptqwi9nhvCOPY/IMG0580.dcm /tmp/tmptqwi9nhvCOPY/IMG0162.dcm /tmp/tmptqwi9nhvCOPY/IMG0509.dcm /tmp/tmptqwi9nhvCOPY/IMG0588.dcm /tmp/tmptqwi9nhvCOPY/IMG0425.dcm /tmp/tmptqwi9nhvCOPY/IMG0591.dcm /tmp/tmptqwi9nhvCOPY/IMG0498.dcm /tmp/tmptqwi9nhvCOPY/IMG0414.dcm /tmp/tmptqwi9nhvCOPY/IMG0316.dcm /tmp/tmptqwi9nhvCOPY/IMG0219.dcm /tmp/tmptqwi9nhvCOPY/IMG0005.dcm /tmp/tmptqwi9nhvCOPY/IMG0065.dcm /tmp/tmptqwi9nhvCOPY/IMG0505.dcm /tmp/tmptqwi9nhvCOPY/IMG0315.dcm /tmp/tmptqwi9nhvCOPY/IMG0154.dcm /tmp/tmptqwi9nhvCOPY/IMG0593.dcm /tmp/tmptqwi9nhvCOPY/IMG0023.dcm /tmp/tmptqwi9nhvCOPY/IMG0507.dcm /tmp/tmptqwi9nhvCOPY/IMG0590.dcm /tmp/tmptqwi9nhvCOPY/IMG0016.dcm /tmp/tmptqwi9nhvCOPY/IMG0071.dcm /tmp/tmptqwi9nhvCOPY/IMG0405.dcm /tmp/tmptqwi9nhvCOPY/IMG0262.dcm /tmp/tmptqwi9nhvCOPY/IMG0010.dcm /tmp/tmptqwi9nhvCOPY/IMG0091.dcm /tmp/tmptqwi9nhvCOPY/IMG0234.dcm /tmp/tmptqwi9nhvCOPY/IMG0225.dcm /tmp/tmptqwi9nhvCOPY/IMG0603.dcm /tmp/tmptqwi9nhvCOPY/IMG0077.dcm /tmp/tmptqwi9nhvCOPY/IMG0300.dcm /tmp/tmptqwi9nhvCOPY/IMG0520.dcm /tmp/tmptqwi9nhvCOPY/IMG0323.dcm /tmp/tmptqwi9nhvCOPY/IMG0516.dcm /tmp/tmptqwi9nhvCOPY/IMG0568.dcm /tmp/tmptqwi9nhvCOPY/IMG0466.dcm /tmp/tmptqwi9nhvCOPY/IMG0004.dcm /tmp/tmptqwi9nhvCOPY/IMG0292.dcm /tmp/tmptqwi9nhvCOPY/IMG0230.dcm /tmp/tmptqwi9nhvCOPY/IMG0442.dcm /tmp/tmptqwi9nhvCOPY/IMG0586.dcm /tmp/tmptqwi9nhvCOPY/IMG0464.dcm /tmp/tmptqwi9nhvCOPY/IMG0220.dcm /tmp/tmptqwi9nhvCOPY/IMG0424.dcm /tmp/tmptqwi9nhvCOPY/IMG0560.dcm /tmp/tmptqwi9nhvCOPY/IMG0251.dcm /tmp/tmptqwi9nhvCOPY/IMG0481.dcm /tmp/tmptqwi9nhvCOPY/IMG0131.dcm /tmp/tmptqwi9nhvCOPY/IMG0082.dcm /tmp/tmptqwi9nhvCOPY/IMG0303.dcm /tmp/tmptqwi9nhvCOPY/IMG0223.dcm /tmp/tmptqwi9nhvCOPY/IMG0331.dcm /tmp/tmptqwi9nhvCOPY/IMG0429.dcm /tmp/tmptqwi9nhvCOPY/IMG0342.dcm /tmp/tmptqwi9nhvCOPY/IMG0183.dcm /tmp/tmptqwi9nhvCOPY/IMG0020.dcm /tmp/tmptqwi9nhvCOPY/IMG0061.dcm /tmp/tmptqwi9nhvCOPY/IMG0108.dcm /tmp/tmptqwi9nhvCOPY/IMG0340.dcm /tmp/tmptqwi9nhvCOPY/IMG0398.dcm /tmp/tmptqwi9nhvCOPY/IMG0128.dcm /tmp/tmptqwi9nhvCOPY/IMG0146.dcm /tmp/tmptqwi9nhvCOPY/IMG0376.dcm /tmp/tmptqwi9nhvCOPY/IMG0339.dcm /tmp/tmptqwi9nhvCOPY/IMG0181.dcm /tmp/tmptqwi9nhvCOPY/IMG0270.dcm /tmp/tmptqwi9nhvCOPY/IMG0439.dcm /tmp/tmptqwi9nhvCOPY/IMG0006.dcm /tmp/tmptqwi9nhvCOPY/IMG0456.dcm /tmp/tmptqwi9nhvCOPY/IMG0483.dcm /tmp/tmptqwi9nhvCOPY/IMG0370.dcm /tmp/tmptqwi9nhvCOPY/IMG0504.dcm /tmp/tmptqwi9nhvCOPY/IMG0394.dcm /tmp/tmptqwi9nhvCOPY/IMG0418.dcm /tmp/tmptqwi9nhvCOPY/IMG0313.dcm /tmp/tmptqwi9nhvCOPY/IMG0321.dcm /tmp/tmptqwi9nhvCOPY/IMG0086.dcm /tmp/tmptqwi9nhvCOPY/IMG0164.dcm /tmp/tmptqwi9nhvCOPY/IMG0573.dcm /tmp/tmptqwi9nhvCOPY/IMG0170.dcm /tmp/tmptqwi9nhvCOPY/IMG0375.dcm /tmp/tmptqwi9nhvCOPY/IMG0558.dcm /tmp/tmptqwi9nhvCOPY/IMG0426.dcm /tmp/tmptqwi9nhvCOPY/IMG0517.dcm /tmp/tmptqwi9nhvCOPY/IMG0559.dcm /tmp/tmptqwi9nhvCOPY/IMG0445.dcm /tmp/tmptqwi9nhvCOPY/IMG0344.dcm /tmp/tmptqwi9nhvCOPY/IMG0212.dcm /tmp/tmptqwi9nhvCOPY/IMG0345.dcm /tmp/tmptqwi9nhvCOPY/IMG0539.dcm /tmp/tmptqwi9nhvCOPY/IMG0395.dcm /tmp/tmptqwi9nhvCOPY/IMG0139.dcm /tmp/tmptqwi9nhvCOPY/IMG0126.dcm /tmp/tmptqwi9nhvCOPY/IMG0391.dcm /tmp/tmptqwi9nhvCOPY/IMG0237.dcm /tmp/tmptqwi9nhvCOPY/IMG0197.dcm /tmp/tmptqwi9nhvCOPY/IMG0542.dcm /tmp/tmptqwi9nhvCOPY/IMG0248.dcm /tmp/tmptqwi9nhvCOPY/IMG0215.dcm /tmp/tmptqwi9nhvCOPY/IMG0337.dcm /tmp/tmptqwi9nhvCOPY/IMG0400.dcm /tmp/tmptqwi9nhvCOPY/IMG0460.dcm /tmp/tmptqwi9nhvCOPY/IMG0148.dcm /tmp/tmptqwi9nhvCOPY/IMG0033.dcm /tmp/tmptqwi9nhvCOPY/IMG0280.dcm /tmp/tmptqwi9nhvCOPY/IMG0584.dcm /tmp/tmptqwi9nhvCOPY/IMG0458.dcm /tmp/tmptqwi9nhvCOPY/IMG0232.dcm /tmp/tmptqwi9nhvCOPY/IMG0226.dcm /tmp/tmptqwi9nhvCOPY/IMG0100.dcm /tmp/tmptqwi9nhvCOPY/IMG0044.dcm /tmp/tmptqwi9nhvCOPY/IMG0589.dcm /tmp/tmptqwi9nhvCOPY/IMG0120.dcm /tmp/tmptqwi9nhvCOPY/IMG0115.dcm /tmp/tmptqwi9nhvCOPY/IMG0320.dcm /tmp/tmptqwi9nhvCOPY/IMG0110.dcm /tmp/tmptqwi9nhvCOPY/IMG0386.dcm /tmp/tmptqwi9nhvCOPY/IMG0155.dcm /tmp/tmptqwi9nhvCOPY/IMG0503.dcm /tmp/tmptqwi9nhvCOPY/IMG0011.dcm /tmp/tmptqwi9nhvCOPY/IMG0095.dcm /tmp/tmptqwi9nhvCOPY/IMG0264.dcm /tmp/tmptqwi9nhvCOPY/IMG0332.dcm /tmp/tmptqwi9nhvCOPY/IMG0193.dcm /tmp/tmptqwi9nhvCOPY/IMG0526.dcm /tmp/tmptqwi9nhvCOPY/IMG0499.dcm /tmp/tmptqwi9nhvCOPY/IMG0599.dcm /tmp/tmptqwi9nhvCOPY/IMG0295.dcm /tmp/tmptqwi9nhvCOPY/IMG0363.dcm /tmp/tmptqwi9nhvCOPY/IMG0028.dcm /tmp/tmptqwi9nhvCOPY/IMG0471.dcm /tmp/tmptqwi9nhvCOPY/IMG0294.dcm /tmp/tmptqwi9nhvCOPY/IMG0406.dcm /tmp/tmptqwi9nhvCOPY/IMG0031.dcm /tmp/tmptqwi9nhvCOPY/IMG0302.dcm /tmp/tmptqwi9nhvCOPY/IMG0169.dcm /tmp/tmptqwi9nhvCOPY/IMG0249.dcm /tmp/tmptqwi9nhvCOPY/IMG0570.dcm /tmp/tmptqwi9nhvCOPY/IMG0524.dcm /tmp/tmptqwi9nhvCOPY/IMG0161.dcm /tmp/tmptqwi9nhvCOPY/IMG0602.dcm /tmp/tmptqwi9nhvCOPY/IMG0180.dcm /tmp/tmptqwi9nhvCOPY/IMG0496.dcm /tmp/tmptqwi9nhvCOPY/IMG0026.dcm /tmp/tmptqwi9nhvCOPY/IMG0563.dcm /tmp/tmptqwi9nhvCOPY/IMG0463.dcm /tmp/tmptqwi9nhvCOPY/IMG0457.dcm /tmp/tmptqwi9nhvCOPY/IMG0554.dcm /tmp/tmptqwi9nhvCOPY/IMG0416.dcm /tmp/tmptqwi9nhvCOPY/IMG0243.dcm /tmp/tmptqwi9nhvCOPY/IMG0283.dcm /tmp/tmptqwi9nhvCOPY/IMG0127.dcm /tmp/tmptqwi9nhvCOPY/IMG0325.dcm /tmp/tmptqwi9nhvCOPY/IMG0454.dcm /tmp/tmptqwi9nhvCOPY/IMG0289.dcm /tmp/tmptqwi9nhvCOPY/IMG0430.dcm /tmp/tmptqwi9nhvCOPY/IMG0510.dcm /tmp/tmptqwi9nhvCOPY/IMG0182.dcm /tmp/tmptqwi9nhvCOPY/IMG0308.dcm /tmp/tmptqwi9nhvCOPY/IMG0489.dcm /tmp/tmptqwi9nhvCOPY/IMG0314.dcm /tmp/tmptqwi9nhvCOPY/IMG0275.dcm /tmp/tmptqwi9nhvCOPY/IMG0360.dcm /tmp/tmptqwi9nhvCOPY/IMG0396.dcm /tmp/tmptqwi9nhvCOPY/IMG0072.dcm /tmp/tmptqwi9nhvCOPY/IMG0434.dcm /tmp/tmptqwi9nhvCOPY/IMG0096.dcm /tmp/tmptqwi9nhvCOPY/IMG0380.dcm /tmp/tmptqwi9nhvCOPY/IMG0027.dcm /tmp/tmptqwi9nhvCOPY/IMG0359.dcm /tmp/tmptqwi9nhvCOPY/IMG0304.dcm /tmp/tmptqwi9nhvCOPY/IMG0413.dcm /tmp/tmptqwi9nhvCOPY/IMG0443.dcm /tmp/tmptqwi9nhvCOPY/IMG0492.dcm /tmp/tmptqwi9nhvCOPY/IMG0527.dcm /tmp/tmptqwi9nhvCOPY/IMG0364.dcm /tmp/tmptqwi9nhvCOPY/IMG0493.dcm /tmp/tmptqwi9nhvCOPY/IMG0572.dcm /tmp/tmptqwi9nhvCOPY/IMG0480.dcm /tmp/tmptqwi9nhvCOPY/IMG0229.dcm /tmp/tmptqwi9nhvCOPY/IMG0543.dcm /tmp/tmptqwi9nhvCOPY/IMG0305.dcm /tmp/tmptqwi9nhvCOPY/IMG0513.dcm /tmp/tmptqwi9nhvCOPY/IMG0034.dcm /tmp/tmptqwi9nhvCOPY/IMG0038.dcm /tmp/tmptqwi9nhvCOPY/IMG0048.dcm /tmp/tmptqwi9nhvCOPY/IMG0102.dcm /tmp/tmptqwi9nhvCOPY/IMG0605.dcm /tmp/tmptqwi9nhvCOPY/IMG0298.dcm /tmp/tmptqwi9nhvCOPY/IMG0030.dcm /tmp/tmptqwi9nhvCOPY/IMG0271.dcm /tmp/tmptqwi9nhvCOPY/IMG0066.dcm /tmp/tmptqwi9nhvCOPY/IMG0017.dcm /tmp/tmptqwi9nhvCOPY/IMG0200.dcm /tmp/tmptqwi9nhvCOPY/IMG0351.dcm /tmp/tmptqwi9nhvCOPY/IMG0437.dcm /tmp/tmptqwi9nhvCOPY/IMG0432.dcm /tmp/tmptqwi9nhvCOPY/IMG0112.dcm /tmp/tmptqwi9nhvCOPY/IMG0239.dcm /tmp/tmptqwi9nhvCOPY/IMG0290.dcm /tmp/tmptqwi9nhvCOPY/IMG0488.dcm /tmp/tmptqwi9nhvCOPY/IMG0204.dcm /tmp/tmptqwi9nhvCOPY/IMG0012.dcm /tmp/tmptqwi9nhvCOPY/IMG0366.dcm /tmp/tmptqwi9nhvCOPY/IMG0415.dcm /tmp/tmptqwi9nhvCOPY/IMG0029.dcm /tmp/tmptqwi9nhvCOPY/IMG0124.dcm /tmp/tmptqwi9nhvCOPY/IMG0371.dcm /tmp/tmptqwi9nhvCOPY/IMG0604.dcm /tmp/tmptqwi9nhvCOPY/IMG0198.dcm /tmp/tmptqwi9nhvCOPY/IMG0596.dcm /tmp/tmptqwi9nhvCOPY/IMG0134.dcm /tmp/tmptqwi9nhvCOPY/IMG0346.dcm /tmp/tmptqwi9nhvCOPY/IMG0163.dcm /tmp/tmptqwi9nhvCOPY/IMG0244.dcm /tmp/tmptqwi9nhvCOPY/IMG0452.dcm /tmp/tmptqwi9nhvCOPY/IMG0286.dcm /tmp/tmptqwi9nhvCOPY/IMG0133.dcm /tmp/tmptqwi9nhvCOPY/IMG0214.dcm /tmp/tmptqwi9nhvCOPY/IMG0518.dcm /tmp/tmptqwi9nhvCOPY/IMG0278.dcm /tmp/tmptqwi9nhvCOPY/IMG0107.dcm /tmp/tmptqwi9nhvCOPY/IMG0556.dcm /tmp/tmptqwi9nhvCOPY/IMG0528.dcm /tmp/tmptqwi9nhvCOPY/IMG0525.dcm /tmp/tmptqwi9nhvCOPY/IMG0191.dcm /tmp/tmptqwi9nhvCOPY/IMG0052.dcm /tmp/tmptqwi9nhvCOPY/IMG0093.dcm /tmp/tmptqwi9nhvCOPY/IMG0050.dcm /tmp/tmptqwi9nhvCOPY/IMG0453.dcm /tmp/tmptqwi9nhvCOPY/IMG0281.dcm /tmp/tmptqwi9nhvCOPY/IMG0067.dcm /tmp/tmptqwi9nhvCOPY/IMG0176.dcm /tmp/tmptqwi9nhvCOPY/IMG0409.dcm /tmp/tmptqwi9nhvCOPY/IMG0519.dcm /tmp/tmptqwi9nhvCOPY/IMG0125.dcm /tmp/tmptqwi9nhvCOPY/IMG0168.dcm /tmp/tmptqwi9nhvCOPY/IMG0565.dcm /tmp/tmptqwi9nhvCOPY/IMG0136.dcm /tmp/tmptqwi9nhvCOPY/IMG0141.dcm /tmp/tmptqwi9nhvCOPY/IMG0606.dcm /tmp/tmptqwi9nhvCOPY/IMG0511.dcm /tmp/tmptqwi9nhvCOPY/IMG0140.dcm /tmp/tmptqwi9nhvCOPY/IMG0595.dcm /tmp/tmptqwi9nhvCOPY/IMG0085.dcm /tmp/tmptqwi9nhvCOPY/IMG0600.dcm /tmp/tmptqwi9nhvCOPY/IMG0508.dcm /tmp/tmptqwi9nhvCOPY/IMG0022.dcm /tmp/tmptqwi9nhvCOPY/IMG0035.dcm /tmp/tmptqwi9nhvCOPY/IMG0341.dcm /tmp/tmptqwi9nhvCOPY/IMG0545.dcm /tmp/tmptqwi9nhvCOPY/IMG0261.dcm /tmp/tmptqwi9nhvCOPY/IMG0494.dcm /tmp/tmptqwi9nhvCOPY/IMG0260.dcm /tmp/tmptqwi9nhvCOPY/IMG0268.dcm /tmp/tmptqwi9nhvCOPY/IMG0247.dcm /tmp/tmptqwi9nhvCOPY/IMG0194.dcm /tmp/tmptqwi9nhvCOPY/IMG0142.dcm /tmp/tmptqwi9nhvCOPY/IMG0577.dcm /tmp/tmptqwi9nhvCOPY/IMG0282.dcm /tmp/tmptqwi9nhvCOPY/IMG0448.dcm /tmp/tmptqwi9nhvCOPY/IMG0189.dcm /tmp/tmptqwi9nhvCOPY/IMG0540.dcm /tmp/tmptqwi9nhvCOPY/IMG0326.dcm /tmp/tmptqwi9nhvCOPY/IMG0296.dcm /tmp/tmptqwi9nhvCOPY/IMG0490.dcm /tmp/tmptqwi9nhvCOPY/IMG0288.dcm /tmp/tmptqwi9nhvCOPY/IMG0130.dcm /tmp/tmptqwi9nhvCOPY/IMG0417.dcm /tmp/tmptqwi9nhvCOPY/IMG0564.dcm /tmp/tmptqwi9nhvCOPY/IMG0057.dcm /tmp/tmptqwi9nhvCOPY/IMG0598.dcm /tmp/tmptqwi9nhvCOPY/IMG0532.dcm /tmp/tmptqwi9nhvCOPY/IMG0335.dcm /tmp/tmptqwi9nhvCOPY/IMG0070.dcm /tmp/tmptqwi9nhvCOPY/IMG0171.dcm /tmp/tmptqwi9nhvCOPY/IMG0055.dcm /tmp/tmptqwi9nhvCOPY/IMG0201.dcm /tmp/tmptqwi9nhvCOPY/IMG0551.dcm /tmp/tmptqwi9nhvCOPY/IMG0402.dcm /tmp/tmptqwi9nhvCOPY/IMG0459.dcm /tmp/tmptqwi9nhvCOPY/IMG0317.dcm /tmp/tmptqwi9nhvCOPY/IMG0192.dcm /tmp/tmptqwi9nhvCOPY/IMG0587.dcm /tmp/tmptqwi9nhvCOPY/IMG0153.dcm /tmp/tmptqwi9nhvCOPY/IMG0470.dcm /tmp/tmptqwi9nhvCOPY/IMG0583.dcm /tmp/tmptqwi9nhvCOPY/IMG0379.dcm /tmp/tmptqwi9nhvCOPY/IMG0157.dcm /tmp/tmptqwi9nhvCOPY/IMG0167.dcm /tmp/tmptqwi9nhvCOPY/IMG0469.dcm /tmp/tmptqwi9nhvCOPY/IMG0529.dcm /tmp/tmptqwi9nhvCOPY/IMG0301.dcm /tmp/tmptqwi9nhvCOPY/IMG0267.dcm ================================================ FILE: MicrosGenerate3D.mlx ================================================ ================================================ FILE: NomePaciente.py ================================================ import bpy from os.path import expanduser import os # MENSAGENS class PatientName(bpy.types.Operator): bl_idname = "object.dialog_operator_patient_name" bl_label = "Please, write the patient's name and surname to save!" def execute(self, context): message = ("Teste") self.report({'INFO'}, message) return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) bpy.utils.register_class(PatientName) # CRIA DIRETÓRIO E SALVA ARQUIVO INICIAL def NomePacienteDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteDir = homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente if NomePaciente != "" and SobrenomePaciente != "": if not os.path.exists(homeDir+"/OrtogOnBlenderDir"): os.mkdir(homeDir+"/OrtogOnBlenderDir") print("Diretorio OrtogOnBlender criado") if not os.path.exists(NomePacienteDir): os.mkdir(NomePacienteDir) bpy.ops.wm.save_as_mainfile(filepath=homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Base-"+NomePaciente+"_"+SobrenomePaciente+".blend") print("Diretorio "+NomePaciente+"_"+SobrenomePaciente+" criado!") else: bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') class NomePaciente(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente" bl_label = "Gera Nome Dir Nome Paciente" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteDir = homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente # if found == False: if not os.path.exists(NomePacienteDir): return True else: if os.path.exists(NomePacienteDir): return False def execute(self, context): NomePacienteDef(self, context) return {'FINISHED'} # SALVA ARQUIVO TOMOGRAFIA def NomePacienteVoxelDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Voxel-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteVoxel(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_voxel" bl_label = "Gera Nome Dir Nome Paciente Voxel" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Voxel-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): bpy.ops.file.pack_all() NomePacienteVoxelDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteVoxel) # SALVA ARQUIVO TOMOGRAFIA def NomePacienteTomoDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/CT_Scan-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_tomo" bl_label = "Gera Nome Dir Nome Paciente Tomo" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/CT_Scan-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteTomoDef(self, context) return {'FINISHED'} # SALVA ARQUIVO TOMOGRAFIA AUTO def NomePacienteTomoAutoDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/CT_Scan_Auto-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteTomoAuto(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_tomo_auto" bl_label = "Gera Nome Dir Nome Paciente Tomo AUto" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/CT_Scan_Auto-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteTomoAutoDef(self, context) return {'FINISHED'} # SALVA ARQUIVO MOLDES def NomePacienteArcDef(self, context): context = bpy.context obj = context.object scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Arch-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo com os arcos criado!") class NomePacienteArc(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_arc" bl_label = "Gera Nome Dir Nome Paciente Tomo" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Arch-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteArcDef(self, context) return {'FINISHED'} # REFERENCIAS def NomePacienteRefDef(self, context): context = bpy.context obj = context.object scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Ref-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo com os arcos criado!") class NomePacienteRef(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_ref" bl_label = "Gera Nome Dir Nome Paciente Ref" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Ref-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteRefDef(self, context) return {'FINISHED'} # SEGMENTAÇÃO def NomePacienteSegDef(self, context): context = bpy.context obj = context.object scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Seg-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo com os arcos criado!") class NomePacienteSeg(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_seg" bl_label = "Gera Nome Dir Nome Paciente Seg" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Seg-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteSegDef(self, context) return {'FINISHED'} # FOTOGRAMETRIA def NomePacienteFotogramDef(self, context): context = bpy.context obj = context.object scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Photogram-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo com os arcos criado!") class NomePacienteFotogram(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_fotogram" bl_label = "Gera Nome Dir Nome Paciente Fotogram" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Photogram-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteFotogramDef(self, context) return {'FINISHED'} # ALINHAMENTO def NomePacienteAlinhaFaceDef(self, context): context = bpy.context obj = context.object scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Align_Face-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo com os arcos criado!") class NomePacienteAlinhaFace(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_alinha_face" bl_label = "Gera Nome Dir Nome Paciente Alinha Face" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Align_Face-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteAlinhaFaceDef(self, context) return {'FINISHED'} # ALINHAMENTO FOTO TOMO def NomePacienteAlinhaFotoTomoDef(self, context): context = bpy.context obj = context.object scn = context.scene homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Align_Photogram_CT-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo com os arcos criado!") class NomePacienteAlinhaFotoTomo(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_alinha_foto_tomo" bl_label = "Gera Nome Dir Nome Paciente Alinha Fotogram Tomo" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Align_Photogram_CT-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteAlinhaFotoTomoDef(self, context) return {'FINISHED'} # PONTOS CABEÇA def NomePacientePointsHeadDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Head-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacientePointsHead(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_points_head" bl_label = "Gera Nome Dir Nome Paciente Voxel" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Head-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacientePointsHeadDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacientePointsHead) # PONTOS MAXILA def NomePacientePointsMaxillaDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Maxilla-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacientePointsMaxilla(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_points_maxilla" bl_label = "Gera Nome Dir Nome Paciente Maxilla" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Maxilla-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacientePointsMaxillaDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacientePointsMaxilla) # PONTOS MANDÍBULA def NomePacientePointsMandibleDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Mandible-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacientePointsMandible(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_points_mandible" bl_label = "Gera Nome Dir Nome Paciente Mandible" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Mandible-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacientePointsMandibleDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacientePointsMandible) # PONTOS DENTES def NomePacientePointsTeethDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Teeth-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacientePointsTeeth(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_points_teeth" bl_label = "Gera Nome Dir Nome Paciente Teeth" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Teeth-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacientePointsTeethDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacientePointsTeeth) # PONTOS TECIDO MOLE def NomePacientePointsSoftDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Soft-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacientePointsSoft(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_points_soft" bl_label = "Gera Nome Dir Nome Paciente Soft" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Points_Soft-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacientePointsSoftDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacientePointsSoft) # PONTOS OSTEOTOMIA def NomePacienteOsteotomyDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Osteotomy-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteOsteotomy(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_osteotomy" bl_label = "Gera Nome Dir Nome Paciente Osteotomy" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Osteotomy-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteOsteotomyDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteOsteotomy) # DINÂMICA def NomePacienteDynamicDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Dynamic-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteDynamic(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_dynamic" bl_label = "Gera Nome Dir Nome Paciente Dynamic" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Dynamic-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteDynamicDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteDynamic) # CINEMÁTICA def NomePacienteKinematicDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Kinematic-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteKinematic(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_kinematic" bl_label = "Gera Nome Dir Nome Paciente Kinematic" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Kinematic-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteKinematicDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteKinematic) # GUIA E SPLINT def NomePacienteGuideDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Guide-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteGuide(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_guide" bl_label = "Gera Nome Dir Nome Paciente Guide" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Guide-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteGuideDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteGuide) def NomePacienteMarkersDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Markers-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteMarkers(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_markers" bl_label = "Gera Nome Dir Nome Paciente Markers" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Markers-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteMarkersDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteMarkers) def NomePacienteMusclesDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Muscles-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteMuscles(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_muscles" bl_label = "Gera Nome Dir Nome Paciente Muscles" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Muscles-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteMusclesDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteMuscles) def NomePacienteSculptDef(self, context): context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente if NomePaciente == "" and SobrenomePaciente == "": bpy.ops.object.dialog_operator_patient_name('INVOKE_DEFAULT') else: NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Sculpt-"+NomePaciente+"_"+SobrenomePaciente+".blend") if not os.path.exists(NomePacienteFile): bpy.ops.wm.save_as_mainfile(filepath=NomePacienteFile) print("Arquivo da tomografia criado!") class NomePacienteSculpt(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_dir_nome_paciente_sculpt" bl_label = "Gera Nome Dir Nome Paciente Sculpt" @classmethod def poll(cls, context): # found = 'Orbital right' in bpy.data.objects context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render homeDir = expanduser("~") NomePaciente = bpy.context.scene.nome_paciente SobrenomePaciente = bpy.context.scene.sobrenome_paciente NomePacienteFile = str(homeDir+"/OrtogOnBlenderDir/"+NomePaciente+"_"+SobrenomePaciente+"/Sculpt-"+NomePaciente+"_"+SobrenomePaciente+".blend") # if found == False: if not os.path.exists(NomePacienteFile): return True else: if os.path.exists(NomePacienteFile): return False def execute(self, context): NomePacienteSculptDef(self, context) return {'FINISHED'} bpy.utils.register_class(NomePacienteSculpt) bpy.utils.register_class(NomePaciente) bpy.utils.register_class(NomePacienteTomo) bpy.utils.register_class(NomePacienteTomoAuto) bpy.utils.register_class(NomePacienteArc) bpy.utils.register_class(NomePacienteRef) bpy.utils.register_class(NomePacienteSeg) bpy.utils.register_class(NomePacienteFotogram) bpy.utils.register_class(NomePacienteAlinhaFace) bpy.utils.register_class(NomePacienteAlinhaFotoTomo) ================================================ FILE: OrtogMeshes.py ================================================ import bpy from random import randint from mathutils import Matrix, Vector from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup, ) from bpy_extras.object_utils import AddObjectHelper, object_data_add # LINHA BASE def LinhaBaseDef(self, context): verts = [Vector((0, 0, 125)), Vector((0, 0, -125)), ] edges = [[0,1]] faces = [] mesh = bpy.data.meshes.new(name="LinhaBase") mesh.from_pydata(verts, edges, faces) object_data_add(context, mesh, operator=self) class LinhaBase(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_linhabase" bl_label = "Add Linha Base" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): LinhaBaseDef(self, context) return {'FINISHED'} def CriaMentoDef(self, context): verts = [Vector((-34, 22.5, 0)), Vector((34, 22.5, 0)), Vector((34, -22.5, 0)), Vector((-34, -22.5, 0)), ] edges = [] faces = [[0, 1, 2, 3]] mesh = bpy.data.meshes.new(name="Mento") mesh.from_pydata(verts, edges, faces) object_data_add(context, mesh, operator=self) bpy.ops.object.modifier_add(type='SOLIDIFY') bpy.context.object.modifiers["Solidify"].thickness = 0.3 bpy.context.object.modifiers["Solidify"].offset = 0 bpy.context.object.show_wire = True context = bpy.context activeObject = context.object mat = bpy.data.materials.new(name='Mat_'+activeObject.name) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) class CriaMento(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_mento" bl_label = "Add Mento" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaMentoDef(self, context) return {'FINISHED'} def CriaRamoDef(self, context): verts = [Vector((0, -22.5, 29.5)), Vector((0, 22.5, 29.5)), Vector((0, 22.5, -29.5)), Vector((0, -22.5, -29.5)), ] edges = [] faces = [[0, 1, 2, 3]] mesh = bpy.data.meshes.new(name="Ramo") mesh.from_pydata(verts, edges, faces) object_data_add(context, mesh, operator=self) bpy.ops.object.modifier_add(type='SOLIDIFY') bpy.context.object.modifiers["Solidify"].thickness = 0.3 bpy.context.object.modifiers["Solidify"].offset = 0 bpy.context.object.show_wire = True context = bpy.context activeObject = context.object mat = bpy.data.materials.new(name='Mat_'+activeObject.name) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) class CriaRamo(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_ramo" bl_label = "Add Ramo" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaRamoDef(self, context) return {'FINISHED'} def CriaMaxilaDef(self, context): verts = [Vector((-34, 30, 0)), Vector((-34, -30, 0)), Vector((-4, -30, 10)), Vector((-4, 30, 10)), Vector((4, 30, 10)), Vector((4, -30, 10)), Vector((34, -30, 0)), Vector((34, 30, 0)), ] edges = [] faces = [[0, 1, 2, 3],[5,4,3,2],[4, 5, 6, 7]] mesh = bpy.data.meshes.new(name="Maxila") mesh.from_pydata(verts, edges, faces) object_data_add(context, mesh, operator=self) bpy.ops.object.modifier_add(type='SOLIDIFY') bpy.context.object.modifiers["Solidify"].thickness = 0.3 bpy.context.object.modifiers["Solidify"].offset = 0 bpy.context.object.show_wire = True context = bpy.context activeObject = context.object mat = bpy.data.materials.new(name='Mat_'+activeObject.name) #set new material to variable activeObject.data.materials.append(mat) #add the material to the object activeObject.active_material.diffuse_color = (randint(20, 100)*.01, randint(20, 100)*.01, randint(20, 100)*.01, 1) class CriaMaxila(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_maxila" bl_label = "Add Maxila" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaMaxilaDef(self, context) return {'FINISHED'} # MALHA ALINHA ORIGEM def CriaMeshAlinhOrigDef(self, context): context = bpy.context vec0 = bpy.data.objects['EMP1a'].location vec1 = bpy.data.objects['EMP2a'].location vec2 = bpy.data.objects['EMP3a'].location verts = [Vector((vec0)), Vector((vec1)), Vector((vec2)), ] edges = [] faces = [[0, 1, 2]] mesh = bpy.data.meshes.new(name="MeshAlignOrigi") mesh.from_pydata(verts, edges, faces) object_data_add(context, mesh, operator=self) class CriaMeshAlinhOrig(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_mesh_alinha_origi" bl_label = "Add Mesh Align Origin" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaMeshAlinhOrigDef(self, context) bpy.context.object.location[0] = 0 bpy.context.object.location[1] = 0 bpy.context.object.location[2] = 0 bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') return {'FINISHED'} # MALHA ALINHA ORIGEM def CriaMeshAlinhAlinhDef(self, context): context = bpy.context vec0 = bpy.data.objects['EMP1b'].location vec1 = bpy.data.objects['EMP2b'].location vec2 = bpy.data.objects['EMP3b'].location verts = [Vector((vec0)), Vector((vec1)), Vector((vec2)), ] edges = [] faces = [[0, 1, 2]] mesh = bpy.data.meshes.new(name="MeshAlignAlign") mesh.from_pydata(verts, edges, faces) object_data_add(context, mesh, operator=self) class CriaMeshAlinhAlinh(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "mesh.add_mesh_alinha_alinha" bl_label = "Add Mesh Align Align" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaMeshAlinhAlinhDef(self, context) bpy.context.object.location[0] = 0 bpy.context.object.location[1] = 0 bpy.context.object.location[2] = 0 bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') return {'FINISHED'} bpy.utils.register_class(CriaMeshAlinhOrig) bpy.utils.register_class(CriaMeshAlinhAlinh) def AdicionaPlanosCorteAutoDef(): context = bpy.context obj = context.object scn = context.scene # Plano Maxila try: ListaPontos1 = [ 'Orbital right', 'Orbital left', 'A point' ] bpy.ops.object.select_all(action='DESELECT') for i in ListaPontos1: bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] # Cursor to selected for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break CursorLoc = bpy.context.scene.cursor.location bpy.ops.mesh.add_maxila(location=(CursorLoc)) bpy.ops.transform.translate(value=(0, 0, -10)) except: print("Pode estar faltando algum ponto para o plano da Maxila.") # Plano Mento try: ListaPontos1 = [ 'B point', 'Me point' ] bpy.ops.object.select_all(action='DESELECT') for i in ListaPontos1: bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] # Cursor to selected for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break CursorLoc = bpy.context.scene.cursor.location bpy.ops.mesh.add_mento(location=(CursorLoc)) except: print("Pode estar faltando algum ponto para o plano do Mento.") # Ramo Esquerdo try: ListaPontos1 = [ 'Tooth 19', 'Go left' ] bpy.ops.object.select_all(action='DESELECT') for i in ListaPontos1: bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] # Cursor to selected for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break CursorLoc = bpy.context.scene.cursor.location bpy.ops.mesh.add_ramo(location=(CursorLoc)) except: print("Pode estar faltando algum ponto para o plano do Ramo Esquerdo.") # Ramo Direito try: ListaPontos1 = [ 'Tooth 30', 'Go right' ] bpy.ops.object.select_all(action='DESELECT') for i in ListaPontos1: bpy.data.objects[i].select_set(True) context.view_layer.objects.active = bpy.data.objects[i] # Cursor to selected for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': ctx = bpy.context.copy() ctx['area'] = area ctx['region'] = area.regions[-1] # bpy.ops.view3d.view_selected(ctx) bpy.ops.view3d.snap_cursor_to_selected(ctx) break CursorLoc = bpy.context.scene.cursor.location bpy.ops.mesh.add_ramo(location=(CursorLoc)) except: print("Pode estar faltando algum ponto para o plano do Ramo Direito.") bpy.ops.wm.tool_set_by_id(name="builtin.move") class AdicionaPlanosCorteAuto(Operator, AddObjectHelper): """Create a new Mesh Object""" bl_idname = "object.adiciona_planos_corte_auto" bl_label = "Add Cut Planes Auto" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): AdicionaPlanosCorteAutoDef() return {'FINISHED'} bpy.utils.register_class(AdicionaPlanosCorteAuto) ================================================ FILE: OtherOnBlender.py ================================================ import bpy import platform from .__init__ import * from .Version import * from .FerrSegmentacao import * from .CortaOssoFibula import * from .TomoReconsRapida import * # Apagar! from .DesenhaObjetos import * from .Poisson import * from .DesenhaObjetos import * class OTHER_PT_AtualizaAddonSec(bpy.types.Panel): bl_label = "Upgrade Script" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="VERSION: "+VERSION) row = layout.row() row.operator("object.atualiza_script", text="UPGRADE OTHERTOOLS!", icon="RECOVER_LAST") bpy.utils.register_class(OTHER_PT_AtualizaAddonSec) class OTHER_PT_Converte_Video(bpy.types.Panel): bl_label = "Video to Images" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathvideo", text="") if platform.system() == "Linux": row = layout.row() row.operator("object.converte_video_imagem", text="Convert Video to Images!", icon="RENDER_STILL") if platform.system() == "Windows": row = layout.row() row.operator("object.converte_video_imagem_win", text="Convert Video to Images!", icon="RENDER_STILL") bpy.utils.register_class(OTHER_PT_Converte_Video) class OTHER_PT_Converte_Img_Tomo(bpy.types.Panel): bl_label = "Images to CT-Scan" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_slices_img", text="") row = layout.row() row.label(text="Dimensions:") row = layout.row(align = True) row.prop(context.scene, "S1") row = layout.row(align = True) row.prop(context.scene, "S2") row = layout.row(align = True) row.prop(context.scene, "S3") row = layout.row() row.operator("object.converte_imagens_tomo", text="Convert Images to CT-Scan!", icon="RENDER_STILL") row = layout.row() row = layout.row() row.label(text="Calculations:") row = layout.row(align = True) row.label(text="Real Size:") row.prop(context.scene, "MedidaRealDCM") row = layout.row(align = True) row.label(text="Current Size:") row.prop(context.scene, "MedidaAtualDCM") row = layout.row() row.operator("object.calcula_dimensao_dcm", text="Calculate!", icon="RENDER_STILL") row = layout.row(align = True) row.label(text="Scale Factor:") row.prop(context.scene, "FatorEscalaDCM") row = layout.row() row.label(text="Convert MHA to DCM:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathmha", text="") row = layout.row() row.operator("object.abre_slicer_mha", text="Open Slicer", icon="RENDER_STILL") bpy.utils.register_class(OTHER_PT_Converte_Img_Tomo) bpy.types.Scene.S1 = bpy.props.StringProperty \ ( name = "s1", description = "s1", default = "1" ) bpy.types.Scene.S2 = bpy.props.StringProperty \ ( name = "s2", description = "s2", default = "1" ) bpy.types.Scene.S3 = bpy.props.StringProperty \ ( name = "s3", description = "s3", default = "1" ) bpy.types.Scene.FatorEscalaDCM = bpy.props.StringProperty \ ( name = "", description = "Scale Factor", default = "NONE" ) bpy.types.Scene.MedidaRealDCM = bpy.props.StringProperty \ ( name = "", description = "Real Size", default = "NONE" ) bpy.types.Scene.MedidaAtualDCM = bpy.props.StringProperty \ ( name = "", description = "Current Measure", default = "NONE" ) class OTHER_PT_Objeto_para_Dicom(bpy.types.Panel): bl_label = "3D Object to CT-Scan" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # row = layout.row() # row.label(text="Dimensions:") # Add Volume Area row = layout.row() row.label(text="Setup Structure:") row = layout.row() row.operator("object.importa_voxelcube", text="Import VoxelCube", icon="MESH_CUBE") row = layout.row() row = layout.row() row.operator("object.cria_voxelcube_planos", text="Create VoxelCube Planes", icon="SNAP_VOLUME") row = layout.row() row = layout.row() circle=row.operator("object.booleana_osteo_geral", text="Difference", icon="MOD_BOOLEAN") row = layout.row() circle=row.operator("object.booleana_osteo_union", text="Union", icon="MOD_CAST") row = layout.row() circle=row.operator("object.booleana_osteo_inter", text="Intersect", icon="MOD_MASK") row = layout.row() circle=row.operator("object.booleana_union_multipla", text="MULTIPLE UNION", icon="STICKY_UVS_LOC") row = layout.row() row.label(text="Convert 3D to Voxel:") row = layout.row() row.label(text="1) Import VoxelCube.") row = layout.row() row.label(text="2) Select one or more objects.") row = layout.row() row.operator("object.converte_3d_voxel", text="Convert to DICOM!", icon="ALEMBIC") row = layout.row() row = layout.row() row.label(text="Convert MHA to DICOM:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathmha", text="") row = layout.row() row.operator("object.abre_slicer_mha", text="Open Slicer", icon="RENDER_STILL") bpy.utils.register_class(OTHER_PT_Objeto_para_Dicom) class OTHER_PT_Cut_Points(bpy.types.Panel): bl_label = "Cut Points" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # row = layout.row() # row.label(text="Dimensions:") # Add Volume Area row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.operator("object.cut_point_pt", text="Add Cut Point", icon="NODE_MATERIAL") row = layout.row() if context.window_manager.measureit_run_opengl is False: icon = 'PLAY' txt = 'Show' else: icon = "PAUSE" txt = 'Hide' row.operator("measureit.runopengl", text=txt, icon=icon) row.prop(scn, "measureit_gl_ghost", text="", icon='GHOST_ENABLED') row = layout.row() row.operator("object.cria_cotas_botao", text="Create Measures", icon="TRACKING_FORWARDS_SINGLE") row = layout.row() row.operator("object.cria_bones_fibula", text="Create Bones", icon="BONE_DATA") bpy.utils.register_class(OTHER_PT_Cut_Points) ''' class OTHER_PT_TomoReconRapida(bpy.types.Panel): bl_label = "CT-Scan Fast Reconstruction" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.gera_modelotomo_rec_rapida", text="CT-Scan Fast Recon", icon="NODE_MATERIAL") bpy.utils.register_class(OTHER_PT_TomoReconRapida) ''' class OTHER_PT_Vein(bpy.types.Panel): bl_label = "Vein and Nerves" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # row = layout.row() # row.label(text="Dimensions:") # Add Volume Area row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.operator("mesh.add_ponto_veia", text="Create Point", icon="NODE_MATERIAL") row = layout.row() row.operator("mesh.add_curva_bezier_veia", text="Create Vein or Nerve", icon="OUTLINER_OB_CURVE") bpy.utils.register_class(OTHER_PT_Vein) def CriaSplintDentesPintaDef(): # Grava a arcada selecionada context = bpy.context objArcada = context.active_object bpy.ops.object.mode_set(mode = 'OBJECT') # Cria Metabal bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.metaball_add(type='BALL', radius=1, view_align=False, enter_editmode=False, location=(0,0,0)) objMetaball = context.active_object # Seleciona a arcada bpy.ops.object.select_all(action='DESELECT') objArcada.select_set(True) bpy.context.view_layer.objects.active = objArcada # Adiciona partícula bpy.ops.object.particle_system_add() #bpy.data.particles.new("Espessura") bpy.data.particles["ParticleSettings"].type = 'HAIR' bpy.context.object.particle_systems["ParticleSettings"].vertex_group_density = "Group" bpy.data.particles["ParticleSettings"].render_type = 'OBJECT' bpy.data.particles["ParticleSettings"].instance_object = bpy.data.objects["Mball"] bpy.data.particles["ParticleSettings"].particle_size = 0.4 bpy.data.particles["ParticleSettings"].name = "DELETE" # Seleciona MBall bpy.ops.object.select_all(action='DESELECT') objMetaball.select_set(True) bpy.context.view_layer.objects.active = objMetaball objMetaball.name = "Splint_Offset" objMetaball.name = "Splint_Offset" # Converte MBall em malha bpy.ops.object.convert(target='MESH') bpy.context.view_layer.objects.active = bpy.data.objects["Splint_Offset.001"] bpy.data.objects["Splint_Offset.001"].select_set(True) bpy.data.objects["Splint_Offset.001"].name = "Splint_Offset_final" # Modificador Smooth bpy.ops.object.modifier_add(type='SMOOTH') bpy.context.object.modifiers["Smooth"].factor = 2 bpy.context.object.modifiers["Smooth"].iterations = 30 # Modificador Remesh bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 7 # Converte malha bpy.ops.object.convert(target='MESH') class CriaSplintDentesPinta(bpy.types.Operator): """Tooltip""" bl_idname = "object.cria_splint_dentes_pinta" bl_label = "Create Teeth Offset" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CriaSplintDentesPintaDef() return {'FINISHED'} bpy.utils.register_class(CriaSplintDentesPinta) class OTHER_PT_PintaOffset(bpy.types.Panel): bl_label = "Offset Splint" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Create Offset:") row = layout.row() row.operator("object.weight_1", text="Weight Paint 1", icon="COLORSET_01_VEC") row = layout.row() row.operator("object.weight_0", text="Weight Paint 0", icon="COLORSET_04_VEC") row = layout.row() row.operator("object.cria_splint_dentes_pinta", text="Create Offset!", icon="MOD_SKIN") row = layout.row() row = layout.row() row.label(text="Boolean Segmentation:") row = layout.row() # row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row.operator("object.linha_corte_fora_a_fora", icon='LINE_DATA', text="Draw Line") row = layout.row() row = layout.row() circle=row.operator("object.desenha_booleana_dentro", text="Subtract IN", icon="LIGHTPROBE_CUBEMAP") row = layout.row() circle=row.operator("object.desenha_booleana_fora", text="Subtract OUT", icon="MESH_CUBE") row = layout.row() row.label(text="Boolean:") row = layout.row() circle=row.operator("object.booleana_osteo_geral", text="Difference", icon="MOD_BOOLEAN") row = layout.row() circle=row.operator("object.booleana_osteo_union", text="Union", icon="MOD_CAST") row = layout.row() circle=row.operator("object.booleana_osteo_inter", text="Intersect", icon="MOD_MASK") row = layout.row() row = layout.row() circle=row.operator("object.booleana_union_multipla", text="MULTIPLE UNION", icon="STICKY_UVS_LOC") bpy.utils.register_class(OTHER_PT_PintaOffset) class OTHER_PT_MicrosXYZ(bpy.types.Panel): bl_label = "Atomic Force Microscope" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Others" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # row = layout.row() # row.label(text="Convert MHA to DCM:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathmha", text="") row = layout.row() row.operator("object.importa_reconstroi_xyz", text="Import and Reconstruct XYZ", icon="OVERLAY") row = layout.row() row.label(text="Draw & Cut:") row = layout.row() row.operator("wm.modal_cria_pontos_micros", icon='CURVE_DATA', text="Create Points") row = layout.row() row.operator("mesh.add_curva_bezier_unido", icon='CURVE_BEZCIRCLE', text="Create Bezier Line") row = layout.row() circle=row.operator("object.segmenta_desenho_micros", text="Cut Line!", icon="SCULPTMODE_HLT") row = layout.row() row.operator("object.fecha_buraco_todos", icon='MOD_TRIANGULATE', text="Close All Holes") bpy.utils.register_class(OTHER_PT_MicrosXYZ) ================================================ FILE: Poisson.py ================================================ import bpy import tempfile import platform import subprocess import shutil def PoissonDef(self, context): tmpdir = tempfile.mkdtemp() bpy.ops.object.modifier_add(type='SUBSURF') bpy.context.object.modifiers["Subdivision"].levels = 1 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subdivision") #bpy.ops.object.convert(target='MESH') bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.delete(type='EDGE_FACE') bpy.ops.object.editmode_toggle() bpy.ops.wm.collada_export(filepath=tmpdir+"/Pontos.dae", selected=True) if platform.system() == "Linux": subprocess.call('meshlabserver -i '+tmpdir+'/Pontos.dae -o '+tmpdir+'/Poisson.ply -s ~/Programs/OrtogOnBlender/Meshlab/Poisson.mlx -om vc fq wn', shell=True) bpy.ops.object.delete(use_global=False) bpy.ops.import_mesh.ply(filepath=tmpdir+"/Poisson.ply", files=[], directory="", filter_glob="*.ply") class Poisson(bpy.types.Operator): """Tooltip""" bl_idname = "mesh.poisson" bl_label = "Ortog Poisson" def execute(self, context): PoissonDef(self, context) return {'FINISHED'} bpy.utils.register_class(Poisson) def ReconstXYZDef(): context = bpy.context obj = context.object scn = context.scene tmpdir = tempfile.mkdtemp() dirScript = bpy.utils.user_resource('SCRIPTS') shutil.copyfile(scn.my_tool.filepathmha, tmpdir+"/file.xyz") if platform.system() == "Linux": subprocess.call('meshlabserver -i '+tmpdir+'/file.xyz -o '+tmpdir+'/ObjectXYZ.ply -s '+dirScript+'addons/OrtogOnBlender-master/MicrosGenerate3D.mlx -om', shell=True) #bpy.ops.object.delete(use_global=False) bpy.ops.import_mesh.ply(filepath=tmpdir+"/ObjectXYZ.ply", files=[], directory="", filter_glob="*.ply") bpy.context.space_data.shading.type = 'SOLID' bpy.context.space_data.shading.show_shadows = True bpy.context.space_data.shading.show_cavity = True bpy.context.space_data.shading.cavity_valley_factor = 2.5 bpy.context.space_data.shading.cavity_ridge_factor = 2.5 bpy.context.space_data.shading.cavity_type = 'BOTH' bpy.context.space_data.shading.curvature_valley_factor = 0.604167 bpy.context.space_data.shading.shadow_intensity = 0.884375 bpy.context.scene.display.matcap_ssao_distance = 0.53 # Funciona! # bpy.context.scene.matcap_ssao_distance = 0.53 # Não funciona! # bpy.context.scene.matcap_ssao_attenuation = 1 bpy.context.scene.display.light_direction = (0.666667, 0.319444, 0.673432) bpy.context.scene.display.shadow_focus = 0.270833 # bpy.context.scene.light_direction = (0.666667, 0.319444, 0.673432) # bpy.context.scene.shadow_focus = 0.270833 bpy.ops.view3d.view_selected(use_all_regions=False) class ReconstXYZ(bpy.types.Operator): """Tooltip""" bl_idname = "object.importa_reconstroi_xyz" bl_label = "Import and Reconstruc XYZ" def execute(self, context): ReconstXYZDef() return {'FINISHED'} bpy.utils.register_class(ReconstXYZ) ================================================ FILE: PontosAnatomicos.py ================================================ import bpy import bmesh from math import sqrt import fnmatch # OCULTAR MOSTRAR Pontos def PontosMostraNomesDef(self, context): ListaPontosNomesShow = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left', 'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30', 'Condylar Process right', 'Condylar Process left', 'Coronoid Process left', 'Coronoid Process right', 'Mid Go-Ramus Fracure left', 'Mid Go-Ramus Fracure right', 'Mid Upper Incisors', 'Mid Mandibula Angle left', 'Mid Mandibula Angle right', 'Radix', 'Anterior Nostril left', 'Posterior Nostril left', 'Anterior Nostril right', 'Posterior Nostril right', 'Rhinion', 'Alar Groove right', 'Alar Groove left', 'Supratip', 'Infratip Lobule', 'Columella right', 'Columella left', 'Alar Rim right', 'Alar Rim left', 'Medial Canthus left', 'Medial Canthus right', 'Lateral Canthus left', 'Lateral Canthus right', 'Trichion', 'Submental', 'Supraglabella', 'Glabella', 'Condyle Rotation Point', 'Pronasale digi', 'Exocanthus-Alar Base right digi', 'Exocanthus-Alar Base left digi', 'Cheek right digi', 'Cheek left digi', 'Alar Base right digi', 'Alar Base left digi', 'Subnasale digi', 'Cheilion-Alar Base right digi', 'Cheilion-Alar Base left digi', 'Cupid\'s Bow right digi', 'Cupid\'s Bow left digi', 'Cheilion right digi', 'Cheilion left digi', 'Lower Lip digi', 'B point soft digi', 'Pogonion soft digi', 'Pronasale real', 'Exocanthus-Alar Base right real', 'Exocanthus-Alar Base left real', 'Cheek right real', 'Cheek left real', 'Alar Base right real', 'Alar Base left real', 'Subnasale real', 'Cheilion-Alar Base right real', 'Cheilion-Alar Base left real', 'Cupid\'s Bow right real', 'Cupid\'s Bow left real', 'Cheilion right real', 'Cheilion left real', 'Lower Lip real', 'B point soft real', 'Pogonion soft real', 'Alar Cheek Groove right', 'Alar Cheek Groove left'] for i in ListaPontosNomesShow: try: bpy.data.objects[i].show_name = True except: print("Ponto", i, "ausente!") class PontosMostraNomes(bpy.types.Operator): """Tooltip""" bl_idname = "object.pontos_mostra_nomes" bl_label = "Show Anat. Points" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): PontosMostraNomesDef(self, context) return {'FINISHED'} bpy.utils.register_class(PontosMostraNomes) def PontosOcultaNomesDef(self, context): ListaPontosNomesShow = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left', 'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30', 'Condylar Process right', 'Condylar Process left', 'Coronoid Process left', 'Coronoid Process right', 'Mid Go-Ramus Fracure left', 'Mid Go-Ramus Fracure right', 'Mid Upper Incisors', 'Mid Mandibula Angle left', 'Mid Mandibula Angle right', 'Radix', 'Anterior Nostril left', 'Posterior Nostril left', 'Anterior Nostril right', 'Posterior Nostril right', 'Rhinion', 'Alar Groove right', 'Alar Groove left', 'Supratip', 'Infratip Lobule', 'Columella right', 'Columella left', 'Alar Rim right', 'Alar Rim left', 'Medial Canthus left', 'Medial Canthus right', 'Trichion', 'Submental', 'Supraglabella', 'Glabella', 'Condyle Rotation Point', 'Pronasale digi', 'Exocanthus-Alar Base right digi', 'Exocanthus-Alar Base left digi', 'Cheek right digi', 'Cheek left digi', 'Alar Base right digi', 'Alar Base left digi', 'Subnasale digi', 'Cheilion-Alar Base right digi', 'Cheilion-Alar Base left digi', 'Cupid\'s Bow right digi', 'Cupid\'s Bow left digi', 'Cheilion right digi', 'Cheilion left digi', 'Lower Lip digi', 'B point soft digi', 'Pogonion soft digi', 'Pronasale real', 'Exocanthus-Alar Base right real', 'Exocanthus-Alar Base left real', 'Cheek right real', 'Cheek left real', 'Alar Base right real', 'Alar Base left real', 'Subnasale real', 'Cheilion-Alar Base right real', 'Cheilion-Alar Base left real', 'Cupid\'s Bow right real', 'Cupid\'s Bow left real', 'Cheilion right real', 'Cheilion left real', 'Lower Lip real', 'B point soft real', 'Pogonion soft real', 'Alar Cheek Groove right', 'Alar Cheek Groove left', 'Lateral Canthus left', 'Lateral Canthus right'] for i in ListaPontosNomesShow: try: bpy.data.objects[i].show_name = False except: print("Ponto", i, "ausente!") class PontosOcultaNomes(bpy.types.Operator): """Tooltip""" bl_idname = "object.pontos_oculta_nomes" bl_label = "Hide Anat. Points" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): PontosOcultaNomesDef(self, context) return {'FINISHED'} bpy.utils.register_class(PontosOcultaNomes) def TestaPontoCollDef(): context = bpy.context obj = context.active_object scn = context.scene #Teste se há algum objeto ponto na cena aqui! ListaPontos = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left', 'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30', 'Condylar Process right', 'Condylar Process left', 'Coronoid Process left', 'Coronoid Process right', 'Mid Go-Ramus Fracure left', 'Mid Go-Ramus Fracure right', 'Mid Upper Incisors', 'Mid Mandibula Angle left', 'Mid Mandibula Angle right', 'Radix', 'Anterior Nostril left', 'Posterior Nostril left', 'Anterior Nostril right', 'Posterior Nostril right', 'Rhinion', 'Alar Groove right', 'Alar Groove left', 'Supratip', 'Infratip Lobule', 'Columella right', 'Columella left', 'Alar Rim right', 'Alar Rim left', 'Medial Canthus left', 'Medial Canthus right', 'Trichion', 'Submental', 'Supraglabella', 'Glabella', 'Condyle Rotation Point', 'Pronasale digi', 'Exocanthus-Alar Base right digi', 'Exocanthus-Alar Base left digi', 'Cheek right digi', 'Cheek left digi', 'Alar Base right digi', 'Alar Base left digi', 'Subnasale digi', 'Cheilion-Alar Base right digi', 'Cheilion-Alar Base left digi', 'Cupid\'s Bow right digi', 'Cupid\'s Bow left digi', 'Cheilion right digi', 'Cheilion left digi', 'Lower Lip digi', 'B point soft digi', 'Pogonion soft digi', 'Pronasale real', 'Exocanthus-Alar Base right real', 'Exocanthus-Alar Base left real', 'Cheek right real', 'Cheek left real', 'Alar Base right real', 'Alar Base left real', 'Subnasale real', 'Cheilion-Alar Base right real', 'Cheilion-Alar Base left real', 'Cupid\'s Bow right real', 'Cupid\'s Bow left real', 'Cheilion right real', 'Cheilion left real', 'Lower Lip real', 'B point soft real', 'Pogonion soft real', 'Alar Cheek Groove right', 'Alar Cheek Groove left', 'Lateral Canthus left', 'Lateral Canthus right'] ObjetosColletion = bpy.data.collections['Collection'].objects for i in ObjetosColletion: if i.name in ListaPontos: # print("HÁ O NOME!", i.name) objColletion = bpy.data.objects[i.name] bpy.data.collections['Collection'].objects.unlink(objColletion) def CriaPontoDef(nome, colecao): context = bpy.context obj = context.active_object scn = context.scene # bpy.ops.object.empty_add(type='PLAIN_AXES') # bpy.context.object.name = "EMP1a" # bpy.context.object.empty_draw_size = 3 # bpy.context.object.empty_display_size = 3 bpy.ops.mesh.primitive_uv_sphere_add(radius=1) bpy.context.object.name = nome bpy.context.object.show_name = True # MATERIAL ListaMateriais = [] MateriaisCena = bpy.data.materials for i in MateriaisCena: ListaMateriais.append(i.name) if 'MatAnatPoints' in ListaMateriais: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials["MatAnatPoints"] #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.45, 0.0, 0.9, 1) else: activeObject = bpy.context.active_object #Set active object to variable mat = bpy.data.materials.new(name="MatAnatPoints") #set new material to variable activeObject.data.materials.append(mat) #add the material to the object bpy.context.object.active_material.diffuse_color = (0.45, 0.0, 0.9, 1) # COLEÇÃO # Copia para a coleção determinada ListaColecoes = [] ColocoesCena = bpy.data.collections for i in ColocoesCena: ListaColecoes.append(i.name) if colecao in ListaColecoes: bpy.ops.object.collection_link(collection=colecao) # bpy.data.collections['Collection'].objects.unlink(obj) else: myCol = bpy.data.collections.new(colecao) bpy.context.scene.collection.children.link(myCol) bpy.ops.object.collection_link(collection=colecao) # bpy.data.collections['Collection'].objects.unlink(obj) # CABEÇA class Orbital_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.orbital_right_pt" bl_label = "Orbital right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Orbital right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Orbital right', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class Orbital_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.orbital_left_pt" bl_label = "Orbital left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Orbital left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Orbital left', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class N_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.n_pt" bl_label = "N point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'N point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('N point', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class Po_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.po_right" bl_label = "Po right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Po right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Po right', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class Po_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.po_left" bl_label = "Po left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Po left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Po left', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class Pt_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pt_right" bl_label = "Pt right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pt right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pt right', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class Pt_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pt_left" bl_label = "Pt left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pt left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pt left', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class Ba_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.ba_pt" bl_label = "Ba point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Ba point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Ba point', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} class S_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.s_pt" bl_label = "S point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'S point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('S point', 'Anatomical Points - Head') TestaPontoCollDef() return {'FINISHED'} # MAXILA class U1_Tip_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.u1_tip_pt" bl_label = "U1 Tip" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'U1 Tip' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('U1 Tip', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class U1_LabGenBor_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.u1_labgenbor_pt" bl_label = "U1 Labial Gengival Border" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'U1 Labial Gengival Border' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('U1 Labial Gengival Border', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class U1_LinGenBor_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.u1_lingenbor_pt" bl_label = "U1 Lingual Gengival Border" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'U1 Lingual Gengival Border' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('U1 Lingual Gengival Border', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class M_U6_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.m_u6_pt" bl_label = "M U6" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'M U6' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('M U6', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class D_U6_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.d_u6_pt" bl_label = "D U6" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'D U6' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('D U6', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class U6_Occlusal_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.u6_occlusal_pt" bl_label = "U6 Occlusal" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'U6 Occlusal' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('U6 Occlusal', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class PNS_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pns_pt" bl_label = "PNS point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'PNS point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('PNS point', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class A_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.a_pt" bl_label = "A point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'A point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('A point', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class ANS_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.ans_pt" bl_label = "ANS point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ANS point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ANS point', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} class U1_Root_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.u1_root_pt" bl_label = "U1 Root" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'U1 Root' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('U1 Root', 'Anatomical Points - Maxilla') TestaPontoCollDef() return {'FINISHED'} # MANDÍBULA class L1_Tip_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.l1_tip_pt" bl_label = "L1 Tip" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'L1 Tip' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('L1 Tip', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class L1_Root_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.l1_root_pt" bl_label = "L1 Root" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'L1 Root' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('L1 Root', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class L1_LabGenBor_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.l1_labgenbor_pt" bl_label = "L1 Labial Gengival Border" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'L1 Labial Gengival Border' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('L1 Labial Gengival Border', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class L1_LinGenBor_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.l1_lingenbor_pt" bl_label = "L1 Lingual Gengival Border" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'L1 Lingual Gengival Border' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('L1 Lingual Gengival Border', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class B_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.b_pt" bl_label = "B point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'B point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('B point', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class M_L6_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.m_l6_pt" bl_label = "M L6" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'M L6' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('M L6', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class L6_Occlusal_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.l6_occlusal_pt" bl_label = "L6 Occlusal" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'L6 Occlusal' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('L6 Occlusal', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class D_L6_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.d_l6_pt" bl_label = "D L6" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'D L6' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('D L6', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class MidRamusRight_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.mid_ramus_right_pt" bl_label = "Mid Ramus right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Ramus right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Ramus right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class MidRamusLeft_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.mid_ramus_left_pt" bl_label = "Mid Ramus left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Ramus left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Ramus left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class R_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.r_right_pt" bl_label = "R right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'R right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('R right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class R_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.r_left_pt" bl_label = "R left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'R left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('R left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Go_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.go_right_pt" bl_label = "Go right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Go right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Go right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Go_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.go_left_pt" bl_label = "Go left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Go left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Go left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Ar_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.ar_right_pt" bl_label = "Ar right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Ar right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Ar right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Ar_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.ar_left_pt" bl_label = "Ar left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Ar left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Ar left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Sigmoid_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.sigmoid_right_pt" bl_label = "Sigmoid right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Sigmoid right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Sigmoid right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Sigmoid_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.sigmoid_left_pt" bl_label = "Sigmoid left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Sigmoid left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Sigmoid left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Co_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.co_right_pt" bl_label = "Co right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Co right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Co right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Co_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.co_left_pt" bl_label = "Co left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Co left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Co left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Pg_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.pg_pt" bl_label = "Pg point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Pg point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Pg point', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Gn_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.gn_pt" bl_label = "Gn point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Gn point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Gn point', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Me_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.me_pt" bl_label = "Me point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Me point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Me point', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} class Condylar_Process_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.condylar_process_left_pt" bl_label = "Condylar Process left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Condylar Process left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Condylar Process left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Condylar_Process_left_pt) class Condylar_Process_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.condylar_process_right_pt" bl_label = "Condylar Process right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Condylar Process right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Condylar Process right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Condylar_Process_right_pt) class Coronoid_Process_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.coronoid_process_left_pt" bl_label = "Coronoid Process left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Coronoid Process left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Coronoid Process left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Coronoid_Process_left_pt) class Coronoid_Process_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.coronoid_process_right_pt" bl_label = "Coronoid Process right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Coronoid Process right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Coronoid Process right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Coronoid_Process_right_pt) class Go_Ramus_Fracure_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.go_ramus_fracure_left_pt" bl_label = "Mid Go-Ramus Fracure left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Go-Ramus Fracure left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Go-Ramus Fracure left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Go_Ramus_Fracure_left_pt) class Go_Ramus_Fracure_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.go_ramus_fracure_right_pt" bl_label = "Mid Go-Ramus Fracure right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Go-Ramus Fracure right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Go-Ramus Fracure right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Go_Ramus_Fracure_right_pt) class Mid_Mandibula_Angle_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.mid_mandibula_angle_left_pt" bl_label = "Mid Mandibula Angle left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Mandibula Angle left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Mandibula Angle left', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Mid_Mandibula_Angle_left_pt) class Mid_Mandibula_Angle_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.mid_mandibula_angle_right_pt" bl_label = "Mid Mandibula Angle right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Mandibula Angle right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Mandibula Angle right', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Mid_Mandibula_Angle_right_pt) class Mid_Upper_Incisors_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.mid_upper_incisors_pt" bl_label = "Mid Upper Incisors" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Mid Upper Incisors' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Mid Upper Incisors', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Mid_Upper_Incisors_pt) # DENTES class Tooth_8_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_8_pt" bl_label = "Tooth 8" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 8' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 8', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_8_pt) class Tooth_9_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_9_pt" bl_label = "Tooth 9" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 9' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 9', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_9_pt) class Tooth_6_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_6_pt" bl_label = "Tooth 6" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 6' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 6', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_6_pt) class Tooth_11_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_11_pt" bl_label = "Tooth 11" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 11' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 11', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_11_pt) class Tooth_3_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_3_pt" bl_label = "Tooth 3" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 3' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 3', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_3_pt) class Tooth_14_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_14_pt" bl_label = "Tooth 14" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 14' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 14', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_14_pt) class Tooth_24_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_24_pt" bl_label = "Tooth 24" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 24' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 24', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_24_pt) class Tooth_25_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_25_pt" bl_label = "Tooth 25" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 25' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 25', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_25_pt) class Tooth_22_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_22_pt" bl_label = "Tooth 22" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 22' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 22', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_22_pt) class Tooth_27_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_27_pt" bl_label = "Tooth 27" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 27' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 27', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_27_pt) class Tooth_19_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_19_pt" bl_label = "Tooth 19" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 19' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 19', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_19_pt) class Tooth_30_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tooth_30_pt" bl_label = "Tooth 30" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tooth 30' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tooth 30', 'Anatomical Points - Teeth') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tooth_30_pt) # TECIDO MOLE class ST_Glabella_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_glabella_pt" bl_label = "ST Glabella" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST Glabella' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST Glabella', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_Glabella_pt) class ST_Nasion_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_nasion_pt" bl_label = "ST Nasion" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST Nasion' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST Nasion', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_Nasion_pt) class Bridge_Nose_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.bridge_nose_pt" bl_label = "Bridge of Nose" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Bridge of Nose' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Bridge of Nose', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Bridge_Nose_pt) class Tip_Nose_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.tip_nose_pt" bl_label = "Tip of Nose" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Tip of Nose' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Tip of Nose', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Tip_Nose_pt) class Columella_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.columella_pt" bl_label = "Columalla" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Columella' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Columella', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Columella_pt) class Subnasale_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.subnasale_pt" bl_label = "Subnasale" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Subnasale' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Subnasale', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Subnasale_pt) class ST_A_point_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_a_point_pt" bl_label = "ST A point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST A point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST A point', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_A_point_pt) class Upper_Lip_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.upper_lip_pt" bl_label = "Upper Lip" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Upper Lip' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Upper Lip', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Upper_Lip_pt) class Stomion_Superius_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.stomion_superius_pt" bl_label = "Stomion Superius" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Stomion Superius' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Stomion Superius', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Stomion_Superius_pt) class Stomion_Inferius_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.stomion_inferius_pt" bl_label = "Stomion Inferius" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Stomion Inferius' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Stomion Inferius', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Stomion_Inferius_pt) class Lower_Lip_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.lower_lip_pt" bl_label = "Lower Lip" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Lower Lip' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Lower Lip', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Lower_Lip_pt) class ST_B_point_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_b_point_pt" bl_label = "ST B point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST B point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST B point', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_B_point_pt) class ST_Pogonion_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_pogonion_pt" bl_label = "ST Pogonion" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST Pogonion' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST Pogonion', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_Pogonion_pt) class ST_Gnathion_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_gnathion_pt" bl_label = "ST Gnathion" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST Gnathion' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST Gnathion', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_Gnathion_pt) class ST_Menton_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.st_menton_pt" bl_label = "ST Menton" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'ST Menton' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('ST Menton', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(ST_Menton_pt) class Throat_point_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.throat_point_pt" bl_label = "Throat point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Throat point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Throat point', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Throat_point_pt) class Subpupil_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.subpupil_right_pt" bl_label = "Subpupil right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Subpupil right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Subpupil right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Subpupil_right_pt) class Subpupil_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.subpupil_left_pt" bl_label = "Subpupil left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Subpupil left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Subpupil left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Subpupil_left_pt) class CB_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cb_right_pt" bl_label = "CB right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'CB right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('CB right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(CB_right_pt) class CB_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cb_left_pt" bl_label = "CB left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'CB left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('CB left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(CB_left_pt) class OR_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.or_right_pt" bl_label = "OR right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'OR right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('OR right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(OR_right_pt) class OR_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.or_left_pt" bl_label = "OR left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'OR left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('OR left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(OR_left_pt) class Cheekbone_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheekbone_left_pt" bl_label = "Cheekbone left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheekbone left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheekbone left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheekbone_left_pt) class Cheekbone_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.cheekbone_right_pt" bl_label = "Cheekbone right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Cheekbone right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Cheekbone right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Cheekbone_right_pt) class SP_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.sp_right_pt" bl_label = "SP right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'SP right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('SP right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(SP_right_pt) class SP_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.sp_left_pt" bl_label = "SP left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'SP left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('SP left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(SP_left_pt) class AB_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.ab_right_pt" bl_label = "AB right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'AB right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('AB right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(AB_right_pt) class AB_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.ab_left_pt" bl_label = "AB left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'AB left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('AB left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(AB_left_pt) class Head_of_Condyle_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.head_of_condyle_pt" bl_label = "Condyle Rotation Point" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Condyle Rotation Point' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Condyle Rotation Point', 'Anatomical Points - Mandible') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Head_of_Condyle_pt) class Lateral_Canthus_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.lateral_canthus_left_pt" bl_label = "Lateral Canthus left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Lateral Canthus left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Lateral Canthus left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Lateral_Canthus_left_pt) class Lateral_Canthus_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.lateral_canthus_right_pt" bl_label = "Lateral Canthus right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Lateral Canthus right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Lateral Canthus right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Lateral_Canthus_right_pt) # Parenteia pontos duro def ParenteiaPonto(ponto): bpy.ops.object.mostra_pontos_anatomicos() listaDist = [] osteotomias = [bpy.data.objects["ca"], bpy.data.objects["ma"], bpy.data.objects["cm"], bpy.data.objects["me"], bpy.data.objects["rd"], bpy.data.objects["re"]] # for item in bpy.data.objects: for item in osteotomias: # if item.hide == False and item.type == 'MESH': obj = bpy.data.objects[item.name] # print("OBJETO ATUAL", obj) # Lista os vértices do objeto if obj.mode == 'EDIT': bm = bmesh.from_edit_mesh(obj.data) vertices = bm.verts else: vertices = obj.data.vertices # Todos os vértices por vetor verts = [obj.matrix_world @ vert.co for vert in vertices] # Captura vetor do objeto referencia = bpy.data.objects[ponto].location # Calcula distância pontos def DistanciaObjs(obj1, obj2): objA = bpy.data.objects[obj1].location objB = obj2 distancia = sqrt( (objB[0] - objA[0])**2 + (objB[1] - objA[1])**2 + (objB[2] - objA[2])**2 ) return distancia for i in range(len(verts)): vertAtual = verts[i] distanciaVert = DistanciaObjs(ponto, vertAtual) listaDist.append([distanciaVert, obj.name]) listaFin = sorted(listaDist) print("MAIS PRÓXIMO!", listaFin[0]) bpy.ops.object.select_all(action='DESELECT') ObjPai = bpy.data.objects[listaFin[0][1]] ObjFilho = bpy.data.objects[ponto] ObjPai.select_set(True) ObjFilho.select_set(True) bpy.context.view_layer.objects.active = ObjPai bpy.ops.object.parent_set() bpy.ops.object.select_all(action='DESELECT') #bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) # Parenteia pontos mole def ParenteiaPontoMole(ponto): listaDist = [] obj = bpy.data.objects["SoftTissueDynamic"] # print("OBJETO ATUAL", obj) # Lista os vértices do objeto if obj.mode == 'EDIT': bm = bmesh.from_edit_mesh(obj.data) vertices = bm.verts else: vertices = obj.data.vertices # Todos os vértices por vetor verts = [obj.matrix_world @ vert.co for vert in vertices] # Captura vetor do objeto referencia = bpy.data.objects[ponto].location # Calcula distância pontos def DistanciaObjs(obj1, obj2): objA = bpy.data.objects[obj1].location objB = obj2 distancia = sqrt( (objB[0] - objA[0])**2 + (objB[1] - objA[1])**2 + (objB[2] - objA[2])**2 ) return distancia for i in range(len(verts)): vertAtual = verts[i] distanciaVert = DistanciaObjs(ponto, vertAtual) listaDist.append([distanciaVert, i]) listaFin = sorted(listaDist) print("MAIS PRÓXIMO!", listaFin[0]) bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.mesh.select_all(action = 'DESELECT') bpy.ops.object.mode_set(mode = 'OBJECT') # Quebra aqui obj.data.vertices[listaFin[0][1]].select = True bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.object.mode_set(mode = 'OBJECT') bpy.ops.object.select_all(action='DESELECT') b = bpy.data.objects[ponto] b.select_set(True) bpy.context.view_layer.objects.active = b bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_all(action = 'DESELECT') obj.select_set(True) b.select_set(True) bpy.context.view_layer.objects.active = obj print(b.name) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.object.vertex_parent_set() bpy.ops.object.mode_set(mode = 'OBJECT') class testaPontos(bpy.types.Operator): """Tooltip""" bl_idname = "object.testa_pontos" bl_label = "TestaPontos" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): testaPontosDef(self, context) return {'FINISHED'} # Parenteia pontos def ParenteiaEMPDef(self, context): # Lista com todos os pontos ListaPontos = ['Orbital right', 'Orbital left', 'N point', 'Po right', 'Po left', 'Pt right', 'Pt left', 'Ba point', 'S point', 'U1 Tip', 'U1 Labial Gengival Border', 'U1 Lingual Gengival Border', 'M U6', 'D U6', 'U6 Occlusal', 'PNS point', 'A point', 'ANS point', 'U1 Root', 'L1 Tip', 'L1 Root', 'L1 Labial Gengival Border', 'L1 Lingual Gengival Border', 'B point', 'M L6', 'L6 Occlusal', 'D L6', 'Mid Ramus right', 'Mid Ramus left', 'R right', 'R left', 'Go right', 'Go left', 'Ar right', 'Ar left', 'Sigmoid right', 'Sigmoid left', 'Co right', 'Co left', 'Pg point', 'Gn point', 'Me point', 'Tooth 8', 'Tooth 9', 'Tooth 6', 'Tooth 11', 'Tooth 3', 'Tooth 14', 'Tooth 24', 'Tooth 25', 'Tooth 22', 'Tooth 27', 'Tooth 19', 'Tooth 30', 'Condyle Rotation Point'] ListaPontosMole = [ 'ST Glabella', 'ST Nasion', 'Bridge of Nose', 'Tip of Nose', 'Cheekbone right', 'Cheekbone left', 'Columella', 'Subnasale', 'Subpupil right', 'Subpupil left' ,'ST A point', 'Upper Lip', 'Stomion Superius', 'Stomion Inferius', 'Lower Lip', 'ST B point', 'ST Pogonion', 'ST Gnathion', 'ST Menton', 'Throat point', 'CB right', 'CB left', 'OR right', 'OR left', 'SP right', 'SP left', 'AB right', 'AB left', 'Radix', 'Anterior Nostril left', 'Posterior Nostril left', 'Anterior Nostril right', 'Posterior Nostril right','Rhinion', 'Alar Groove right', 'Alar Groove left', 'Supratip', 'Infratip Lobule', 'Alar Rim right', 'Alar Rim left', 'Columella right', 'Columella left', 'Alar Rim right', 'Alar Rim left', 'Medial Canthus left', 'Medial Canthus right', 'Trichion', 'Submental', 'Supraglabella', 'Glabella', 'Alar Cheek Groove right', 'Alar Cheek Groove left', 'Lateral Canthus left', 'Lateral Canthus right'] # Cria lista com pontos da cena ObjetosCena = bpy.data.objects # Compara pontos duro for ob in ListaPontos: if ob in ObjetosCena: ParenteiaPonto(ob) print(ob,"Existe na lista (Duro)!") # Compara pontos mole for ob in ListaPontosMole: if ob in ObjetosCena: ParenteiaPontoMole(ob) print(ob,"Existe na lista (Mole)!") class ParenteiaEMP(bpy.types.Operator): """Tooltip""" bl_idname = "object.parenteia_emp" bl_label = "ParenteiaEMP" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): ParenteiaEMPDef(self, context) return {'FINISHED'} bpy.utils.register_class(ParenteiaEMP) def OcultaPontosAnatomicosDef(): for i in bpy.data.collections: if fnmatch.fnmatchcase(i.name, "Anatomical Points*"): bpy.data.collections[i.name].hide_viewport=True class OcultaPontosAnatomicos(bpy.types.Operator): """Tooltip""" bl_idname = "object.oculta_pontos_anatomicos" bl_label = "Hide Anatomical Points" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): OcultaPontosAnatomicosDef() return {'FINISHED'} bpy.utils.register_class(OcultaPontosAnatomicos) def MostraPontosAnatomicosDef(): for i in bpy.data.collections: if fnmatch.fnmatchcase(i.name, "Anatomical Points*"): bpy.data.collections[i.name].hide_viewport=False class MostraPontosAnatomicos(bpy.types.Operator): """Tooltip""" bl_idname = "object.mostra_pontos_anatomicos" bl_label = "Show Anatomical Points" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): MostraPontosAnatomicosDef() return {'FINISHED'} bpy.utils.register_class(MostraPontosAnatomicos) ================================================ FILE: README.md ================================================ **OrtogOnBlender** ================== ![GitHub Logo](http://www.ciceromoraes.com.br/ups/OrtogOnBlender.jpg)

História

No ano de 2014 iniciou-se uma parceria entre o cirurgião bucomaxilofacial, Dr. Everton da Rosa e o 3D designer [Cicero Moraes](http://www.ciceromoraes.com.br) com o objetivo de criar uma metodologia de planejamento de cirurgia ortognática baseada em software livre. A ferramenta principal de trabalho seria o Blender 3D, poderoso software livre de modelagem e animação. No entanto, apesar de este contar com um workflow bem preparado para o campo artístico, o mesmo não poderia se dizer em relação às ciências da saúde. Dentre os muitos problemas encontrados podem ser citados: a falta de uma poderosa ferramenta de cálculos booleanos para o processo de osteotomia e criação de guias cirúrgicos, a falta de suporte e conversão de arquivos DICOM (tomografias computadorizadas) e a distribuição difusa dos comandos pela interface, o que dificultava em muito a utilização do software por iniciantes no mundo da computação gráfica 3D. De 2014 a 2017 dos dois especialistas desenvolveram e lapidaram não apenas uma metodologia de uso do software livre na cirurgia ortognática, mas também uma forma de compartilhar esse conhecimento através de cursos presenciais. No segundo semestre de 2017 o OrtogOnBlender começou a ser desenvolvido e em poucos meses já contava com uma versão funcional.

Sobre o Addon

O OrtogOnBlender é um addon de planejamento digital de cirurgia ortognática, baseado no software de modelagem e animação Blender 3D e é focado na facilitação do uso de ferramentas 3D por parte de profissionais da área de cirurgia bucomaxilofacial. Organizado em um painel na parte esquerda da 3D View, o addon tem em sua estrutura os seguintes passos: * **Importa Tomo**: Reconstrução dos ossos e do mole em 3D, a partir de uma tomografia computadorizada. * **Importar Tomo 3D/Moldes**: Importação da reconstrução da tomografia computadorizada ou digitalização de moles das arcadas dentárias, efetuadas em software externo. * **Zoom Cena**: Elementos de visualização da cena. * **Cria Fotogrametria**: Digitalização de faces a partir de fotografias. * **Importa Fotogrametria**: Importa digitalização de face efetuada em software externo. * **Alinha Faces**: Alinha a face e a redimensiona utilizando as informações fornecidas pelo usuário. * **Importar Cefalometria**: Importa imagem de cefalometria para alinhamento da face. * **Redimensiona e Alinha Faces**: Redimensiona a face baseada em medida conhecida e alinha a fotogrametria em relação ao mole reconstruído a partir da tomografia. * **Osteotomia**: Osteotomia dos ossos da cabeça, com ferramentas de booleana complexa e configura cada uma das peças separadas (coloração e nomeamento). * **Dinâmica do Mole**: Atrela a deformação da pele em relação a movimentação dos ossos provindos da osteotomia. * **Criação do Splint**: Configuração dos estados do planejamento digital e criação dos splints cirúrgicos, para posterior impressão 3D

Como Instalar (Geral)

* Baixe o arquivo em “Clone or download” * No Blender vá em: `File` → `User Preferences` → `Addons` → `Install from file` Procure o arquivo OrtogOnBlender-master.zip, clique sobre ele e em seguida no botão: `Install from file` * Ativar a opção `ortog:OrtogOnBlender` e configure os caminhos dos scripts expandindo a setinha do lado esquerdo. * Para manter o addon ativo clique em: `Save User Settings`.

Como Instalar (Detalhado)

* Tutorial de instalação no Windows: http://www.ciceromoraes.com.br/doc/pt_br/OrtogOnBlender/Instalacao_Windows.html * Tutorial de instalação no Mac OS X: http://www.ciceromoraes.com.br/doc/pt_br/OrtogOnBlender/Instalacao_MacOSX.html * Tutorial de instalação no Linux: http://www.ciceromoraes.com.br/doc/pt_br/OrtogOnBlender/Instalacao_Linux.html

Dependências

O OrtogOnBlender utiliza uma série de addons e bibliotecas/programas, alguns nativos e outros externos em relação ao Blender 3D, são eles:

Addons

* Measureit (nativo) * 3D Navigation (nativo) * Import Images as Planes (nativo) * Cork on Blender - https://github.com/dfelinto/cork-on-blender * Cut Mesh - https://github.com/patmo141/cut_mesh * Object Alignment - https://github.com/patmo141/object_alignment

Programas

* Meshlab (instalador) - http://www.meshlab.net/ * OpenMVG (código-fonte) - https://github.com/openMVG/openMVG * OpenMVS (código-fonte) - http://cdcseacave.github.io/openMVS/ * MVE/SMVS (código-fonte) - https://github.com/flanggut/smvs * Dicom2Mesh (código-fonte) - https://github.com/AOT-AG/DicomToMesh

Agradecimentos

[Dalai Felinto](https://github.com/dfelinto/), [Pierre Moulon](https://github.com/pmoulon), [Patrick Moore](https://github.com/patmo141/), [Adrian Schneider](https://github.com/eidelen), Rodrigo Dornelles, Liogi Iwaki Filho, Antônio Eduardo Izidro, Paulo Henrique Luiz de Freitas, Vinicius de Paula Ribeiro, Richard Gravalos, José Patrício Neto, Hugo Santos Cunha, Frederico Yonezaki, Eduardo Correa Costa, Renata Porto Stypulkowski, Samuel Cardoso Santiago Júnior, José Arnaldo dos Santos Júnior, Lucio Gamboa Villegas, Walace Guimarães Matos e Adriano Rocha Campos. ================================================ FILE: RelatorioAnimacao.py ================================================ import bpy def AnimaLocRotDef(self, context): context = bpy.context scn = context.scene bpy.ops.anim.keyframe_insert_menu(type='BUILTIN_KSI_LocRot') class AnimaLocRot(bpy.types.Operator): """Tooltip""" bl_idname = "anim.ortog_loc_rot" bl_label = "Kinematic Ortog" def execute(self, context): AnimaLocRotDef(self, context) return {'FINISHED'} bpy.utils.register_class(AnimaLocRot) ================================================ FILE: RhinOnBlender.py ================================================ import bpy import platform from .__init__ import * from .RhinTools import * from .Version import * from .RhinOpenGL import * class RHIN_PT_AtualizaAddonSec(bpy.types.Panel): bl_label = "Upgrade Script" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="VERSION: "+VERSION) row = layout.row() row.operator("object.atualiza_script", text="UPGRADE RHIN!", icon="RECOVER_LAST") bpy.utils.register_class(RHIN_PT_AtualizaAddonSec) class RHIN_PT_NomePaciente(bpy.types.Panel): bl_label = "Patient's Name" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() col = self.layout.column(align = True) col.prop(context.scene, "nome_paciente") col = self.layout.column(align = True) col.prop(context.scene, "sobrenome_paciente") box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(RHIN_PT_NomePaciente) class RHIN_PT_Fotogrametria(bpy.types.Panel): bl_label = "Photogrammetry Start" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.prop(scn, "my_enum") my_enum = scn.my_enum if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.OPENMVG: # row = layout.row() # row.label(text="OpenMVG+OpenMVS:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") col = self.layout.column(align = True) col.alignment = 'RIGHT' col.prop(context.scene, "d_factor") col.prop(context.scene, "smooth_factor") col.prop(scn.my_tool, "imagem_bool", text="Decrease picture size!") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.rhin_fotogrametria_dec", text="Start Photogrammetry!", icon="IMAGE_DATA") if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.SMVS: # row = layout.row() # row.label(text="SMVS+Meshlab:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") row = layout.row() row.operator("object.gera_modelo_foto_smvs", text="Alternative Photogrammetry I", icon="IMAGE_DATA") if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.MESHROOM: # row = layout.row() # row.label(text="Meshroom (AliceVision):") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") row = layout.row() row.operator("object.gera_modelo_foto_meshroom", text="Alternative Photogrammetry II", icon="IMAGE_DATA") if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.OPENMVGWIN: # row = layout.row() # row.label(text="OpenMVG+OpenMVS:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") col = self.layout.column(align = True) col.alignment = 'RIGHT' col.prop(context.scene, "d_factor") col.prop(context.scene, "smooth_factor") col.prop(scn.my_tool, "imagem_bool", text="Decrease picture size!") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.gera_modelo_foto_win", text="Start Photogrammetry!", icon="IMAGE_DATA") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_fotogram", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(RHIN_PT_Fotogrametria) class RHIN_PT_AlinhaFace(bpy.types.Panel): bl_label = "Photogrammetry - Align & Scale" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Align Points:") row = layout.row() linha=row.operator("object.emp1b", text="Cantal Lateral Right", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp2b", text="Cantal Lateral Left", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp3b", text="Down Point", icon="SORTBYEXT") # row = layout.row() # row.operator("object.cria_tres_pontos", text="3 Points Click", icon="OUTLINER_OB_MESH") row = self.layout.row(align = True) row.label(text="Real Size:") row.prop(context.scene, "medida_real2") row = layout.row() row.operator("object.alinha_forca", text="Align and Resize!", icon="ORIENTATION_LOCAL") row = layout.row() row = layout.row() row.label(text="Segmentation Cut Through:") row = layout.row() row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row = layout.row() linha=row.operator("object.segmenta_desenho", text="Cut Draw!", icon="FCURVE") row = layout.row() row = layout.row() row.label(text="Surface Cut:") row = layout.row() row.operator("wm.modal_cria_pontos", icon='CURVE_DATA', text="Create Points") row = layout.row() row.operator("mesh.add_curva_bezier_unido", icon='CURVE_BEZCIRCLE', text="Create Bezier Line") row = layout.row() circle=row.operator("object.bezier_corta", text="Cut Line!", icon="SCULPTMODE_HLT") row = layout.row() circle=row.operator("object.bezier_corta_dupla", text="Cut Line Double!", icon="MOD_THICKNESS") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_alinha_face", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(RHIN_PT_AlinhaFace) ''' class RHIN_PT_FotogramModif(bpy.types.Panel): bl_label = "Photogrammetry - Modifiers" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context scn = context.scene row = layout.row() row.label(text="Modifiers:") ob = context.object layout.operator_menu_enum("object.modifier_add", "type") for md in ob.modifiers: box = layout.template_modifier(md) if box: # match enum type to our functions, avoids a lookup table. getattr(self, md.type)(box, ob, md) row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.convert", text="APPLY ALL!", icon="ERROR").target='MESH' bpy.utils.register_class(RHIN_PT_FotogramModif) ''' class RHIN_PT_PontosAnatomicos(bpy.types.Panel): bl_label = "Anatomical Points" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context scn = context.scene row = layout.row() linha=row.operator("object.copia_face", text="COPY FACE!") row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.label(text="Anatomical Points") row = layout.row() row.label(text="Nose Calculation Points:") row = layout.row() linha=row.operator("object.radix_pt", text="Radix") row = layout.row() linha=row.operator("object.tip_nose_pt", text="Tip of Nose") row = layout.row() linha=row.operator("object.alar_cheek_groove_right_pt", text="Alar Cheek Groove right") row = layout.row() linha=row.operator("object.alar_cheek_groove_left_pt", text="Alar Cheek Groove left") row = layout.row() linha=row.operator("object.subnasale_pt", text="Subnasale") row = layout.row() linha=row.operator("object.anterior_nostril_left_pt", text="Anterior Nostril left") row = layout.row() linha=row.operator("object.posterior_nostril_left_pt", text="Posterior Nostril left") row = layout.row() linha=row.operator("object.anterior_nostril_right_pt", text="Anterior Nostril right") row = layout.row() linha=row.operator("object.posterior_nostril_right_pt", text="Posterior Nostril right") row = layout.row() row.label(text="Facial Analysis Points:") row = layout.row() linha=row.operator("object.medial_canthus_right_pt", text="Medial Canthus right") row = layout.row() linha=row.operator("object.medial_canthus_left_pt", text="Medial Canthus left") row = layout.row() linha=row.operator("object.trichion_pt", text="Trichion") row = layout.row() linha=row.operator("object.st_glabella_pt", text="ST Glabella") row = layout.row() linha=row.operator("object.subnasale_pt", text="Subnasale") row = layout.row() linha=row.operator("object.st_menton_pt", text="ST Menton") row = layout.row() row.label(text="Control Points:") row = layout.row() linha=row.operator("object.rhinion_pt", text="Rhinion") row = layout.row() linha=row.operator("object.supratip_pt", text="Supratip") row = layout.row() linha=row.operator("object.alar_groove_right_pt", text="Alar Groove right") row = layout.row() linha=row.operator("object.alar_groove_left_pt", text="Alar Groove left") row = layout.row() linha=row.operator("object.infratip_lobule_pt", text="Infratip Lobule") row = layout.row() linha=row.operator("object.alar_rim_right_pt", text="Alar Rim right") row = layout.row() linha=row.operator("object.alar_rim_left_pt", text="Alar Rim left") row = layout.row() linha=row.operator("object.columella_right_pt", text="Columella right") row = layout.row() linha=row.operator("object.columella_left_pt", text="Columella left") row = layout.row() row = layout.row() row.label(text="Parent Points:") row = layout.row() circle=row.operator("object.parenteia_emp", text="Parent Points", icon="LINKED") row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() row = layout.row() linha=row.operator("object.pontos_oculta_nomes", text="Hide Names", icon="GHOST_DISABLED") row = layout.row() linha=row.operator("object.pontos_mostra_nomes", text="Show Names", icon="GHOST_ENABLED") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_points_soft", text="SAVE!", icon="FILE_TICK") bpy.utils.register_class(RHIN_PT_PontosAnatomicos) class RHIN_PT_DistAngles(bpy.types.Panel): bl_label = "Dists & Angles" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context scn = context.scene row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.label(text="Facial Analysis Points:") row = layout.row() linha=row.operator("object.lateral_canthus_right_pt", text="Lateral Canthus right") row = layout.row() linha=row.operator("object.lateral_canthus_left_pt", text="Lateral Canthus left") row = layout.row() linha=row.operator("object.medial_canthus_right_pt", text="Medial Canthus right") row = layout.row() linha=row.operator("object.medial_canthus_left_pt", text="Medial Canthus left") row = layout.row() linha=row.operator("object.trichion_pt", text="Trichion") row = layout.row() linha=row.operator("object.st_glabella_pt", text="ST Glabella") row = layout.row() linha=row.operator("object.subnasale_pt", text="Subnasale") row = layout.row() linha=row.operator("object.st_menton_pt", text="ST Menton") row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.rhin_visualiza_gl", text="View Lines!", icon="HIDE_OFF") row = layout.row() linha=row.operator("object.rhin_remove_gl", text="Hide Lines!", icon="HIDE_ON") row = layout.row() row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() row = layout.row() linha=row.operator("object.pontos_oculta_nomes", text="Hide Names", icon="GHOST_DISABLED") row = layout.row() linha=row.operator("object.pontos_mostra_nomes", text="Show Names", icon="GHOST_ENABLED") row = layout.row() circle=row.operator("object.parenteia_emp", text="Parent Points", icon="LINKED") row = layout.row() row = layout.row() linha=row.operator("object.dist_nariz", text="CALC ALL!", icon="PREFERENCES") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.label(text="Results:") # Proporção do nariz row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.radix_pt", text="Radix") linha=row.operator("object.tip_nose_pt", text="Tip of Nose") # linha=row.operator("object.subnasale_pt", text="Subnasale") row = col.row() linha=row.operator("object.alar_cheek_groove_right_pt", text="Alar Cheek Groove right") row = col.row() linha=row.operator("object.alar_cheek_groove_left_pt", text="Alar Cheek Groove left") row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "rhin_prop_nariz") row = col.row() row.alignment = 'RIGHT' row.label(text="Average: 0.67") # Calculado # Ângulo nasolabial esquerdo row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.anterior_nostril_left_pt", text="Ant. Nostril left") linha=row.operator("object.posterior_nostril_left_pt", text="Post. Nostril left") row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "rhin_angulo_nasolabial_esquerdo") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: 95 - 100º Men: 90º - 95º") # Calculado # Ângulo nasolabial direito row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.anterior_nostril_right_pt", text="Ant. Nostril right") linha=row.operator("object.posterior_nostril_right_pt", text="Post. Nostril right") row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "rhin_angulo_nasolabial_direito") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: 95 - 100º Men: 90º - 95º") # Calculado # Alar Rim - Columella left row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.anterior_nostril_left_pt", text="Ant. Nostril left") linha=row.operator("object.posterior_nostril_left_pt", text="Post. Nostril left") row = col.row() linha=row.operator("object.alar_rim_left_pt", text="Alar Rim left") linha=row.operator("object.columella_left_pt", text="Columella left") row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.label(text="Alar Rim - Columella Factor LEFT") row = col.row() row.alignment = 'RIGHT' row.prop(context.scene, "rhin_alar_rim_med_esquerdo") row = col.row() row.alignment = 'RIGHT' row.prop(context.scene, "rhin_columella_med_esquerdo") # Alar Rim - Columella left row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.anterior_nostril_right_pt", text="Ant. Nostril right") linha=row.operator("object.posterior_nostril_right_pt", text="Post. Nostril right") row = col.row() linha=row.operator("object.alar_rim_right_pt", text="Alar Rim right") linha=row.operator("object.columella_right_pt", text="Columella right") row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.label(text="Alar Rim - Columella Factor RIGHT") row = col.row() row.alignment = 'RIGHT' row.prop(context.scene, "rhin_alar_rim_med_direito") row = col.row() row.alignment = 'RIGHT' row.prop(context.scene, "rhin_columella_med_direito") bpy.utils.register_class(RHIN_PT_DistAngles) bpy.types.Scene.rhin_prop_nariz = bpy.props.StringProperty \ ( name = "Nose Proportion", description = "Nose Proportion", default = "NONE" ) bpy.types.Scene.rhin_angulo_nasolabial_esquerdo = bpy.props.StringProperty \ ( name = "Nasolabial Angle left", description = "Nasolabial Angle left", default = "NONE" ) bpy.types.Scene.rhin_angulo_nasolabial_direito = bpy.props.StringProperty \ ( name = "Nasolabial Angle right", description = "Nasolabial Angle right", default = "NONE" ) # Alar Rim - Columella left bpy.types.Scene.rhin_alar_rim_med_esquerdo = bpy.props.StringProperty \ ( name = "Alar Rim - Nostril", description = "Alar Rim - Nostril", default = "NONE" ) bpy.types.Scene.rhin_columella_med_esquerdo = bpy.props.StringProperty \ ( name = "Columella - Nostril", description = "Columella - Nostril", default = "NONE" ) # Alar Rim - Columella right bpy.types.Scene.rhin_alar_rim_med_direito = bpy.props.StringProperty \ ( name = "Alar Rim - Nostril", description = "Alar Rim - Nostril", default = "NONE" ) bpy.types.Scene.rhin_columella_med_direito = bpy.props.StringProperty \ ( name = "Columella - Nostril", description = "Columella - Nostril", default = "NONE" ) class RHIN_PT_Escultura(bpy.types.Panel): bl_label = "Sculpting" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout row = layout.row() row.operator("object.cria_shape_keys", text="Create Shape Keys", icon="MOD_SIMPLEDEFORM") row = layout.row() ob = context.object key = ob.data.shape_keys kb = ob.active_shape_key enable_edit = ob.mode != 'EDIT' enable_edit_value = False if ob.show_only_shape_key is False: if enable_edit or (ob.type == 'MESH' and ob.use_shape_key_edit_mode): enable_edit_value = True if key.use_relative: if ob.active_shape_key_index != 0: layout.use_property_split = True row = layout.row() row.active = enable_edit_value row.prop(kb, "value") row = layout.row() linha=row.operator("object.escultura_grab", text="Grab", icon="BRUSH_GRAB") row = layout.row() linha=row.operator("object.escultura_smooth", text="Smooth", icon="BRUSH_SMOOTH") row = layout.row() linha=row.operator("object.escultura_mask", text="Mask", icon="BRUSH_MASK") row = layout.row() linha=row.operator("object.mode_set", text="OK! (Object Mode)", icon="META_CUBE").mode='OBJECT' row = layout.row() row.label(text="View/Transp.:") row = layout.row() linha=row.operator("object.material_transparente_dois", text="Transp. Material", icon="SHADING_RENDERED") row = layout.row() #col = self.layout.column(align = True) row.alignment = 'CENTER' row.prop(context.scene, "mat_transp_pre") #row = layout.row() row.operator("object.material_transp_pre", text="Original") row = layout.row() #col = self.layout.column(align = True) row.alignment = 'CENTER' row.prop(context.scene, "mat_transp_pos") #row = layout.row() row.operator("object.material_transp_pos", text="Planning") row = layout.row() row = layout.row() linha=row.operator("object.material_opaco_dois", text="Opaque Material", icon="SHADING_SOLID") row = layout.row() row = layout.row() row.operator("view3d.clip_border", text="Clipping Border", icon="UV_FACESEL") bpy.utils.register_class(RHIN_PT_Escultura) class RHIN_PT_GuideCreation(bpy.types.Panel): bl_label = "Guide Creation" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Rhin" def draw(self, context): layout = self.layout context = bpy.context scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() row = layout.row() linha=row.operator("object.pontos_oculta_nomes", text="Hide Names", icon="GHOST_DISABLED") row = layout.row() linha=row.operator("object.pontos_mostra_nomes", text="Show Names", icon="GHOST_ENABLED") row = layout.row() row.label(text="Anatomical Points") row = layout.row() linha=row.operator("object.supraglabella_pt", text="Supraglabella") row = layout.row() linha=row.operator("object.st_glabella_pt", text="ST Glabella") row = layout.row() linha=row.operator("object.radix_pt", text="Radix") row = layout.row() linha=row.operator("object.rhinion_pt", text="Rhinion") row = layout.row() linha=row.operator("object.supratip_pt", text="Supratip") row = layout.row() linha=row.operator("object.tip_nose_pt", text="Tip of Nose") row = layout.row() linha=row.operator("object.columella_pt", text="Columella") row = layout.row() linha=row.operator("object.subnasale_pt", text="Subnasale") row = layout.row() linha=row.operator("object.upper_lip_pt", text="Upper Lip") row = layout.row() row = layout.row() linha=row.operator("object.gera_guia_nariz", text="Create Nose Guide!", icon="PREFERENCES") row = layout.row() row = layout.row() row.operator("export_mesh.stl", text="Export STL", icon="TRACKING_REFINE_FORWARDS").use_selection=True#.use_mesh_modifiers=True row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_guide", text="SAVE!", icon="FILE_TICK") bpy.types.Scene.mat_transp_pre = bpy.props.StringProperty \ ( name = "Original", description = "Original Face", default = "0.30" ) bpy.types.Scene.mat_transp_pos = bpy.props.StringProperty \ ( name = "Planning", description = "Planning Face", default = "0.30" ) bpy.utils.register_class(RHIN_PT_GuideCreation) ================================================ FILE: RhinOpenGL.py ================================================ import bpy import gpu import bgl from gpu_extras.batch import batch_for_shader def LinhasCentraisCria(): CantusRightX = bpy.data.objects['Medial Canthus right'].location[0] CantusRightY = bpy.data.objects['Medial Canthus right'].location[1] CantusLeftX = bpy.data.objects['Medial Canthus left'].location[0] CantusLeftY = bpy.data.objects['Medial Canthus left'].location[1] TrichionY = bpy.data.objects['Trichion'].location[1] TrichionZ = bpy.data.objects['Trichion'].location[2] STGlabellaY = bpy.data.objects['ST Glabella'].location[1] STGlabellaZ = bpy.data.objects['ST Glabella'].location[2] SubnasaleY = bpy.data.objects['Subnasale'].location[1] SubnasaleZ = bpy.data.objects['Subnasale'].location[2] STMentonY = bpy.data.objects['ST Menton'].location[1] STMentonZ = bpy.data.objects['ST Menton'].location[2] DistanciaCantus = abs(CantusLeftX - CantusRightX) print("DISTANCIA CANTUS!!!", DistanciaCantus) try: LatCantusRightX = bpy.data.objects['Lateral Canthus right'].location[0] LatCantusRightY = bpy.data.objects['Lateral Canthus right'].location[1] LatCantusLeftX = bpy.data.objects['Lateral Canthus left'].location[0] LatCantusLeftY = bpy.data.objects['Lateral Canthus left'].location[1] coords = [(LatCantusRightX,LatCantusRightY,-1000), (LatCantusRightX,LatCantusRightY,1000),(CantusRightX,CantusRightY,-1000), (CantusRightX,CantusRightY,1000), (LatCantusLeftX,LatCantusLeftY,-1000), (LatCantusLeftX,LatCantusLeftY, 1000),(CantusLeftX,CantusLeftY,-1000), (CantusLeftX,CantusLeftY, 1000), (1000, TrichionY, TrichionZ), (-1000, TrichionY, TrichionZ), (1000, STGlabellaY, STGlabellaZ), (-1000, STGlabellaY, STGlabellaZ), (1000, SubnasaleY, SubnasaleZ), (-1000, SubnasaleY, SubnasaleZ), (1000, STMentonY, STMentonZ), (-1000, STMentonY, STMentonZ) ] #, (CantusRightX-DistanciaCantus,CantusRightY,-1000), (CantusRightX-DistanciaCantus,CantusRightY, 1000), (CantusLeftX+DistanciaCantus,CantusLeftY,-1000), (CantusLeftX+DistanciaCantus,CantusLeftY, 1000)] shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'LINES', {"pos": coords}) except: coords = [(CantusRightX,CantusRightY,-1000), (CantusRightX,CantusRightY,1000),(CantusLeftX,CantusLeftY,-1000), (CantusLeftX,CantusLeftY, 1000), (1000, TrichionY, TrichionZ), (-1000, TrichionY, TrichionZ), (1000, STGlabellaY, STGlabellaZ), (-1000, STGlabellaY, STGlabellaZ), (1000, SubnasaleY, SubnasaleZ), (-1000, SubnasaleY, SubnasaleZ), (1000, STMentonY, STMentonZ), (-1000, STMentonY, STMentonZ) ] #, (CantusRightX-DistanciaCantus,CantusRightY,-1000), (CantusRightX-DistanciaCantus,CantusRightY, 1000), (CantusLeftX+DistanciaCantus,CantusLeftY,-1000), (CantusLeftX+DistanciaCantus,CantusLeftY, 1000)] shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'LINES', {"pos": coords}) def draw(): shader.bind() bgl.glLineWidth(3) # 1 Grossura # bgl.glDisable(bgl.GL_BLEND) # bgl.glEnable(bgl.GL_DEPTH_TEST) bgl.glDisable(bgl.GL_DEPTH_TEST) # bgl.glColor4f(0.0, 0.0, 0.0, 1.0) shader.uniform_float("color", (1, 1, 1, 1)) batch.draw(shader) global my_draw_handler my_draw_handler = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW') bpy.ops.view3d.view_all(center=False) class RhinVisualizaGL(bpy.types.Operator): """Tooltip""" bl_idname = "object.rhin_visualiza_gl" bl_label = "Visualiza OpenGL" def execute(self, context): LinhasCentraisCria() return {'FINISHED'} bpy.utils.register_class(RhinVisualizaGL) def LinhasCentraisApaga(): bpy.types.SpaceView3D.draw_handler_remove(my_draw_handler, 'WINDOW') bpy.ops.view3d.view_all(center=False) class RhinRemoveGL(bpy.types.Operator): """Tooltip""" bl_idname = "object.rhin_remove_gl" bl_label = "Remove OpenGL" def execute(self, context): LinhasCentraisApaga() return {'FINISHED'} bpy.utils.register_class(RhinRemoveGL) ================================================ FILE: RhinTools.py ================================================ import bpy from .PontosAnatomicos import * from .Cefalometria import * from .FerrMedidas import * from .FerrImgTomo import * # Importa tratamento de materiais from math import sqrt import bmesh from mathutils import Matrix, Vector from time import gmtime, strftime # PONTOS ANATOMICOS class Alar_Cheek_Groove_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_cheek_groove_right_pt" bl_label = "Alar Cheek Groove right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Cheek Groove right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Cheek Groove right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Cheek_Groove_right_pt) class Alar_Cheek_Groove_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_cheek_groove_left_pt" bl_label = "Alar Cheek Groove left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Cheek Groove left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Cheek Groove left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Cheek_Groove_left_pt) class Medial_Canthus_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.medial_canthus_right_pt" bl_label = "Medial Canthus right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Medial Canthus right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Medial Canthus right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Medial_Canthus_right_pt) class Medial_Canthus_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.medial_canthus_left_pt" bl_label = "Medial Canthus left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Medial Canthus left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Medial Canthus left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Medial_Canthus_left_pt) class Radix_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.radix_pt" bl_label = "Radix" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Radix' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Radix', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Radix_pt) class Anterior_Nostril_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.anterior_nostril_left_pt" bl_label = "Anterior Nostril left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Anterior Nostril left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Anterior Nostril left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Anterior_Nostril_left_pt) class Anterior_Nostril_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.anterior_nostril_right_pt" bl_label = "Anterior Nostril right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Anterior Nostril right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Anterior Nostril right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Anterior_Nostril_right_pt) class Posterior_Nostril_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.posterior_nostril_left_pt" bl_label = "Posterior Nostril left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Posterior Nostril left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Posterior Nostril left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Posterior_Nostril_left_pt) class Posterior_Nostril_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.posterior_nostril_right_pt" bl_label = "Posterior Nostril right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Posterior Nostril right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Posterior Nostril right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Posterior_Nostril_right_pt) class Rhinion_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.rhinion_pt" bl_label = "Rhinion" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Rhinion' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Rhinion', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Rhinion_pt) class Alar_Groove_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_groove_right_pt" bl_label = "Alar Groove right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Groove right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Groove right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Groove_right_pt) class Alar_Groove_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_groove_left_pt" bl_label = "Alar Groove left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Groove left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Groove left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Groove_left_pt) class Supratip_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.supratip_pt" bl_label = "Supratip" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Supratip' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Supratip', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Supratip_pt) class Infratip_Lobule_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.infratip_lobule_pt" bl_label = "Infratip Lobule" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Infratip Lobule' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Infratip Lobule', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Infratip_Lobule_pt) class Alar_Rim_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_rim_right_pt" bl_label = "Alar Rim right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Rim right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Rim right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Rim_right_pt) class Alar_Rim_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.alar_rim_left_pt" bl_label = "Alar Rim left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Alar Rim left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Alar Rim left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Alar_Rim_left_pt) class Columella_right_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.columella_right_pt" bl_label = "Columella right" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Columella right' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Columella right', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Columella_right_pt) class Columella_left_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.columella_left_pt" bl_label = "Columella left" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Columella left' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Columella left', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Columella_left_pt) class Trichion_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.trichion_pt" bl_label = "Trichion" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Trichion' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Trichion', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Trichion_pt) class Submental_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.submental_pt" bl_label = "Submental" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Submental' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Submental', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Submental_pt) class Supraglabella_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.supraglabella_pt" bl_label = "Supraglabella" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Supraglabella' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Supraglabella', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Supraglabella_pt) class Glabella_pt(bpy.types.Operator): """Tooltip""" bl_idname = "object.glabella_pt" bl_label = "Glabella" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'Glabella' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CriaPontoDef('Glabella', 'Anatomical Points - Soft Tissue') TestaPontoCollDef() return {'FINISHED'} bpy.utils.register_class(Glabella_pt) # COPIA FACE def CopiaFaceDef(): bpy.context.object.name = "SoftTissueDynamic" bpy.ops.object.duplicate() bpy.context.object.name = "SoftTissueDynamic_COPY" FaceCopiada = bpy.data.objects['SoftTissueDynamic_COPY'] FaceCopiada.hide_viewport=True FaceOriginal = bpy.data.objects['SoftTissueDynamic'] FaceOriginal.select_set(True) bpy.context.view_layer.objects.active = FaceOriginal class CopiaFace(bpy.types.Operator): """Tooltip""" bl_idname = "object.copia_face" bl_label = "Copy Face" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): found = 'SoftTissueDynamic_COPY' in bpy.data.objects if found == False: return True else: if found == True: return False def execute(self, context): CopiaFaceDef() return {'FINISHED'} bpy.utils.register_class(CopiaFace) def CalculaDistsNarizDef(): try: bpy.ops.object.mode_set(mode = 'OBJECT') except: print("Já em modo objeto.") try: ListaPontos = ['Tip of Nose', 'Subnasale','Radix', 'Anterior Nostril left', 'Posterior Nostril left', 'Anterior Nostril right', 'Posterior Nostril right','Rhinion', 'Alar Groove right', 'Alar Groove left', 'Supratip', 'Infratip Lobule', 'Alar Rim right', 'Alar Rim left', 'Columella right', 'Columella left', 'Alar Cheek Groove right', 'Alar Cheek Groove left'] for i in ListaPontos: # print("HÁ O NOME!", i.name) try: bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects[i] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.duplicate() NovoNome = str(bpy.data.objects[i].name)+"_COPY_MEDIDAS" bpy.context.object.name = NovoNome bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM') bpy.ops.object.select_all(action='DESELECT') except: print("Erro ao tentar copiar o objeto:", i) except: print("Erro ao tentar copiar os objetos.") try: DistRadixTip = DistanciaObjetos("Radix_COPY_MEDIDAS", "Tip of Nose_COPY_MEDIDAS") CursorToSelectedObjs("Alar Cheek Groove right", "Alar Cheek Groove left") print("HHHHHHHHAAHAHAHHAHAHA") bpy.ops.mesh.primitive_uv_sphere_add(radius=1, view_align=False, enter_editmode=False) bpy.context.object.name = "Alar Cheek Groove MEIO" DistTipAlar = DistanciaObjetos("Tip of Nose_COPY_MEDIDAS", "Alar Cheek Groove MEIO") ProporcaoNariz = DistTipAlar / DistRadixTip print("ProporcaoNariz", ProporcaoNariz) bpy.types.Scene.rhin_prop_nariz = bpy.props.StringProperty \ ( name = "Nose Proportion", description = "Nose Proportion", default = str(round(ProporcaoNariz, 2)) ) # Apaga objeto criados bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects["Alar Cheek Groove MEIO"] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.delete(use_global=False) except: print("Problemas ao calcular a proporção do nariz.") try: # CRIA PONTOS PARA CALCULAR ANGULO ESQUERDO bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects["Posterior Nostril left_COPY_MEDIDAS"] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.duplicate() NovoNome = "Posterior Nostril left_ABAIXO" bpy.context.object.name = NovoNome bpy.ops.transform.translate(value=(0, 0, -80)) bpy.ops.object.select_all(action='DESELECT') # CALCULA ANGULO AnguloNasolabial = CalculaAngulo("Anterior Nostril left_COPY_MEDIDAS", "Posterior Nostril left_COPY_MEDIDAS", "Posterior Nostril left_ABAIXO") # AnguloNasolabial = CalculaAngulo("Radix_COPY_MEDIDAS", "Tip of Nose_COPY_MEDIDAS", "Subnasale_COPY_MEDIDAS") bpy.types.Scene.rhin_angulo_nasolabial_esquerdo = bpy.props.StringProperty \ ( name = "Nasolabial Angle left", description = "Nasolabial Angle left", default = str(AnguloNasolabial) #+"º" ) # Apaga objeto criados bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects["Posterior Nostril left_ABAIXO"] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.delete(use_global=False) except: print("Não foi possível fazer o cálculo do ângulo nasolabial ESQUERDO.") try: # CRIA PONTOS PARA CALCULAR ANGULO DIREITO bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects["Posterior Nostril right_COPY_MEDIDAS"] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.duplicate() NovoNome = "Posterior Nostril right_ABAIXO" bpy.context.object.name = NovoNome bpy.ops.transform.translate(value=(0, 0, -80)) bpy.ops.object.select_all(action='DESELECT') # CALCULA ANGULO AnguloNasolabial = CalculaAngulo("Anterior Nostril right_COPY_MEDIDAS", "Posterior Nostril right_COPY_MEDIDAS", "Posterior Nostril right_ABAIXO") # AnguloNasolabial = CalculaAngulo("Radix_COPY_MEDIDAS", "Tip of Nose_COPY_MEDIDAS", "Subnasale_COPY_MEDIDAS") bpy.types.Scene.rhin_angulo_nasolabial_direito = bpy.props.StringProperty \ ( name = "Nasolabial Angle right", description = "Nasolabial Angle right", default = str(AnguloNasolabial) #+"º" ) # Apaga objeto criados bpy.ops.object.select_all(action='DESELECT') ObjetoAtual = bpy.data.objects["Posterior Nostril right_ABAIXO"] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.delete(use_global=False) except: print("Não foi possível fazer o cálculo do ângulo nasolabial DIREITO.") try: # CALCULA ALAR RIM - COLUMELLA FACTOR - ESQUERDA AnteriorNostrilLeft = bpy.data.objects["Anterior Nostril left_COPY_MEDIDAS"].location[2] PosteriorNostrilLeft = bpy.data.objects["Posterior Nostril left_COPY_MEDIDAS"].location[2] NostrileftMedia = (AnteriorNostrilLeft + PosteriorNostrilLeft) / 2 AlarRimLeft = bpy.data.objects["Alar Rim left_COPY_MEDIDAS"].location[2] FatorAlarRimLeft = abs(AlarRimLeft - NostrileftMedia) bpy.types.Scene.rhin_alar_rim_med_esquerdo = bpy.props.StringProperty \ ( name = "Alar Rim - Nostril", description = "Alar Rim - Nostril", default = str(round(FatorAlarRimLeft, 2)) ) ColumellaLeft = bpy.data.objects["Columella left_COPY_MEDIDAS"].location[2] FatorColumellaLeft = abs(ColumellaLeft - NostrileftMedia) print("FatoColumellaLeft:", FatorColumellaLeft) bpy.types.Scene.rhin_columella_med_esquerdo = bpy.props.StringProperty \ ( name = "Columella - Nostril", description = "Columella - Nostril", default = str(round(FatorColumellaLeft, 2)) ) except: print("Não foi possível fazer o cálculo do fator Alar Rim-Columella - ESQUERDO.") try: # CALCULA ALAR RIM - COLUMELLA FACTOR - DIREITA AnteriorNostrilRight = bpy.data.objects["Anterior Nostril right_COPY_MEDIDAS"].location[2] PosteriorNostrilRight = bpy.data.objects["Posterior Nostril right_COPY_MEDIDAS"].location[2] NonstrilRightMedia = (AnteriorNostrilRight + PosteriorNostrilRight) / 2 AlarRimRight = bpy.data.objects["Alar Rim right_COPY_MEDIDAS"].location[2] print("AQUI!!!") #print(FatorAlarRimRight) FatorAlarRimRight = abs(AlarRimRight - NonstrilRightMedia) bpy.types.Scene.rhin_alar_rim_med_direito = bpy.props.StringProperty \ ( name = "Alar Rim - Nostril", description = "Alar Rim - Nostril", default = str(round(FatorAlarRimRight, 2)) ) ColumellaRight = bpy.data.objects["Columella right_COPY_MEDIDAS"].location[2] FatorColumellaRight = abs(ColumellaRight - NonstrilRightMedia) print("FatoColumellaRight:", FatorColumellaRight) bpy.types.Scene.rhin_columella_med_direito = bpy.props.StringProperty \ ( name = "Columella - Nostril", description = "Columella - Nostril", default = str(round(FatorColumellaRight, 2)) ) except: print("Não foi possível fazer o cálculo do fator Alar Rim-Columella - DIREITO.") # APAGA Pontos criados try: for i in ListaPontos: # print("HÁ O NOME!", i.name) try: bpy.ops.object.select_all(action='DESELECT') NomeAtual = str(bpy.data.objects[i].name)+"_COPY_MEDIDAS" ObjetoAtual = bpy.data.objects[NomeAtual] ObjetoAtual.select_set(True) bpy.context.view_layer.objects.active = ObjetoAtual bpy.ops.object.delete(use_global=False) bpy.ops.object.select_all(action='DESELECT') except: print("Houve problema ao deletar o ponto:", i) except: print("Houve algum problema ao deletar os pontos.") class CalculaDistsNariz(bpy.types.Operator): """Tooltip""" bl_idname = "object.dist_nariz" bl_label = "Nose dists" def execute(self, context): try: OriginalBool = bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport if bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport == True: print("XXXXXXXXXX") bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = False except: print("A coleção Anatomical Points - Soft Tissue não existe!") CalculaDistsNarizDef() try: if OriginalBool == False: bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = False else: bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = True except: print("A coleção Anatomical Points - Soft Tissue não existe!") return {'FINISHED'} bpy.utils.register_class(CalculaDistsNariz) class MostraOcultaPontos(bpy.types.Operator): """Tooltip""" bl_idname = "object.rhin_mostra_oculta_pontos" bl_label = "Nose dists" def execute(self, context): try: if bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport == False: print("HIDE FALSE") bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = True else: #bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport == True: print("HIDE TRUE") bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = False # bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = False except: print("A coleção Anatomical Points - Soft Tissue não existe!") return {'FINISHED'} bpy.utils.register_class(MostraOcultaPontos) def GeraGuiaNarizDef(): Rosto = bpy.data.objects["SoftTissueDynamic"] Pontos = ['Supraglabella', 'ST Glabella', 'Radix', 'Rhinion', 'Supratip', 'Tip of Nose', 'Columella', 'Subnasale', 'Upper Lip'] coords = [] for i in Pontos: VetorAtual = bpy.data.objects[i].location VetX = bpy.data.objects[i].location[0] VetY = bpy.data.objects[i].location[1] VetZ = bpy.data.objects[i].location[2] coords.append((VetX, VetY, VetZ)) curveData = bpy.data.curves.new('myCurve', type='CURVE') curveData.dimensions = '3D' # curveData.resolution_u = 6 curveData.resolution_u = 36 # map coords to spline polyline = curveData.splines.new('BEZIER') polyline.bezier_points.add(len(coords)-1) # for i, coord in enumerate(coords): # x,y,z = coord # polyline.points[i].co = (x, y, z, 1) from bpy_extras.io_utils import unpack_list polyline.bezier_points.foreach_set("co", unpack_list(coords)) # Apaga pontos bpy.ops.object.select_all(action='DESELECT') #for i in Pontos: # bpy.data.objects[i].select_set(True) #bpy.ops.object.delete(use_global=False) bpy.data.collections['Anatomical Points - Soft Tissue'].hide_viewport = True # Cria Linha curveOB = bpy.data.objects.new('myCurve', curveData) # attach to scene and validate context scn = bpy.context.scene # scn.objects.link(curveOB) bpy.context.collection.objects.link(curveOB) #scn.collection.objects.link(curveOB) # Esta opção faz com que o objeto criado vá para a Scene Collection! bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = curveOB curveOB.select_set(True) bpy.ops.object.editmode_toggle() bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.handle_type_set(type='AUTOMATIC') #bpy.ops.curve.make_segment() bpy.ops.object.editmode_toggle() bpy.ops.object.modifier_add(type='SHRINKWRAP') bpy.context.object.modifiers["Shrinkwrap"].target = Rosto bpy.context.object.modifiers["Shrinkwrap"].offset = 0.01 bpy.context.object.modifiers["Shrinkwrap"].wrap_mode = 'ABOVE_SURFACE' #bpy.context.space_data.context = 'MODIFIER' bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Shrinkwrap") #bpy.context.space_data.context = 'DATA' bpy.context.object.data.bevel_depth = 4 bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].octree_depth = 6 bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' GuiaBaseNome = str("GuiaBase-"+strftime("%Y%m%d%H%M%S", gmtime())) bpy.context.object.name = GuiaBaseNome bpy.ops.object.select_all(action='DESELECT') Rosto.select_set(True) bpy.context.view_layer.objects.active = Rosto bpy.ops.object.duplicate() bpy.context.object.active_shape_key_index = 0 # Seleciona o primeiro para apagar e manter o segundo como forma. bpy.ops.object.shape_key_remove(all=False) bpy.ops.object.shape_key_remove(all=False) bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 8 bpy.context.object.modifiers["Remesh"].scale = 0.99 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh") NomeFaceNova = str("FaceDelete-"+strftime("%Y%m%d%H%M%S", gmtime())) # strftime("%Y-%m-%d %H:%M:%S", gmtime())) bpy.context.object.name = NomeFaceNova bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[NomeFaceNova].select_set(True) bpy.data.objects[GuiaBaseNome].select_set(True) bpy.context.view_layer.objects.active = bpy.data.objects[NomeFaceNova] bpy.ops.object.booleana_osteo_geral() bpy.ops.object.modifier_add(type='REMESH') bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH' bpy.context.object.modifiers["Remesh"].octree_depth = 8 bpy.context.object.modifiers["Remesh"].scale = 0.99 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh") class GeraGuiaNariz(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_guia_nariz" bl_label = "Nose Guide Generator" def execute(self, context): GeraGuiaNarizDef() return {'FINISHED'} bpy.utils.register_class(GeraGuiaNariz) def EsculturaGrabDef(): context = bpy.context scn = context.scene bpy.context.space_data.shading.type = 'MATERIAL' bpy.ops.object.mode_set(mode = 'SCULPT') bpy.ops.wm.tool_set_by_id(name="builtin_brush.Grab") bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False class EsculturaGrab(bpy.types.Operator): """Tooltip""" bl_idname = "object.escultura_grab" bl_label = "Change to Grab" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT' or bpy.context.mode == 'SCULPT': return True else: return False else: return False def execute(self, context): EsculturaGrabDef() return {'FINISHED'} bpy.utils.register_class(EsculturaGrab) def EsculturaSmoothDef(): context = bpy.context scn = context.scene bpy.context.space_data.shading.type = 'MATERIAL' bpy.ops.object.mode_set(mode = 'SCULPT') bpy.ops.wm.tool_set_by_id(name="builtin_brush.Smooth") bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False class EsculturaSmooth(bpy.types.Operator): """Tooltip""" bl_idname = "object.escultura_smooth" bl_label = "Change to Smooth" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT' or bpy.context.mode == 'SCULPT': return True else: return False else: return False def execute(self, context): EsculturaSmoothDef() return {'FINISHED'} bpy.utils.register_class(EsculturaSmooth) def EsculturaMaskDef(): context = bpy.context scn = context.scene bpy.context.space_data.shading.type = 'MATERIAL' bpy.ops.object.mode_set(mode = 'SCULPT') bpy.ops.wm.tool_set_by_id(name="builtin_brush.Mask") bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False class EsculturaMask(bpy.types.Operator): """Tooltip""" bl_idname = "object.escultura_mask" bl_label = "Change to Mask" @classmethod def poll(cls, context): o = context.object if o is None: return False else: if o.type == "MESH": if bpy.context.mode == 'OBJECT' or bpy.context.mode == 'SCULPT': return True else: return False else: return False def execute(self, context): EsculturaMaskDef() return {'FINISHED'} bpy.utils.register_class(EsculturaMask) def MaterialTransparentePosDef(): m = Material() m.set_cycles() m.make_material("FaceRhinPos") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] diffuseBSDF = m.nodes['Principled BSDF'] # diffuseBSDF.inputs["Base Color"].default_value = [0.3, 0.2, 0.4, 0.5] materialOutput = m.nodes['Material Output'] transparentBSDF = m.makeNode('ShaderNodeBsdfTransparent', 'Transparent BSDF') #bpy.data.node_groups["Shader Nodetree"].nodes["Translucent BSDF"].inputs[0].default_value = (0.8, 0.8, 0.8, 0.00745112) mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.dump_node(mixShader) mixShader.inputs['Fac'].default_value = 0.3 m.link(transparentBSDF, 'BSDF', mixShader, 1) m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(mixShader, 'Shader', materialOutput, 'Surface') m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["FaceRhinPos"] bpy.context.object.active_material.blend_method = 'BLEND' def MaterialTransparentePreDef(): m = Material() m.set_cycles() m.make_material("FaceRhinPre") ImageTexture = m.makeNode('ShaderNodeTexImage', 'Image Texture') ImageTexture.image = bpy.data.images['scene_dense_mesh_texture_material_0_map_Kd.jpg'] diffuseBSDF = m.nodes['Principled BSDF'] # diffuseBSDF.inputs["Base Color"].default_value = [0.3, 0.2, 0.4, 0.5] materialOutput = m.nodes['Material Output'] transparentBSDF = m.makeNode('ShaderNodeBsdfTransparent', 'Transparent BSDF') #bpy.data.node_groups["Shader Nodetree"].nodes["Translucent BSDF"].inputs[0].default_value = (0.8, 0.8, 0.8, 0.00745112) mixShader = m.makeNode('ShaderNodeMixShader', 'Mix Shader') m.dump_node(mixShader) mixShader.inputs['Fac'].default_value = 0.3 m.link(transparentBSDF, 'BSDF', mixShader, 1) m.link(diffuseBSDF, 'BSDF', mixShader, 2) m.link(mixShader, 'Shader', materialOutput, 'Surface') m.link(ImageTexture, 'Color', diffuseBSDF, 'Base Color') bpy.ops.object.material_slot_remove() bpy.ops.object.material_slot_add() bpy.data.objects[bpy.context.view_layer.objects.active.name].active_material = bpy.data.materials["FaceRhinPre"] bpy.context.object.active_material.blend_method = 'BLEND' class MaterialTransparenteDois(bpy.types.Operator): """Tooltip""" bl_idname = "object.material_transparente_dois" bl_label = "Material Transparente Pre" def execute(self, context): bpy.data.objects['SoftTissueDynamic_COPY'].hide_viewport = False FacePre = bpy.data.objects['SoftTissueDynamic_COPY'] bpy.ops.object.select_all(action='DESELECT') FacePre.select_set(True) bpy.context.view_layer.objects.active = FacePre MaterialTransparentePreDef() bpy.data.objects['SoftTissueDynamic'].hide_viewport = False FacePos = bpy.data.objects['SoftTissueDynamic'] bpy.ops.object.select_all(action='DESELECT') FacePos.select_set(True) bpy.context.view_layer.objects.active = FacePos MaterialTransparentePosDef() return {'FINISHED'} bpy.utils.register_class(MaterialTransparenteDois) def MaterialTranspPreDef(): bpy.data.materials['FaceRhinPre'].node_tree.nodes["Mix Shader"].inputs[0].default_value = float(bpy.context.scene.mat_transp_pre) class MaterialTranspPre(bpy.types.Operator): """Tooltip""" bl_idname = "object.material_transp_pre" bl_label = "Material Transparente Pre" def execute(self, context): MaterialTranspPreDef() return {'FINISHED'} bpy.utils.register_class(MaterialTranspPre) def MaterialTranspPosDef(): bpy.data.materials['FaceRhinPos'].node_tree.nodes["Mix Shader"].inputs[0].default_value = float(bpy.context.scene.mat_transp_pos) class MaterialTranspPos(bpy.types.Operator): """Tooltip""" bl_idname = "object.material_transp_pos" bl_label = "Material Transparente Pos" def execute(self, context): MaterialTranspPosDef() return {'FINISHED'} bpy.utils.register_class(MaterialTranspPos) class MaterialOpacoDois(bpy.types.Operator): """Tooltip""" bl_idname = "object.material_opaco_dois" bl_label = "Material Opaco Dois" def execute(self, context): bpy.data.objects['SoftTissueDynamic_COPY'].hide_viewport = False FacePre = bpy.data.objects['SoftTissueDynamic_COPY'] bpy.ops.object.select_all(action='DESELECT') FacePre.select_set(True) bpy.context.view_layer.objects.active = FacePre bpy.context.object.active_material.blend_method = 'OPAQUE' #FacePre.hide_viewport = True bpy.data.objects['SoftTissueDynamic'].hide_viewport = False FacePos = bpy.data.objects['SoftTissueDynamic'] bpy.ops.object.select_all(action='DESELECT') FacePos.select_set(True) bpy.context.view_layer.objects.active = FacePos bpy.context.object.active_material.blend_method = 'OPAQUE' bpy.context.space_data.shading.type = 'SOLID' bpy.context.space_data.shading.color_type = 'TEXTURE' return {'FINISHED'} bpy.utils.register_class(MaterialOpacoDois) def RhinFotogrametriaDecDef(): bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.gera_modelo_foto() bpy.ops.object.modifier_add(type='DECIMATE') bpy.context.object.modifiers["Decimate"].ratio = 0.5 bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate") class RhinFotogrametriaDec(bpy.types.Operator): """Tooltip""" bl_idname = "object.rhin_fotogrametria_dec" bl_label = "Rhin Photogrammetry Decimate" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): RhinFotogrametriaDecDef() return {'FINISHED'} bpy.utils.register_class(RhinFotogrametriaDec) ================================================ FILE: SegmentaImagens.py ================================================ import bpy import tempfile import platform import os from .AjustaTomo import * from .FotogrametriaOpenMVG import * def SegmentacaoImagemFaceDef(): context = bpy.context # obj = context.object scn = context.scene TmpDirSegFace = tempfile.mkdtemp() SegFaceScript = TmpDirSegFace+'/SegmentaFace.py' homeall = expanduser("~") # -------- HEIC ConverteHEICtoJPG() # ------------ with open(SegFaceScript, "a") as ScriptF: ScriptF.write("from imutils import face_utils\n") ScriptF.write("import imutils\n") ScriptF.write("import numpy as np\n") ScriptF.write("import collections\n") ScriptF.write("import dlib\n") ScriptF.write("import cv2\n") ScriptF.write("from os.path import expanduser\n") ScriptF.write("import platform\n") ScriptF.write("import os\n") ScriptF.write("from os import listdir\n") ScriptF.write("from os.path import isfile, join\n") ScriptF.write("\n") ScriptF.write("def face_remap(shape):\n") ScriptF.write(" remapped_image = cv2.convexHull(shape)\n") ScriptF.write(" return remapped_image\n") ScriptF.write("\n") ScriptF.write("def GeraImagemComMascara(imgOriginal, imgFinal):\n") ScriptF.write("\n") ScriptF.write(" image = cv2.imread(imgOriginal)\n") Arquivo = os.listdir(scn.my_tool.path_photo)[0] Imagem = bpy.data.images.load(scn.my_tool.path_photo+Arquivo) Largura = str(Imagem.size[1]) print("A largura é:", Largura) ScriptF.write(" image = imutils.resize(image, width="+Largura+")\n") ScriptF.write(" gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n") ScriptF.write("\n") ScriptF.write(" out_face = np.zeros_like(image)\n") ScriptF.write("\n") ScriptF.write(" detector = dlib.get_frontal_face_detector()\n") if platform.system() == "Linux": ScriptF.write(" predictor = dlib.shape_predictor('/home/linux3dcs/Programs/OrtogOnBlender/SegmentaImagens/shape_predictor_81_face_landmarks.dat')\n") if platform.system() == "Windows": ScriptF.write(" predictor = dlib.shape_predictor('C:\OrtogOnBlender\SegmentaImagens\shape_predictor_81_face_landmarks.dat')\n") if platform.system() == "Darwin": ScriptF.write(" predictor = dlib.shape_predictor('"+homeall+"/Programs/OrtogOnBlender/SegmentaImagens/shape_predictor_81_face_landmarks.dat')\n") ScriptF.write("\n") ScriptF.write(" rects = detector(gray, 1)\n") ScriptF.write("\n") ScriptF.write("\n") ScriptF.write(" for (i, rect) in enumerate(rects):\n") ScriptF.write("\n") ScriptF.write(" shape = predictor(gray, rect)\n") ScriptF.write(" shape = face_utils.shape_to_np(shape)\n") ScriptF.write("\n") ScriptF.write(" remapped_shape = np.zeros_like(shape)\n") ScriptF.write(" feature_mask = np.zeros((image.shape[0], image.shape[1]))\n") ScriptF.write("\n") ScriptF.write(" remapped_shape = face_remap(shape)\n") ScriptF.write(" cv2.fillConvexPoly(feature_mask, remapped_shape[0:27], 1)\n") ScriptF.write(" feature_mask = feature_mask.astype(np.bool)\n") ScriptF.write(" out_face[feature_mask] = image[feature_mask]\n") ScriptF.write(" cv2.imshow('mask_inv', out_face)\n") ScriptF.write(" cv2.imwrite(imgFinal, out_face)\n") ScriptF.write("\n") ScriptF.write("def AdicionaModeloDistanciaFocal(diretorioFinalFotos):\n") ScriptF.write("\n") ScriptF.write(" homeall = expanduser('~')\n") ScriptF.write("\n") ScriptF.write(" if platform.system() == 'Linux':\n") ScriptF.write(" os.system('cd '+diretorioFinalFotos+' && exiftool -overwrite_original -Model=\"Z00AD\" -FocalLength=\"3.8 mm\" *')\n") # '+homeall+'/Programs/OrtogOnBlender/openMVG/ExifTool.sh # exiftool -overwrite_original -Model="Z00AD" -FocalLength="3.8 mm" * ScriptF.write("\n") ScriptF.write(" if platform.system() == 'Darwin':\n") ScriptF.write(" os.system('cd '+diretorioFinalFotos+' && /OrtogOnBlender/openMVGMACelcap/ExifTool.sh')\n") ScriptF.write("\n") ScriptF.write(" if platform.system() == 'Windows':\n") ScriptF.write(" print(mypath)\n") ScriptF.write(" subprocess.call(['C:\OrtogOnBlender\ExitTool\exiftool.exe', '-overwrite_original', '-Model=\"Z00AD\"', '-FocalLength=4', diretorioFinalFotos+'*'])\n") ScriptF.write("\n") ScriptF.write("dirOrigi = '/home/linux3dcs/prj/Estudos/DLIB/ROSTO/'\n") if platform.system() == "Linux" or platform.system() == "Darwin": ScriptF.write("os.mkdir('"+TmpDirSegFace+"/SegmentedPhotos')\n") if platform.system() == "Windows": ScriptF.write("os.mkdir(r'"+TmpDirSegFace+"/SegmentedPhotos')\n") if platform.system() == "Linux" or platform.system() == "Darwin": ScriptF.write("dirFinal = '"+TmpDirSegFace+"/SegmentedPhotos/'\n") if platform.system() == "Windows": ScriptF.write("dirFinal = r'"+TmpDirSegFace+"/SegmentedPhotos/'\n") ScriptF.write("\n") if platform.system() == "Linux" or platform.system() == "Darwin": ScriptF.write("mypath = '"+scn.my_tool.path_photo+"'\n") if platform.system() == "Windows": ScriptF.write("mypath = '"+scn.my_tool.path_photo+"\\'\n") ScriptF.write("\n") ScriptF.write("onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]\n") ScriptF.write("\n") ScriptF.write("for i in onlyfiles:\n") ScriptF.write(" GeraImagemComMascara(mypath+i, dirFinal+i)\n") ScriptF.write(" print('Image '+i+' Finished!')\n") ScriptF.write("AdicionaModeloDistanciaFocal(dirFinal)\n") ScriptF.close() if platform.system() == "Linux" or platform.system() == "Darwin": os.system('python3 '+TmpDirSegFace+'/SegmentaFace.py') scn.my_tool.path_photo = TmpDirSegFace+"/SegmentedPhotos/" abrir_diretorio(TmpDirSegFace+"/SegmentedPhotos/") if platform.system() == "Windows": os.system('C:\OrtogOnBlender\Python36\python '+TmpDirSegFace+'/SegmentaFace.py') scn.my_tool.path_photo = TmpDirSegFace+"/SegmentedPhotos/" abrir_diretorio(TmpDirSegFace+"/SegmentedPhotos/") class SegmentacaoImagemFace(bpy.types.Operator): """Tooltip""" bl_idname = "object.segmenta_imagem_face" bl_label = "Imagem Segmentation" def execute(self, context): SegmentacaoImagemFaceDef() return {'FINISHED'} bpy.utils.register_class(SegmentacaoImagemFace) ================================================ FILE: TomoReconsRapida.py ================================================ import bpy import os import pydicom as dicom from collections import Counter import tempfile import shutil import subprocess import platform def GeraModelo3DTomo(ossos, mole, dentes): context = bpy.context obj = context.object scn = context.scene #if ReducaoTomo == "REDUZIR": # NÃO USAR!!! # bpy.ops.object.reduz_dimensao_dicom() # NÃO USAR!!! bpy.ops.object.corrige_dicom() bpy.ops.object.corrige_tomo_raw() bpy.context.scene.interesse_ossos = ossos bpy.context.scene.interesse_mole = mole bpy.context.scene.interesse_dentes = dentes print("TENTATIVA 1") try: bpy.ops.object.gera_modelo_tomo_manual() except: print("\nERROO!") print("TENTATIVA 2") scn.my_tool.path = tmpdirTomo bpy.ops.object.gera_modelo_tomo_manual() def CorrigeTomoRawDef(): context = bpy.context obj = context.object scn = context.scene os.chdir(scn.my_tool.path) if platform.system() == "Linux" or platform.system() == "Darwin": subprocess.call('for i in *; do gdcmconv -w -i $i -o '+tmpdirTomo2+'/$i; done', shell=True) print("Tomografia corrigida!!!") if platform.system() == "Windows": subprocess.call('for %f in (*) do C:\OrtogOnBlender\GDCM\gdcmconv -w -i %f -o '+tmpdirTomo2+'/%f', shell=True) print("Tomografia corrigida!!!") scn.my_tool.path = tmpdirTomo2 class CorrigeTomoRaw(bpy.types.Operator): """Tooltip""" bl_idname = "object.corrige_tomo_raw" bl_label = "CT-Scan fix raw" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): CorrigeTomoRawDef() return {'FINISHED'} bpy.utils.register_class(CorrigeTomoRaw) def TomoRecRapidaDef(): context = bpy.context obj = context.object scn = context.scene DirTomoOriginal = scn.my_tool.path # Listar todos os arquivos ListaArquivosAbs = [] #DiretorioDCM = '/home/linux3dcs/del/TOMOGRAFIAS_ESTUDOS/DAVI/000' for dirname, dirnames, filenames in os.walk(scn.my_tool.path): for filename in filenames: print(os.path.join(dirname, filename)) ListaArquivosAbs.append(os.path.join(dirname, filename)) #print(ListaArquivosAbs) ListaConvolutionKernel = [] ListaSeriesNumber = [] ListaArquivosDICOM = [] #ListaInstanceCreationTime = [] NaoEhDICOM = [] # Pesquisa os arquivos for ArquivoAtual in ListaArquivosAbs: try: ds = dicom.dcmread(ArquivoAtual, force=True) ListaArquivosDICOM.append(ArquivoAtual) #print("SERIESSSSSS", ds.SeriesNumber) if ds.SeriesNumber == "": try: ds.SeriesNumber = "198291829182" ds.save_as(str(ArquivoAtual)) print("SALVOOOO") except: print("PROBLEMA NA INSERÇÃO!") #ListaInstanceCreationTime.append(ds.InstanceCreationTime) try: ListaSeriesNumber.append(ds.SeriesNumber) except: print("Problem com o SeriesNumer") print("Series:", ArquivoAtual) try: ListaConvolutionKernel.append(ds.ConvolutionKernel) except: print("ConvKernel:", ArquivoAtual) except: NaoEhDICOM.append(ArquivoAtual) # print(ArquivoAtual, "Não é!") print("FINISHED!") #for i in NaoEhDICOM: # print(i, "Não é DICOM!") #print(DiretorioDCM) #print(Counter(ListaInstanceCreationTime)) print(Counter(ListaSeriesNumber)) try: print(Counter(ListaConvolutionKernel)) except: print("Problema ao imprimir o ConvKernel") SeriesValores = Counter(ListaSeriesNumber) print("SERIES") print(SeriesValores) listaSeries = [] for i in SeriesValores: if i == '': i = "2312457886300" listaSeries.append([SeriesValores[i], int(i)]) print("ORDEM ORIGINAL") print(listaSeries) # Calcula o número de arquivos por diretório print("SORT") listaFinal = sorted(listaSeries, reverse=True) print(sorted(listaSeries, reverse=True)) print("Diretório com mais arquivos:", listaFinal[0][1]) DiretorioFinal = listaFinal[0][1] # Copia os arquivos para diretório temporário global tmpdirTomo global tmpdirTomo2 tmpdirTomo = tempfile.mkdtemp() tmpdirTomo2 = tempfile.mkdtemp() DCMNum = 0 for ArquivoAtual in ListaArquivosDICOM: ds = dicom.dcmread(ArquivoAtual, force=True) try: if ds.SeriesNumber == DiretorioFinal: #print(ds.SeriesNumber ) os.chdir(tmpdirTomo) shutil.copy(ArquivoAtual, "Copy-"+str(DCMNum)) #print("Copiado de: ", ArquivoAtual, " Para: ", "Copy-"+str(DCMNum)) DCMNum += 1 except: print("Erro de leitura do SeriesNumber no:", ArquivoAtual) scn.my_tool.path = tmpdirTomo print("Arquivos DICOM copiados!") # Captura o 0018,1210 do primeiro arquivo ArquivoTopo = os.listdir(os.getcwd())[0] print("Arquivo topo:", ArquivoTopo) ds = dicom.dcmread(ArquivoTopo, force=True) #global ReducaoTomo try: ConvKernel = ds.ConvolutionKernel print("ConvolutionKernel:", ConvKernel) except: ConvKernel = "" print("Erro no ConvKernel!") try: Manufacturer = ds.Manufacturer print("Manufacturer", Manufacturer) except: Manufacturer = "" print("Erro no Manufacturer!") ''' try: DimPixelsX = ds.Rows DimPixelsY = ds.Columns if DimPixelsX > 512 or DimPixelsY > 512: ReducaoTomo = "REDUZIR" else: ReducaoTomo = "NAO REDUZIR" except: ReducaoTomo = "Problema" print("Problema ao verificar as dimensões") ''' # Reconstrói tomografia HELICOIDAL if not ConvKernel == "" and not Manufacturer == "NewTom": try: print("Há ConvKernel!") if ConvKernel == "FC03" or ConvKernel =="FC04" or ConvKernel == "STANDARD" or ConvKernel == "H30s" or ConvKernel == "SOFT" or ConvKernel == "UB" or ConvKernel == "SA" or ConvKernel == "FC23" or ConvKernel == "FC08" or ConvKernel == ['Hr40f', '3'] or ConvKernel == "FC21" or ConvKernel =="A" or ConvKernel =="FC02" or ConvKernel =="B" or ConvKernel =="H23s" or ConvKernel =="H20s" or ConvKernel == "H31s" or ConvKernel == "H32s" or ConvKernel == ['J30s', '3'] or ConvKernel == "H40s" or ConvKernel == "H31s" or ConvKernel == "B41s" or ConvKernel == "B70s" or ConvKernel == "H22s" or ConvKernel == ['J30f', '2'] or ConvKernel == "H20f" or ConvKernel == "FC68" or ConvKernel == "FC07" or ConvKernel == "B30s" or ConvKernel == "B41s" or ConvKernel == ['I31f', '3'] or ConvKernel == ['Br40f', '3'] or ConvKernel == "D10f" or ConvKernel == "B45s" or ConvKernel == "B26f" or ConvKernel == "B30f" or ConvKernel == "32" or ConvKernel == "SB": GeraModelo3DTomo("200", "-300", "1430") if ConvKernel == "BONE" or ConvKernel =="BONEPLUS" or ConvKernel =="FC30" or ConvKernel =="H70s" or ConvKernel =="D" or ConvKernel =="EA" or ConvKernel == ['Hr60f', '3'] or ConvKernel =="FC81" or ConvKernel =="YC" or ConvKernel =="YD" or ConvKernel =="H70h" or ConvKernel =="H60s" or ConvKernel == "H60f" or ConvKernel == "FC35" or ConvKernel == "B80s" or ConvKernel == "H90s" or ConvKernel == ['I70f', '3'] or ConvKernel == "B70f": GeraModelo3DTomo("400", "-300", "995") except: # Usa o diretório FIXED em caso de erro com o gdcmconv print("Problema na reconstrução... tentando outro meio:") DirTemporario = tempfile.gettempdir() if os.path.isfile(DirTemporario+"/tmpdirFIXED.txt"): arquivo = open(DirTemporario+"/tmpdirFIXED.txt", 'r') DiretorioFIXED = arquivo.read() arquivo.close() scn.my_tool.path = DiretorioFIXED bpy.ops.object.gera_modelo_tomo_manual() if not os.path.isfile(DirTemporario+"/tmpdirFIXED.txt"): print("Infelizmente não foi possível reconstruir, tente exportar no Slicer!") # Reconstrói tomografia CONE BEAM # Excepcionalmente! if not ConvKernel == "" and Manufacturer == "NewTom": GeraModelo3DTomo("606", "-466", "1032") # Normal if ConvKernel == "" and not Manufacturer == "": print("Tentando pelo modelo...") if Manufacturer == "Imaging Sciences International": GeraModelo3DTomo("358", "-629", "995") if Manufacturer == "Xoran Technologies ®": GeraModelo3DTomo("331", "-679", "1052") if Manufacturer == "Planmeca": GeraModelo3DTomo("330", "-548", "756") if Manufacturer == "J.Morita.Mfg.Corp.": GeraModelo3DTomo("487", "-315", "787") if Manufacturer == "Carestream Health": GeraModelo3DTomo("388", "-598", "1013") if Manufacturer == "NewTom": GeraModelo3DTomo("606", "-466", "1032") if Manufacturer == "MyRay": GeraModelo3DTomo("850", "-360", "1735") if Manufacturer == "NIM": GeraModelo3DTomo("1300", "-1", "1260") if Manufacturer == "PreXion": GeraModelo3DTomo("312", "-687", "1505") if Manufacturer == "Sirona": GeraModelo3DTomo("590", "-170", "780") if Manufacturer == "Dabi Atlante": GeraModelo3DTomo("575", "-375", "1080") if Manufacturer == "INSTRUMENTARIUM DENTAL": GeraModelo3DTomo("430", "-480", "995") class TomoRecRapida(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelotomo_rec_rapida" bl_label = "CT-Scan fast auto reconstruction" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): TomoRecRapidaDef() return {'FINISHED'} bpy.utils.register_class(TomoRecRapida) ================================================ FILE: Version.py ================================================ import bpy VERSION = "2020-08-18a-lin" ================================================ FILE: __init__.py ================================================ bl_info = { "name": "New Object", "author": "Your Name Here", "version": (1, 0), "blender": (2, 80, 0), "location": "View3D > Add > Mesh > New Object", "description": "OrtogOnBlender", "warning": "", "wiki_url": "", "category": "Ortog", } if "bpy" in locals(): import imp imp.reload(ImportaArmature) # imp.reload(GeraModelosTomo) print("Reloaded multifiles") else: from .SegmentaImagens import * from .CompareOnBlender import * from .RhinOnBlender import * from .ForensicOnBlender import * from .OtherOnBlender import * from .NomePaciente import * from .GeraModelosTomo import * from .AjustaTomo import * from .OrtogMeshes import * from .Version import * from .FerrSegmentacao import * from .FerrMedidas import * from .BooleanaOsteo import * from .AlinhaObjetos import * from .FotogrametriaOpenMVG import * from . FotogrametriaOpenMVGWinWSL import * # Solcao erro Windows from .FotogrametriaSMVS import * from .FotogrametriaMeshroom import * # from .AlinhaTresPontosNovo import * from .AlinhaRedimensiona import * from .DesenhaObjetos import * from .FerrFisica import * from .ConfOsteotomiaAuto import * from .DinamicaMole import * from .AtualizaScript import * from .PontosAnatomicos import * from .DesenhaGuia import * from .RelatorioAnimacao import * from .Poisson import * from .FerrImgTomo import * from .Cefalometria import * from .GeraRelatorio import * from .CriaSplint import * from .FerrMalhas import * import bpy from bpy_extras.object_utils import AddObjectHelper, object_data_add from bpy.props import (StringProperty, PointerProperty, BoolProperty, ) from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup, ) # Comandos Booleanos # ATUALIZA SCRIPT class ORTOG_PT_AtualizaAddonSec(bpy.types.Panel): bl_label = "Upgrade Script" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="VERSION: "+VERSION) row = layout.row() row.operator("object.atualiza_script", text="UPGRADE ORTOG!", icon="RECOVER_LAST") class ORTOG_PT_NomePaciente(bpy.types.Panel): bl_label = "Patient's Name" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render # row = layout.row() # row.label(text="CT-Scan Reconstruction:") # col = layout.column(align=True) # col.prop(scn.my_tool, "path", text="") row = layout.row() # row.operator("object.tomo_heli", text="CT-Scan") # row.operator("object.tomo_cone", text="CBCT") col = self.layout.column(align = True) col.prop(context.scene, "nome_paciente") col = self.layout.column(align = True) col.prop(context.scene, "sobrenome_paciente") box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente", text="SAVE!", icon="FILE_TICK") class ORTOG_UI_Local(PropertyGroup): path = StringProperty( name="", description="Path to Directory", maxlen=1024, subtype='DIR_PATH') path_slices_img = StringProperty( name="", description="Path to Directory", maxlen=1024, subtype='DIR_PATH') path_photo = StringProperty( name="", description="Path to Directory", maxlen=1024, subtype='DIR_PATH') filepathmha = StringProperty( name="", description="Select File", maxlen=1024, subtype='FILE_PATH') filepathcsv = StringProperty( name="", description="Select File", maxlen=1024, subtype='FILE_PATH') filepathobj = StringProperty( name="", description="Select File", maxlen=1024, subtype='FILE_PATH') filepathvideo = StringProperty( name="", description="Select File", maxlen=1024, subtype='FILE_PATH') imagem_bool = BoolProperty( name="", description="Decrease picture size!", default = True ) # IMPORTA TOMO MOLDES class ENUM_VALUES_CTSCAN: MANUAL = 'Manual' DEFAULT = 'Default' VOXEL = 'Voxel' VOXEL_FULL = 'Voxel Full' AUTO = 'Auto' CUSTOM = 'Custom' AUTOEXP = 'Auto EXP.!!!' class ORTOG_PT_CTScanSelect(bpy.types.Panel): bl_label = "CT-Scan Reconstruction" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.prop(scn, "my_enum_ct") my_enum_ct = scn.my_enum_ct if my_enum_ct == ENUM_VALUES_CTSCAN.MANUAL: row = layout.row() row.label(text="CT-Scan Preparing:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") # layout.prop(rd, "filepath", text="") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.ajusta_tomo", text="Organize", icon="NODETREE") row = layout.row() row = layout.row() # row.label(text="CT-Scan Fix:") # col = layout.column(align=True) # col.prop(scn.my_tool, "path", text="") # row = layout.row() # row.operator("object.corrige_dicom", text="Fix it!", icon="FILE_TICK") row = layout.row() row.label(text="Threshold Setup:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.abre_slicer", text="Open Slicer!", icon="FILE_TICK") row = layout.row() row.label(text="CT-Scan 3D Reconstruction:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() # row.operator("object.tomo_heli", text="CT-Scan") # row.operator("object.tomo_cone", text="CBCT") col = self.layout.column(align = True) #col.scale_y=1.5 col.alignment = 'CENTER' col.prop(context.scene, "interesse_ossos") col = self.layout.column(align = True) col.alignment = 'CENTER' col.prop(context.scene, "interesse_mole") col = self.layout.column(align = True) col.alignment = 'CENTER' col.prop(context.scene, "interesse_dentes") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() # row.operator("object.gera_modelos_tomo", text="Convert DICOM to 3D", icon="SNAP_FACE") row.operator("object.gera_modelo_tomo_manual", text="Convert DICOM to 3D", icon="SNAP_FACE") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_tomo", text="SAVE!", icon="FILE_TICK") if my_enum_ct == ENUM_VALUES_CTSCAN.DEFAULT: #row = layout.row() #row.label(text="Default CT-Scan Reconstruction:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.gera_modelotomo_rec_rapida", text="CT-Scan Reconstruction", icon="SNAP_FACE") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_tomo_auto", text="SAVE!", icon="FILE_TICK") if my_enum_ct == ENUM_VALUES_CTSCAN.VOXEL: row = layout.row() row.label(text="CT-Scan Preparing:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.ajusta_tomo", text="Organize", icon="NODETREE") row = layout.row() row.label(text="CT-Scan Voxel Importing:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") # layout.prop(rd, "filepath", text="") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.importa_fatias_dcm", text="Import DICOM Slices", icon="ALEMBIC") # row = layout.row() # prefs = context.preferences # system = prefs.system # row.prop(system, "gl_clip_alpha", slider=True) row = layout.row() row.label(text="View/Shader/Material:") scene = context.scene props = scene.eevee self.layout.prop(props, "use_gtao", text="Ambient Occlusion") row = layout.row() row.operator("object.voxelshader_osso", text="Bone", icon="NODE_MATERIAL") row = layout.row() row.operator("object.voxelshader_musculo", text="Muscle", icon="NODE_MATERIAL") row = layout.row() row.operator("object.voxelshader_pele", text="Skin", icon="NODE_MATERIAL") row = layout.row() row.operator("object.voxelshader_default", text="Default", icon="NODE_MATERIAL") box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_voxel", text="SAVE!", icon="FILE_TICK") if my_enum_ct == ENUM_VALUES_CTSCAN.VOXEL_FULL: row = layout.row() row.label(text="CT-Scan Preparing:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.ajusta_tomo", text="Organize", icon="NODETREE") row = layout.row() row.label(text="CT-Scan Voxel Importing:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") # layout.prop(rd, "filepath", text="") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.importa_fatias_axial_coronal_sagital", text="Import DICOM Slices", icon="ALEMBIC") # row = layout.row() # prefs = context.preferences # system = prefs.system # row.prop(system, "gl_clip_alpha", slider=True) row = layout.row() row.label(text="View/Shader/Material:") scene = context.scene props = scene.eevee self.layout.prop(props, "use_gtao", text="Ambient Occlusion") row = layout.row() row.operator("object.voxelshader_osso", text="Bone", icon="NODE_MATERIAL") row = layout.row() row.operator("object.voxelshader_musculo", text="Muscle", icon="NODE_MATERIAL") row = layout.row() row.operator("object.voxelshader_pele", text="Skin", icon="NODE_MATERIAL") row = layout.row() row.operator("object.voxelshader_default", text="Default", icon="NODE_MATERIAL") box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_voxel", text="SAVE!", icon="FILE_TICK") if my_enum_ct == ENUM_VALUES_CTSCAN.AUTO: row = layout.row() row.label(text="Automatic Reconstruction:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.gera_modelos_tomo_auto", text="AUTOMATIC DICOM TO 3D", icon="SNAP_FACE") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_tomo_auto", text="SAVE!", icon="FILE_TICK") if my_enum_ct == ENUM_VALUES_CTSCAN.CUSTOM: row = layout.row() row.label(text="CT-Scan Preparing:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") # layout.prop(rd, "filepath", text="") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.ajusta_tomo", text="Organize", icon="NODETREE") row = layout.row() row = layout.row() # row.label(text="CT-Scan Fix:") # col = layout.column(align=True) # col.prop(scn.my_tool, "path", text="") # row = layout.row() # row.operator("object.corrige_dicom", text="Fix it!", icon="FILE_TICK") row = layout.row() row.label(text="Threshold Setup:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.abre_slicer", text="Open Slicer!", icon="FILE_TICK") row = layout.row() row.label(text="CT-Scan 3D Reconstruction:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() # row.operator("object.tomo_heli", text="CT-Scan") # row.operator("object.tomo_cone", text="CBCT") col = self.layout.column(align = True) col.alignment = 'CENTER' col.prop(context.scene, "interesse_geral") col = self.layout.column(align = True) col.alignment = 'CENTER' col.prop(context.scene, "fator_simplificacao") col = self.layout.column(align = True) col.alignment = 'CENTER' col.prop(context.scene, "nome_objeto") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() # row.operator("object.gera_modelos_tomo", text="Convert DICOM to 3D", icon="SNAP_FACE") row.operator("object.gera_modelo_tomo_custom", text="Convert DICOM to 3D", icon="SNAP_FACE") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_tomo", text="SAVE!", icon="FILE_TICK") if my_enum_ct == ENUM_VALUES_CTSCAN.AUTOEXP: row = layout.row() row.label(text="Automatic Experimental:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") row = layout.row() row.operator("object.gera_modelotomo_auto_mole", text="AUTOMATIC DICOM TO 3D", icon="SNAP_FACE") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_tomo_auto", text="SAVE!", icon="FILE_TICK") class ORTOG_OT_GeraModelosTomoArc(bpy.types.Operator): """Tooltip""" bl_idname = "object.gera_modelos_tomo_arc" bl_label = "Gera Tomografia Molde" def execute(self, context): GeraModelosTomoArcDef(self, context) return {'FINISHED'} class ORTOG_PT_ImportaArc(bpy.types.Panel): bl_label = "Import Archs" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene # scene = context.scene # rd = scene.render row = layout.row() row.label(text="Arch Teeth Import:") col = layout.column(align=True) col.prop(scn.my_tool, "path", text="") ''' if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") ''' row = layout.row() row.operator("object.abre_slicer", text="Open Slicer!", icon="FILE_TICK") col = self.layout.column(align = True) col.prop(context.scene, "interesse_arco") row = layout.row() row.operator("object.gera_modelos_tomo_arc", text="Arch Generator", icon="SNAP_FACE") row = layout.row() row = layout.row() row.label(text="Import File:") row = layout.row() row.operator("import_mesh.stl", text="Import STL", icon="IMPORT") row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Alignment:") row = layout.row() linha=row.operator("object.emp1a", text="Point 1a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp1b", text="Point 1b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.emp2a", text="Point 2a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp2b", text="Point 2b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.emp3a", text="Point 3a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp3b", text="Point 3b - Align", icon="SORTBYEXT") row = layout.row() row.label(text="Select align object!") row = layout.row() linha=row.operator("object.alinha_tres_pontos", text="ALIGN!", icon="MESH_DATA") row = layout.row() row.label(text="Select other object!") # row = layout.row() # linha=row.operator("object.align_icp", text="ICP Align", icon="TRACKING_REFINE_FORWARDS") row = layout.row() linha=row.operator("object.force_icp", text="Force ICP Align (Slow)", icon="TRACKING_REFINE_FORWARDS") row = layout.row() row = layout.row() row.label(text="Segmentation:") row = layout.row() row.operator("object.prepara_impressao_3d", text="Close Holes (Remesh)?", icon="META_CUBE") row = layout.row() row = layout.row() row = layout.row() # row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row.operator("object.linha_corte_fora_a_fora", icon='LINE_DATA', text="Draw Line") row = layout.row() circle=row.operator("object.desenha_booleana_dentro", text="Subtract IN", icon="LIGHTPROBE_CUBEMAP") row = layout.row() circle=row.operator("object.desenha_booleana_fora", text="Subtract OUT", icon="MESH_CUBE") row = layout.row() row = layout.row() linha=row.operator("object.entra_editmode_limpo", text="Edit Mode Clean", icon="UV_VERTEXSEL") row = layout.row() linha=row.operator("mesh.select_more", text="Sel. More", icon="ADD") linha=row.operator("mesh.select_less", text="Sel. Less", icon="REMOVE") row = layout.row() linha=row.operator("object.separa_objeto", text="Separate Selected!", icon="MOD_BEVEL") row = layout.row() row = layout.row() circle=row.operator("object.booleana_osteo_union", text="Union", icon="MOD_CAST") row = layout.row() row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.label(text="Pivot Rotation:") obj = context.active_object tool_settings = context.tool_settings object_mode = 'OBJECT' if obj is None else obj.mode if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode: layout.prop_with_popover( tool_settings, "transform_pivot_point", text="", icon_only=False, panel="VIEW3D_PT_pivot_point", ) row = layout.row() row.label(text="Reconstruction:") row = layout.row() row.operator("object.fecha_buraco_todos", icon='MOD_TRIANGULATE', text="Close All Holes") row = layout.row() linha=row.operator("mesh.poisson", text="Poisson Reconstruction", icon="MESH_ICOSPHERE") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_arc", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_GraphicRefs(bpy.types.Panel): bl_label = "Graphic References" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.label(text="Frankfurt Alignment:") row = layout.row() linha=row.operator("object.oculta_mole", text="Hide Face (CT-Scan)", icon="HIDE_ON") row = layout.row() linha=row.operator("object.orbital_right_pt", text="Orbital right") linha=row.operator("object.orbital_left_pt", text="Orbital left") row = layout.row() linha=row.operator("object.n_pt", text="N point") linha=row.operator("object.po_left", text="Po left") row = layout.row() row = layout.row() row.operator("object.alinha_cranio_frankfurt", text="Align!", icon="ORIENTATION_LOCAL") row = layout.row() row.label(text="Reference Lines:") row = layout.row() linha=row.operator("mesh.add_linhabase", text="Vertical Center Line", icon="SORT_DESC") linha.location=(0,-200,0) row = layout.row() linha=row.operator("mesh.add_linhabase", text="Horizontal Center Line", icon="FORWARD") linha.location=(0,-200,0) linha.rotation=(0,1.5708,0) row = layout.row() linha=row.operator("mesh.add_linhabase", text="Horizontal Side Line", icon="FORWARD") linha.location=(200,30,0) linha.rotation=(1.5708,0,0) row = layout.row() row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() row = layout.row() row = layout.row() row.operator("object.desagrupa_tomo", text="UNGROUP!!!", icon="PARTICLE_DATA") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_ref", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_Segmentation(bpy.types.Panel): bl_label = "Segmentation" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.operator("object.segmenta_linked", icon='OUTLINER_DATA_CURVE', text="Separate Linked") row = layout.row() row = layout.row() row.operator("object.fecha_buraco_todos", icon='MOD_TRIANGULATE', text="Close All Holes") row = layout.row() row = layout.row() row.label(text="Boolean Segmentation:") row = layout.row() # row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row.operator("object.linha_corte_fora_a_fora", icon='LINE_DATA', text="Draw Line") row = layout.row() row = layout.row() circle=row.operator("object.desenha_booleana_dentro", text="Subtract IN", icon="LIGHTPROBE_CUBEMAP") row = layout.row() circle=row.operator("object.desenha_booleana_fora", text="Subtract OUT", icon="MESH_CUBE") row = layout.row() row.label(text="Boolean:") row = layout.row() circle=row.operator("object.booleana_osteo_geral", text="Difference", icon="MOD_BOOLEAN") row = layout.row() circle=row.operator("object.booleana_osteo_union", text="Union", icon="MOD_CAST") row = layout.row() circle=row.operator("object.booleana_osteo_inter", text="Intersect", icon="MOD_MASK") row = layout.row() row = layout.row() circle=row.operator("object.booleana_union_multipla", text="MULTIPLE UNION", icon="STICKY_UVS_LOC") row = layout.row() row.label(text="Surface Cut:") row = layout.row() row.operator("wm.modal_cria_pontos", icon='CURVE_DATA', text="Create Points") row = layout.row() row.operator("mesh.add_curva_bezier_unido", icon='CURVE_BEZCIRCLE', text="Create Bezier Line") row = layout.row() circle=row.operator("object.bezier_corta", text="Cut Line!", icon="SCULPTMODE_HLT") row = layout.row() circle=row.operator("object.bezier_corta_dupla", text="Cut Line Double!", icon="MOD_THICKNESS") row = layout.row() row.label(text="Teeth Segmentation Tube:") row = layout.row() circle=row.operator("wm.modal_cria_pontos_teeth", text="Create Points", icon="CURVE_DATA") row = layout.row() row.operator("mesh.add_curva_bezier_unido_teeth", icon='CURVE_BEZCIRCLE', text="Create Bezier Tube") row = layout.row() circle=row.operator("object.bezier_corta_dupla_teeth", text="Cut Line Teeth!", icon="MOD_THICKNESS") row = layout.row() row.label(text="Teeth Segmentation Line:") row = layout.row() circle=row.operator("object.prepara_malha_corte", text="Prepare Mesh to Cut", icon="ALEMBIC") row = layout.row() circle=row.operator("mesh.knife_tool", text="Knife Cut", icon="SCULPTMODE_HLT") row = layout.row() circle=row.operator("object.separa_edge_split", text="Edge Split Separation", icon="MATSPHERE") row = layout.row() row.label(text="Separated Teeth:") row = layout.row() row.operator("object.weight_1", text="Weight Paint 1", icon="COLORSET_01_VEC") row = layout.row() row.operator("object.weight_0", text="Weight Paint 0", icon="COLORSET_04_VEC") row = layout.row() linha=row.operator("object.mantem_pintado", text="Delete Blue", icon="GPBRUSH_ERASE_HARD") row = layout.row() linha=row.operator("object.apaga_pintado", text="Delete Red", icon="GPBRUSH_ERASE_HARD") row = layout.row() linha=row.operator("object.booleana_mandib", text="Separate Skull-Mandible", icon="FULLSCREEN_ENTER") row = layout.row() row.label(text="Teeth Touched:") row = layout.row() linha=row.operator("object.condylar_process_right_pt", text="Condylar Process right") row = layout.row() linha=row.operator("object.condylar_process_left_pt", text="Condylar Process left") row = layout.row() linha=row.operator("object.coronoid_process_right_pt", text="Coronoid Process right") row = layout.row() linha=row.operator("object.coronoid_process_left_pt", text="Coronoid Process left") row = layout.row() linha=row.operator("object.go_ramus_fracure_right_pt", text="Mid Go-Ramus Fracure right") row = layout.row() linha=row.operator("object.go_ramus_fracure_left_pt", text="Mid Go-Ramus Fracure left") row = layout.row() linha=row.operator("object.go_right_pt", text="Go right") row = layout.row() linha=row.operator("object.go_left_pt", text="Go left") row = layout.row() linha=row.operator("object.mid_mandibula_angle_right_pt", text="Mid Mandible Angle right") row = layout.row() linha=row.operator("object.mid_mandibula_angle_left_pt", text="Mid Mandible Angle left") row = layout.row() linha=row.operator("object.gn_pt", text="Gn point") row = layout.row() linha=row.operator("object.b_pt", text="B point") row = layout.row() linha=row.operator("object.mid_upper_incisors_pt", text="Mid Upper Incisors") row = layout.row() row = layout.row() linha=row.operator("object.separacao_mandibula", text="Mandible Segmentation", icon="PIVOT_ACTIVE") row = layout.row() row = layout.row() linha=row.operator("object.separacao_mandibula_cranio", text="Separate Skull from Mandible", icon="MONKEY") row = layout.row() row.label(text="Other Tools:") row = layout.row() linha=row.operator("mesh.poisson", text="Poisson Reconstruction", icon="MESH_ICOSPHERE") row = layout.row() row = layout.row() # row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row.operator("object.linha_corte_fora_a_fora", icon='LINE_DATA', text="Draw Line") row = layout.row() linha=row.operator("object.segmenta_desenho", text="Cut Draw!", icon="FCURVE") row = layout.row() row = layout.row() linha=row.operator("object.entra_editmode_limpo", text="Edit Mode Clean", icon="UV_VERTEXSEL") row = layout.row() linha=row.operator("mesh.select_more", text="Sel. More", icon="ADD") linha=row.operator("mesh.select_less", text="Sel. Less", icon="REMOVE") row = layout.row() linha=row.operator("object.separa_objeto", text="Separate Selected!", icon="MOD_BEVEL") row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Pivot Rotation:") obj = context.active_object tool_settings = context.tool_settings object_mode = 'OBJECT' if obj is None else obj.mode if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode: layout.prop_with_popover( tool_settings, "transform_pivot_point", text="", icon_only=False, panel="VIEW3D_PT_pivot_point", ) row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_seg", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_SegmentacaoFace(bpy.types.Panel): bl_label = "Photo Face Segmentation" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") row = layout.row() row.operator("object.segmenta_imagem_face", text="Start Segmentation!", icon="USER") class ORTOG_PT_Converte_Video(bpy.types.Panel): bl_label = "Video to Images" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "filepathvideo", text="") row = layout.row() row.operator("object.converte_video_imagem", text="Convert Video to Images!", icon="RENDER_STILL") class ENUM_VALUES_PHOTOGRAMMETRY: OPENMVG = 'OpenMVG+OpenMVS' SMVS = 'SMVS+MeshLab' MESHROOM = 'Meshroom' OPENMVGWIN = 'OpenMVG Linux on Win' class ORTOG_PT_Fotogrametria(bpy.types.Panel): bl_label = "Photogrammetry Start" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.operator("object.prepara_cena_fotogram", text="Setup Scene!", icon="ERROR") row = layout.row() row = layout.row() row.label(text="Fotogrammetry Algorithm:") row = layout.row() row.prop(scn, "my_enum") my_enum = scn.my_enum if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.OPENMVG: # row = layout.row() # row.label(text="OpenMVG+OpenMVS:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") #self.layout.prop(context.scene, "use_gravity", text="Decrease picture size!") #self.layout.prop(scn.my_tool, "imagem_bool", text="") col.prop(scn.my_tool, "imagem_bool", text="Decrease picture size!") col = self.layout.column(align = True) col.alignment = 'RIGHT' col.prop(context.scene, "d_factor") col.prop(context.scene, "smooth_factor") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.gera_modelo_foto", text="Start Photogrammetry!", icon="IMAGE_DATA") if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.SMVS: # row = layout.row() # row.label(text="SMVS+Meshlab:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") row = layout.row() row.operator("object.gera_modelo_foto_smvs", text="Alternative Photogrammetry I", icon="IMAGE_DATA") if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.MESHROOM: # row = layout.row() # row.label(text="Meshroom (AliceVision):") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") row = layout.row() row.operator("object.gera_modelo_foto_meshroom", text="Alternative Photogrammetry II", icon="IMAGE_DATA") if my_enum == ENUM_VALUES_PHOTOGRAMMETRY.OPENMVGWIN: # row = layout.row() # row.label(text="OpenMVG+OpenMVS:") row = layout.row() col = layout.column(align=True) col.prop(scn.my_tool, "path_photo", text="") col = self.layout.column(align = True) col.alignment = 'RIGHT' col.prop(context.scene, "d_factor") col.prop(context.scene, "smooth_factor") col.prop(scn.my_tool, "imagem_bool", text="Decrease picture size!") if platform.system() == "Windows": row = layout.row() row.operator("wm.console_toggle", text="Open Terminal?", icon="CONSOLE") row = layout.row() row.operator("object.gera_modelo_foto_win", text="Start Photogrammetry!", icon="IMAGE_DATA") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_fotogram", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_AlinhaFace(bpy.types.Panel): bl_label = "Photogrammetry - Align & Scale" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Align Points:") row = layout.row() linha=row.operator("object.emp1b", text="Cantal Lateral Right", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp2b", text="Cantal Lateral Left", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp3b", text="Down Point", icon="SORTBYEXT") # row = layout.row() # row.operator("object.cria_tres_pontos", text="3 Points Click", icon="OUTLINER_OB_MESH") row = self.layout.row(align = True) row.label(text="Real Size:") row.prop(context.scene, "medida_real2") row = layout.row() row.operator("object.alinha_forca", text="Align and Resize!", icon="ORIENTATION_LOCAL") row = layout.row() row = layout.row() row.label(text="Segmentation Cut Through:") row = layout.row() row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row = layout.row() linha=row.operator("object.segmenta_desenho", text="Cut Draw!", icon="FCURVE") row = layout.row() row = layout.row() row.label(text="Surface Cut:") row = layout.row() row.operator("wm.modal_cria_pontos", icon='CURVE_DATA', text="Create Points") row = layout.row() row.operator("mesh.add_curva_bezier_unido", icon='CURVE_BEZCIRCLE', text="Create Bezier Line") row = layout.row() circle=row.operator("object.bezier_corta", text="Cut Line!", icon="SCULPTMODE_HLT") row = layout.row() circle=row.operator("object.bezier_corta_dupla", text="Cut Line Double!", icon="MOD_THICKNESS") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_alinha_face", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_FotogramModif(bpy.types.Panel): bl_label = "Photogrammetry - Modifiers" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context scn = context.scene row = layout.row() row.label(text="Modifiers:") ob = context.object layout.operator_menu_enum("object.modifier_add", "type") for md in ob.modifiers: box = layout.template_modifier(md) if box: # match enum type to our functions, avoids a lookup table. getattr(self, md.type)(box, ob, md) row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.convert", text="APPLY ALL!", icon="ERROR").target='MESH' class ORTOG_PT_AlinhaFaceCT(bpy.types.Panel): bl_label = "Align Face to CT-Scan" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Align Points:") row = layout.row() linha=row.operator("object.emp1a", text="Point 1a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp1b", text="Point 1b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.emp2a", text="Point 2a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp2b", text="Point 2b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.emp3a", text="Point 3a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp3b", text="Point 3b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() row.label(text="Select the object to be aligned!") row = layout.row() linha=row.operator("object.alinha_tres_pontos", text="ALIGN!", icon="MESH_DATA") row = layout.row() row.label(text="Select other object!") # row = layout.row() # linha=row.operator("object.align_icp", text="ICP Align", icon="TRACKING_REFINE_FORWARDS") row = layout.row() linha=row.operator("object.force_icp", text="Force ICP Align (Slow)", icon="TRACKING_REFINE_FORWARDS") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_alinha_foto_tomo", text="SAVE!", icon="FILE_TICK") class ENUM_VALUES_ANATOMICAL: HEAD = 'Head' MAXILLA = 'Maxilla' MANDIBLE = 'Mandible' TEETH = 'Teeth' SOFTTISSUE = 'SoftTissue' class ORTOG_PT_PontosAnatomicos(bpy.types.Panel): bl_label = "Anatomical Points" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.prop(scn, "my_enum_ana") my_enum_ana = scn.my_enum_ana if my_enum_ana == ENUM_VALUES_ANATOMICAL.HEAD: row = layout.row() linha=row.operator("object.orbital_right_pt", text="Orbital right") row = layout.row() linha=row.operator("object.orbital_left_pt", text="Orbital left") row = layout.row() linha=row.operator("object.n_pt", text="N point") row = layout.row() linha=row.operator("object.po_right", text="Po right") row = layout.row() linha=row.operator("object.po_left", text="Po left") row = layout.row() linha=row.operator("object.pt_right", text="Pt right") row = layout.row() linha=row.operator("object.pt_left", text="Pt left") row = layout.row() linha=row.operator("object.ba_pt", text="Ba point") row = layout.row() linha=row.operator("object.s_pt", text="S point") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_points_head", text="SAVE!", icon="FILE_TICK") if my_enum_ana == ENUM_VALUES_ANATOMICAL.MAXILLA: row = layout.row() linha=row.operator("object.u1_tip_pt", text="U1 Tip") row = layout.row() linha=row.operator("object.u1_labgenbor_pt", text="U1 Labial Gengival Border") row = layout.row() linha=row.operator("object.u1_lingenbor_pt", text="U1 Lingual Gengival Border") row = layout.row() linha=row.operator("object.u1_root_pt", text="U1 Root") row = layout.row() linha=row.operator("object.m_u6_pt", text="M U6") row = layout.row() linha=row.operator("object.d_u6_pt", text="D U6") row = layout.row() linha=row.operator("object.u6_occlusal_pt", text="U6 Occlusal") row = layout.row() linha=row.operator("object.pns_pt", text="PNS point") row = layout.row() linha=row.operator("object.a_pt", text="A point") row = layout.row() linha=row.operator("object.ans_pt", text="ANS point") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_points_maxilla", text="SAVE!", icon="FILE_TICK") if my_enum_ana == ENUM_VALUES_ANATOMICAL.MANDIBLE: row = layout.row() linha=row.operator("object.l1_tip_pt", text="L1 Tip") row = layout.row() linha=row.operator("object.l1_labgenbor_pt", text="L1 Labial Gengival Border") row = layout.row() linha=row.operator("object.l1_lingenbor_pt", text="L1 Lingual Gengival Border") row = layout.row() linha=row.operator("object.l1_root_pt", text="L1 Root") row = layout.row() linha=row.operator("object.b_pt", text="B point") row = layout.row() linha=row.operator("object.m_l6_pt", text="M L6") row = layout.row() linha=row.operator("object.l6_occlusal_pt", text="L6 Occlusal") row = layout.row() linha=row.operator("object.d_l6_pt", text="D L6") row = layout.row() linha=row.operator("object.mid_ramus_right_pt", text="Mid Ramus right") row = layout.row() linha=row.operator("object.mid_ramus_left_pt", text="Mid Ramus left") row = layout.row() linha=row.operator("object.r_right_pt", text="R right") row = layout.row() linha=row.operator("object.r_left_pt", text="R left") row = layout.row() linha=row.operator("object.go_right_pt", text="Go right") row = layout.row() linha=row.operator("object.go_left_pt", text="Go left") row = layout.row() linha=row.operator("object.ar_right_pt", text="Ar right") row = layout.row() linha=row.operator("object.ar_left_pt", text="Ar left") row = layout.row() linha=row.operator("object.sigmoid_right_pt", text="Sigmoid right") row = layout.row() linha=row.operator("object.sigmoid_left_pt", text="Sigmoid left") row = layout.row() linha=row.operator("object.co_right_pt", text="Co right") row = layout.row() linha=row.operator("object.co_left_pt", text="Co left") row = layout.row() linha=row.operator("object.pg_pt", text="Pg point") row = layout.row() linha=row.operator("object.gn_pt", text="Gn point") row = layout.row() linha=row.operator("object.me_pt", text="Me point") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_points_mandible", text="SAVE!", icon="FILE_TICK") if my_enum_ana == ENUM_VALUES_ANATOMICAL.TEETH: row = layout.row() row.label(text="Upper Teeth:") row = layout.row() linha=row.operator("object.tooth_8_pt", text="Tooth 8 (11)") row = layout.row() linha=row.operator("object.tooth_9_pt", text="Tooth 9 (21)") row = layout.row() linha=row.operator("object.tooth_6_pt", text="Tooth 6 (13)") row = layout.row() linha=row.operator("object.tooth_11_pt", text="Tooth 11 (23)") row = layout.row() linha=row.operator("object.tooth_3_pt", text="Tooth 3 (16)") row = layout.row() linha=row.operator("object.tooth_14_pt", text="Tooth 14 (26)") row = layout.row() row = layout.row() row.label(text="Lower Teeth:") row = layout.row() linha=row.operator("object.tooth_24_pt", text="Tooth 24 (31)") row = layout.row() linha=row.operator("object.tooth_25_pt", text="Tooth 25 (41)") row = layout.row() linha=row.operator("object.tooth_22_pt", text="Tooth 22 (33)") row = layout.row() linha=row.operator("object.tooth_27_pt", text="Tooth 27 (43)") row = layout.row() linha=row.operator("object.tooth_19_pt", text="Tooth 19 (36)") row = layout.row() linha=row.operator("object.tooth_30_pt", text="Tooth 30 (46)") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_points_teeth", text="SAVE!", icon="FILE_TICK") if my_enum_ana == ENUM_VALUES_ANATOMICAL.SOFTTISSUE: row = layout.row() linha=row.operator("object.st_glabella_pt", text="ST Glabella") row = layout.row() linha=row.operator("object.st_nasion_pt", text="ST Nasion") row = layout.row() linha=row.operator("object.bridge_nose_pt", text="Bridge of Nose") row = layout.row() linha=row.operator("object.tip_nose_pt", text="Tip of Nose") row = layout.row() linha=row.operator("object.columella_pt", text="Columella") row = layout.row() linha=row.operator("object.subnasale_pt", text="Subnasale") row = layout.row() linha=row.operator("object.st_a_point_pt", text="ST A point") row = layout.row() linha=row.operator("object.upper_lip_pt", text="Upper Lip") row = layout.row() linha=row.operator("object.stomion_superius_pt", text="Stomion Superius") row = layout.row() linha=row.operator("object.stomion_inferius_pt", text="Stomion Inferius") row = layout.row() linha=row.operator("object.lower_lip_pt", text="Lower Lip") row = layout.row() linha=row.operator("object.st_b_point_pt", text="ST B point") row = layout.row() linha=row.operator("object.st_pogonion_pt", text="ST Pogonion") row = layout.row() linha=row.operator("object.st_gnathion_pt", text="ST Gnathion") row = layout.row() linha=row.operator("object.st_menton_pt", text="ST Menton") row = layout.row() linha=row.operator("object.throat_point_pt", text="Throat point") row = layout.row() linha=row.operator("object.cb_right_pt", text="CB right") row = layout.row() linha=row.operator("object.cb_left_pt", text="CB left") row = layout.row() linha=row.operator("object.or_right_pt", text="OR' right") row = layout.row() linha=row.operator("object.or_left_pt", text="OR' left") row = layout.row() linha=row.operator("object.subpupil_right_pt", text="Subpupil right") row = layout.row() linha=row.operator("object.subpupil_left_pt", text="Subpupil left") row = layout.row() linha=row.operator("object.cheekbone_right_pt", text="Cheekbone right") row = layout.row() linha=row.operator("object.cheekbone_left_pt", text="Cheekbone left") row = layout.row() linha=row.operator("object.sp_right_pt", text="SP right") row = layout.row() linha=row.operator("object.sp_left_pt", text="SP left") row = layout.row() linha=row.operator("object.ab_right_pt", text="AB right") row = layout.row() linha=row.operator("object.ab_left_pt", text="AB left") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_points_soft", text="SAVE!", icon="FILE_TICK") row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") class ENUM_VALUES_CEFALOMETRIA: USP = 'USP' ARNETT = 'ARNETT' class ORTOG_PT_Cefalometria(bpy.types.Panel): bl_label = "Cephalometry" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout MaxOcPlane = "NONE" context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.prop(scn, "my_enum_cefalometria") my_enum_cefalometria = scn.my_enum_cefalometria if my_enum_cefalometria == ENUM_VALUES_CEFALOMETRIA.USP: # Plano oclusal maxila row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() row.operator("object.calcula_tudo_usp", text="Calculate!!!", icon="PREFERENCES") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.operator("object.tooth_8_pt", text="Tooth 8 (11)") linha=row.operator("object.tooth_9_pt", text="Tooth 9 (21)") row = col.row() linha=row.operator("object.tooth_3_pt", text="Tooth 3 (16)") linha=row.operator("object.tooth_14_pt", text="Tooth 14 (26)") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "plano_oclusal_maxila_classico") row = col.row() row.alignment = 'CENTER' row.label(text="4º-(8º)-12º") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.s_pt", text="S point") linha=row.operator("object.n_pt", text="N point") linha=row.operator("object.a_pt", text="A point") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "angulo_sna") row = col.row() row.alignment = 'CENTER' row.label(text="> 82º Prognathic Maxilla (Class 2)") row = col.row() row.alignment = 'CENTER' row.label(text="< 82º Retrognathic Maxilla (Class 3)") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.s_pt", text="S point") linha=row.operator("object.n_pt", text="N point") linha=row.operator("object.b_pt", text="B point") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "angulo_snb") row = col.row() row.alignment = 'CENTER' row.label(text="> 80º Prognathic Mandible") row = col.row() row.alignment = 'CENTER' row.label(text="< 80º Retrognathic Mandible") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.a_pt", text="A point") linha=row.operator("object.n_pt", text="N point") linha=row.operator("object.b_pt", text="B point") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "angulo_anb") row = col.row() row.alignment = 'CENTER' row.label(text="0º-(2º)-4º") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.s_pt", text="S point") linha=row.operator("object.n_pt", text="N point") linha=row.operator("object.gn_pt", text="Gn point") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "angulo_sngn") row = col.row() row.alignment = 'CENTER' row.label(text="65º-(67º)-69º") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.go_right_pt", text="Go right") linha=row.operator("object.go_left_pt", text="Go left") linha=row.operator("object.me_pt", text="Me point") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "plano_mandibula_usp") row = col.row() row.alignment = 'CENTER' row.label(text="28º-(32º)-36º") row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() linha=row.operator("object.s_pt", text="S point") linha=row.operator("object.n_pt", text="N point") row = col.row() linha=row.operator("object.go_right_pt", text="Go right") linha=row.operator("object.go_left_pt", text="Go left") linha=row.operator("object.gn_pt", text="Gn point") row = col.row() row.scale_y=1.0 row.alignment = 'CENTER' row.prop(context.scene, "angulo_sngogn") row = col.row() row.alignment = 'CENTER' row.label(text="28º-(32º)-36º") if my_enum_cefalometria == ENUM_VALUES_CEFALOMETRIA.ARNETT: row = layout.row() linha=row.operator("object.calcula_tudo_cefalo", text="Calculate All!!!", icon="PREFERENCES") row = layout.row() row = layout.row() row = layout.row() row.label(text="Angles:") # Plano oclusal maxila row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "plano_oclusal_maxila") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: 90º-120º Men: 85º-105º") # Ângulo nasolabial row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "angulo_nasolabial") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: 97.7º - 110.3º Men: 98.7º - 114.1º") # Calculado # Ângulo Gn', Sn, Pog' row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "angulo_GbSnPog") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: 90º-120º Men: 85º-105º") row = layout.row() row.label(text="Distances:") # Glabella - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_glabella_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Rima Orbital - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_rima_or_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Mole malar - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_cheekbone_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Subpupilar - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_subpupil_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Proj. Nasal - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_proj_nasal_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Base Nasal - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_base_nasal_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # A' - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_a_mole_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Upper Lip - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_labio_superior_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # L1 - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_l1_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # U1 - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_u1_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Lábio inferior - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_labio_inferior_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # B' - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_b_mole_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Pog' - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_pog_mole_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") # Pescoço-Garganta - LVV row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.0 row.alignment = 'RIGHT' row.prop(context.scene, "dist_pescoco_garganta_tvl") row = col.row() row.alignment = 'RIGHT' row.label(text="Women: -1 to 3 Men: -1 to 3") bpy.types.Scene.angulo_sngogn = bpy.props.StringProperty \ ( name = "SNGoGn Angle", description = "SNGoGn Angle", default = "NONE" ) bpy.types.Scene.angulo_sna = bpy.props.StringProperty \ ( name = "SNA Angle", description = "SNA Angle", default = str("NONE"), ) bpy.types.Scene.angulo_snb = bpy.props.StringProperty \ ( name = "SNB Angle", description = "SNB Angle", default = str("NONE") ) bpy.types.Scene.angulo_anb = bpy.props.StringProperty \ ( name = "ANB Angle", description = "ANB Angle", default = "NONE" ) print("Falta algum ponto anatômico (ANB)!") bpy.types.Scene.angulo_sngn = bpy.props.StringProperty \ ( name = "SNGn Angle", description = "SNGn Angle", default = "NONE" ) bpy.types.Scene.dist_pescoco_garganta_tvl = bpy.props.StringProperty \ ( name = "Throat point - TVL", description = "Throat point - TVL", default = "NONE" ) bpy.types.Scene.dist_pog_mole_tvl = bpy.props.StringProperty \ ( name = "ST Pogonion - TVL", description = "ST Pogonion - TVL", default = "NONE" ) bpy.types.Scene.dist_b_mole_tvl = bpy.props.StringProperty \ ( name = "ST B point - TVL", description = "ST B point - TVL", default = "NONE" ) bpy.types.Scene.dist_labio_inferior_tvl = bpy.props.StringProperty \ ( name = "Lower Lip - TVL", description = "Lower Lip - TVL", default = "NONE" ) bpy.types.Scene.dist_u1_tvl = bpy.props.StringProperty \ ( name = "U1 Tip - TVL", description = "U1 Tip - TVL", default = "NONE" ) bpy.types.Scene.dist_l1_tvl = bpy.props.StringProperty \ ( name = "L1 Tip - TVL", description = "L1 Tip - TVL", default = "NONE" ) bpy.types.Scene.dist_labio_superior_tvl = bpy.props.StringProperty \ ( name = "Upper Lip - TVL", description = "Upper Lip - TVL", default = "NONE" ) bpy.types.Scene.dist_a_mole_tvl = bpy.props.StringProperty \ ( name = "A' - TVL", description = "A' - TVL", default = "NONE" ) bpy.types.Scene.dist_base_nasal_tvl = bpy.props.StringProperty \ ( name = "AB - TVL", description = "AB - TVL", default = "NONE" ) bpy.types.Scene.dist_proj_nasal_tvl = bpy.props.StringProperty \ ( name = "Tip of Nose - TVL", description = "Tip of Nose - TVL", default = "NONE" ) bpy.types.Scene.dist_subpupil_tvl = bpy.props.StringProperty \ ( name = "Subpupil - TVL", description = "Subpupil - TVL", default = "NONE" ) bpy.types.Scene.dist_cheekbone_tvl = bpy.props.StringProperty \ ( name = "Cheekbone - TVL", description = "Cheekbone - TVL", default = "NONE" ) bpy.types.Scene.dist_rima_or_tvl = bpy.props.StringProperty \ ( name = "OR' - TVL", description = "OR' - TVL", default = "NONE" ) bpy.types.Scene.dist_glabella_tvl = bpy.props.StringProperty \ ( name = "Glabella - TVL", description = "Glabella - TVL", default = "NONE" ) bpy.types.Scene.plano_oclusal_maxila = bpy.props.StringProperty \ ( name = "Maxillary Occlusal Plane", description = "Maxillary Occlusal Plane", default = "NONE" ) bpy.types.Scene.angulo_nasolabial = bpy.props.StringProperty \ ( name = "Nasolabial Angle", description = "Nasolabial Angle", default = "NONE" ) bpy.types.Scene.angulo_GbSnPog = bpy.props.StringProperty \ ( name = "Gb', Sn, Pog' Angle", description = "Gb', Sn, Pog' Angle", default = str("NONE") ) class ENUM_VALUES_OSTEOTOMY: AUTO = 'Auto' MANUAL = 'Manual' BOOLEAN = 'Boolean' DRAW = 'Draw' class ORTOG_PT_Osteotomia(bpy.types.Panel): bl_label = "Osteotomy" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.prop(scn, "my_enum_osteotomy") my_enum_ct = scn.my_enum_osteotomy if my_enum_ct == ENUM_VALUES_OSTEOTOMY.AUTO: row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() linha=row.operator("object.orbital_right_pt", text="Orbital right") linha=row.operator("object.orbital_left_pt", text="Orbital left") linha=row.operator("object.a_pt", text="A point") row = layout.row() linha=row.operator("object.tooth_30_pt", text="Tooth 30 (46)") linha=row.operator("object.go_right_pt", text="Go right") linha=row.operator("object.tooth_19_pt", text="Tooth 19 (36)") row = layout.row() linha=row.operator("object.go_left_pt", text="Go left") linha=row.operator("object.b_pt", text="B point") linha=row.operator("object.me_pt", text="Me point") row = layout.row() row = layout.row() circle=row.operator("object.adiciona_planos_corte_auto", text="Create Cut Planes!", icon="AXIS_TOP") row = layout.row() row.label(text="Pivot:") obj = context.active_object tool_settings = context.tool_settings object_mode = 'OBJECT' if obj is None else obj.mode if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_PAINT'} or has_pose_mode: layout.prop_with_popover( tool_settings, "transform_pivot_point", text="", icon_only=False, panel="VIEW3D_PT_pivot_point", ) row = layout.row() row = layout.row() row.label(text="Boolean:") row = layout.row() circle=row.operator("object.booleana_union_multipla", text="Join All (Union)", icon="GROUP") row = layout.row() circle=row.operator("object.booleana_osteo_geral", text="Cut Boolean", icon="MOD_BOOLEAN") if my_enum_ct == ENUM_VALUES_OSTEOTOMY.MANUAL: row = layout.row() circle=row.operator("mesh.add_mento", text="Chin Plane", icon="TRIA_DOWN") circle.location=(0,-35,-81) row = layout.row() circle=row.operator("mesh.add_ramo", text="Left Ramus Plane", icon="TRIA_RIGHT") circle.location=(36, -4, -45) row = layout.row() circle=row.operator("mesh.add_ramo", text="Right Ramus Plane", icon="TRIA_LEFT") circle.location=(-36, -4, -45) row = layout.row() circle=row.operator("mesh.add_maxila", text="Maxilla Plane", icon="TRIA_UP") circle.location=(0, -45, -31) row = layout.row() row = layout.row() row.label(text="Boolean:") row = layout.row() circle=row.operator("object.booleana_union_multipla", text="Join All (Union)", icon="GROUP") row = layout.row() circle=row.operator("object.booleana_osteo_geral", text="Cut Boolean", icon="MOD_BOOLEAN") if my_enum_ct == ENUM_VALUES_OSTEOTOMY.BOOLEAN: row = layout.row() # row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row.operator("object.linha_corte_fora_a_fora", icon='LINE_DATA', text="Draw Line") row = layout.row() row = layout.row() circle=row.operator("object.desenha_booleana_dentro", text="Subtract IN", icon="LIGHTPROBE_CUBEMAP") row = layout.row() circle=row.operator("object.desenha_booleana_fora", text="Subtract OUT", icon="MESH_CUBE") if my_enum_ct == ENUM_VALUES_OSTEOTOMY.DRAW: row = layout.row() row.operator("object.linha_corte", icon='LINE_DATA', text="Draw Surface Line") row = layout.row() circle=row.operator("object.desenha_linha_vertex", text="View Cut Line", icon="RESTRICT_VIEW_OFF") row = layout.row() circle=row.operator("object.desenha_linha_vertex_fin", text="Cut Visible Line", icon="SCULPTMODE_HLT") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_osteotomy", text="SAVE!", icon="FILE_TICK") class ENUM_VALUES_DYNAMIC: DEFAULT = 'Default' NOSE = 'Nose' EXPERIMENTAL = 'Experimental' class ORTOG_PT_ArmatureDynamic(bpy.types.Panel): bl_label = "Dynamic" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout context = bpy.context obj = context.object scn = context.scene row = layout.row() row.prop(scn, "my_enum_dynamic") my_enum_dynamic = scn.my_enum_dynamic if my_enum_dynamic == ENUM_VALUES_DYNAMIC.DEFAULT: row = layout.row() row.label(text="Configure Armature (Classic):") row = layout.row() row.operator("object.conf_osteo_auto", text="Setup Osteotomy Auto", icon="FILE_TICK") row = layout.row() row.label(text="Soft Tissue:") row = layout.row() circle=row.operator("object.configura_dinamica_mole", text="Setup Soft Tissue Dynamics", icon="STYLUS_PRESSURE") row = layout.row() circle=row.operator("view3d.clip_border", text="Clipping Border", icon="UV_FACESEL") if my_enum_dynamic == ENUM_VALUES_DYNAMIC.NOSE: row = layout.row() row.operator("object.conf_osteo_auto", text="Setup Osteotomy Auto", icon="FILE_TICK") row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row = layout.row() row.label(text="Anatomical Points:") row = layout.row() linha=row.operator("object.trichion_pt", text="Trichion") row = layout.row() linha=row.operator("object.radix_pt", text="Radix") row = layout.row() linha=row.operator("object.tip_nose_pt", text="Tip of Nose") row = layout.row() linha=row.operator("object.alar_groove_right_pt", text="Alar Groove right") row = layout.row() linha=row.operator("object.alar_groove_left_pt", text="Alar Groove left") row = layout.row() linha=row.operator("object.submental_pt", text="Submental") row = layout.row() row = layout.row() row.label(text="Soft Tissue:") row = layout.row() circle=row.operator("object.configura_dinamica_mole", text="Setup Soft Tissue Dynamics", icon="STYLUS_PRESSURE") row = layout.row() circle=row.operator("view3d.clip_border", text="Clipping Border", icon="UV_FACESEL") if my_enum_dynamic == ENUM_VALUES_DYNAMIC.EXPERIMENTAL: row = layout.row() row.label(text=" Auto Osteo+Soft Setup (Experimental):") row = layout.row() row.operator("object.nome_face_malha", text="Set Face and Hide", icon="USER") row = layout.row() row.operator("object.conf_osteo_mole_auto", text="Setup Auto!", icon="BONE_DATA") row = layout.row() row = layout.row() row.label(text="Parent Points:") row = layout.row() circle=row.operator("object.parenteia_emp", text="Parent Points", icon="LINKED") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_dynamic", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_CinematicaPanel(bpy.types.Panel): bl_label = "Kinematic" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout obj = context.object row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() row.label(text="Pivot Rotation:") obj = context.active_object tool_settings = context.tool_settings object_mode = 'OBJECT' if obj is None else obj.mode if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_PAINT'} or has_pose_mode: layout.prop_with_popover( tool_settings, "transform_pivot_point", text="", icon_only=False, panel="VIEW3D_PT_pivot_point", ) row = layout.row() row.label(text="Reference Lines:") row = layout.row() linha=row.operator("mesh.add_linhabase", text="Vertical Center Line", icon="SORT_DESC") linha.location=(0,-200,0) row = layout.row() linha=row.operator("mesh.add_linhabase", text="Horizontal Center Line", icon="FORWARD") linha.location=(0,-200,0) linha.rotation=(0,1.5708,0) row = layout.row() linha=row.operator("mesh.add_linhabase", text="Horizontal Side Line", icon="FORWARD") linha.location=(200,30,0) linha.rotation=(1.5708,0,0) row = layout.row() row = layout.row() row.label(text="Upper Teeth:") row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() row = layout.row() linha=row.operator("object.tooth_8_pt", text="Tooth 8 (11)") linha=row.operator("object.tooth_9_pt", text="Tooth 9 (21)") row = layout.row() linha=row.operator("object.tooth_6_pt", text="Tooth 6 (13)") linha=row.operator("object.tooth_11_pt", text="Tooth 11 (23)") row = layout.row() linha=row.operator("object.tooth_3_pt", text="Tooth 3 (16)") linha=row.operator("object.tooth_14_pt", text="Tooth 14 (26)") row = layout.row() row = layout.row() row.label(text="Vertical Measurements:") row = layout.row() row.operator("object.medverhor_dentes", text="Create Vertical Measurements", icon="DRIVER_DISTANCE") row = layout.row() row.operator("measureit.runopengl", text="Show/Hide Measurements", icon="GHOST_ENABLED") row = layout.row() row = layout.row() row.operator("object.apaga_pontos_objetos", text="Delete Measure", icon="CANCEL") row = layout.row() row = layout.row() row.label(text="Parent Points:") row = layout.row() circle=row.operator("object.parenteia_emp", text="Parent Points", icon="LINKED") # row = layout.row() # row.operator("object.transforms_to_deltas", text="PUT Loc/Rot/Scale TO ZERO", icon="EMPTY_AXIS").mode='ALL' # bpy.ops.object.transforms_to_deltas(mode='ALL') try: cursor = context.active_object layout.column().prop(cursor, "location", text="Location") rotation_mode = cursor.rotation_mode if rotation_mode == 'QUATERNION': layout.column().prop(cursor, "rotation_quaternion", text="Rotation") elif rotation_mode == 'AXIS_ANGLE': layout.column().prop(cursor, "rotation_axis_angle", text="Rotation") else: layout.column().prop(cursor, "rotation_euler", text="Rotation") layout.prop(cursor, "rotation_mode", text="") except: print("Selectione objeto!") #bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR' #bpy.context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT' row = layout.row() row.label(text="Custom Anatomical Point:") context = bpy.context obj = context.object scn = context.scene row = layout.row() row.label(text="Select an object before!") row = layout.row() if context.window_manager.measureit_run_opengl is False: icon = 'PLAY' txt = 'Show' else: icon = "PAUSE" txt = 'Hide' row.operator("measureit.runopengl", text=txt, icon=icon) row.prop(scn, "measureit_gl_ghost", text="", icon='GHOST_ENABLED') row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" col = self.layout.column(align = True) col.alignment = 'CENTER' col.prop(context.scene, "nome_ponto_customizado") row = layout.row() row.operator("object.cria_ponto_medida", text="Create Custom Point!", icon="SHADING_RENDERED") row = layout.row() row.label(text="Controllers:") row = layout.row() row.operator("screen.frame_jump", text="Start", icon="TRIA_LEFT_BAR").end=False row.operator("screen.animation_play", text="", icon="PLAY_REVERSE").reverse=True row.operator("anim.ortog_loc_rot", text="", icon="VIEW_CAMERA") row.operator("screen.animation_play", text="", icon="PLAY") row.operator("screen.frame_jump", text="End", icon="TRIA_RIGHT_BAR").end=True row = layout.row() row.label(text="Align with Models:") row = layout.row() linha=row.operator("object.prepara_mandibula_cm", text="Prepare Mandible", icon="MESH_DATA") row = layout.row() row.operator("import_mesh.stl", text="Import STL", icon="IMPORT") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() linha=row.operator("object.emp1a", text="Point 1a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp1b", text="Point 1b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() linha=row.operator("object.emp2a", text="Point 2a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp2b", text="Point 2b - Align", icon="SORTBYEXT") row = layout.row() row = layout.row() linha=row.operator("object.emp3a", text="Point 3a - Origin", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.emp3b", text="Point 3b - Align", icon="SORTBYEXT") row = layout.row() linha=row.operator("object.alinha_tres_pontos", text="ALIGN!", icon="MESH_DATA") row = layout.row() linha=row.operator("object.force_icp", text="Force ICP Align (Slow)", icon="TRACKING_REFINE_FORWARDS") row = layout.row() row = layout.row() linha=row.operator("object.finaliza_mandibula_cm", text="Finish Mandible", icon="MESH_DATA") row = layout.row() row.label(text="Mandible Collision:") row = layout.row() row.operator("object.prepara_maxila_mandibula", text="Prepares Maxilla & Mandible", icon="SHADERFX") row = layout.row() row = layout.row() linha=row.operator("object.colisao_arcos_inverso", text="Solve Collision Inverted", icon="STYLUS_PRESSURE") row = layout.row() linha=row.operator("object.aplica_anima_cor", text="Contact Color", icon="COLORSET_01_VEC") row = layout.row() row = layout.row() linha=row.operator("object.finaliza_colisao_max_mand", text="Apply!!!", icon="FREEZE") row = layout.row() row.label(text="Piggyback:") row = layout.row() row.label(text="1) Select son(s)") row = layout.row() row.label(text="2) Select father") row = layout.row() row.operator("object.parenteia_objetos", text="MAKE PARENT", icon="RESTRICT_VIEW_OFF") row = layout.row() row = layout.row() row.operator("object.desparenteia_objetos", text="Clear Parent", icon="UNLINKED") row = layout.row() row.label(text="Capturing:") row = layout.row() row.operator("object.gera_deslocamento_todos", text="Generate Data Action", icon="FULLSCREEN_ENTER") row = layout.row() row.label(text="Spreadsheet:") row = layout.row() row.operator("object.gera_relatorio", text="GENERATE REPORT", icon="SHORTDISPLAY") row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_kinematic", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_FechaLabios(bpy.types.Panel): bl_label = "Close Lips" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): layout = self.layout # row = layout.row() # row.label(text="Close Lips:") row = layout.row() row.operator("object.cria_shape_keys", text="Create Shape Keys", icon="MOD_SIMPLEDEFORM") row = layout.row() ob = context.object key = ob.data.shape_keys kb = ob.active_shape_key enable_edit = ob.mode != 'EDIT' enable_edit_value = False if ob.show_only_shape_key is False: if enable_edit or (ob.type == 'MESH' and ob.use_shape_key_edit_mode): enable_edit_value = True if key.use_relative: if ob.active_shape_key_index != 0: layout.use_property_split = True row = layout.row() row.active = enable_edit_value row.prop(kb, "value") row = layout.row() linha=row.operator("object.escultura_grab", text="Grab", icon="BRUSH_GRAB") row = layout.row() linha=row.operator("object.escultura_smooth", text="Smooth", icon="BRUSH_SMOOTH") row = layout.row() linha=row.operator("object.escultura_mask", text="Mask", icon="BRUSH_MASK") row = layout.row() linha=row.operator("object.mode_set", text="OK! (Object Mode)", icon="META_CUBE").mode='OBJECT' class ENUM_VALUES_ARCHSCOLLISION: DEFAULT = 'Default' INVERTED = 'Inverted' class ORTOG_PT_GuideCreation(bpy.types.Panel): bl_label = "Guide and Splint Creation" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_options = {'DEFAULT_CLOSED'} bl_category = "Ortog" def draw(self, context): context = bpy.context scn = context.scene layout = self.layout row = layout.row() row.label(text="Free Draw Solid:") row = layout.row() row.operator("object.linha_corte", icon='LINE_DATA', text="Draw Surface Line") row = layout.row() row.operator("object.desenha_guia", text="Create Solid by Line", icon="META_ELLIPSOID") row = layout.row() row.label(text="Draw Line Tube:") row = layout.row() row.operator("wm.modal_cria_pontos", icon='CURVE_DATA', text="Create Points") # row = layout.row() # row.operator("mesh.add_linha_pontos", icon='LINE_DATA', text="Create Object") row = layout.row() row.operator("mesh.add_curva_bezier", icon='MESH_CYLINDER', text="Create Bezier Volume") row = layout.row() row.label(text="Boolean:") row = layout.row() circle=row.operator("object.booleana_osteo_geral", text="Difference", icon="MOD_BOOLEAN") row = layout.row() circle=row.operator("object.booleana_osteo_union", text="Union", icon="MOD_CAST") row = layout.row() circle=row.operator("object.booleana_osteo_inter", text="Intersect", icon="MOD_MASK") row = layout.row() row = layout.row() circle=row.operator("object.booleana_union_multipla", text="MULTIPLE UNION", icon="STICKY_UVS_LOC") row = layout.row() row = layout.row() row.label(text="Boolean Segmentation:") row = layout.row() # row.operator("gpencil.annotate", icon='LINE_DATA', text="Draw Line").mode = 'DRAW_POLY' row.operator("object.linha_corte_fora_a_fora", icon='LINE_DATA', text="Draw Line") row = layout.row() row = layout.row() circle=row.operator("object.desenha_booleana_dentro", text="Subtract IN", icon="LIGHTPROBE_CUBEMAP") row = layout.row() circle=row.operator("object.desenha_booleana_fora", text="Subtract OUT", icon="MESH_CUBE") row = layout.row() row.label(text="Sculpture:") row = layout.row() linha=row.operator("object.forensic_escultura_grab", text="Grab", icon="BRUSH_GRAB") row = layout.row() linha=row.operator("object.forensic_escultura_smooth", text="Smooth", icon="BRUSH_SMOOTH") row = layout.row() linha=row.operator("object.forensic_escultura_clay_strips", text="Clay Strips", icon="BRUSH_CLAY_STRIPS") row = layout.row() linha=row.operator("object.mode_set", text="OK! (Object Mode)", icon="META_CUBE").mode='OBJECT' row = layout.row() row.label(text="Teeth Points:") row = layout.row() circle=row.operator("object.oculta_pontos_anatomicos", text="Hide Anatomical Points", icon="GHOST_DISABLED") row = layout.row() circle=row.operator("object.mostra_pontos_anatomicos", text="Show Anatomical Points", icon="GHOST_ENABLED") row = layout.row() row = layout.row() linha=row.operator("object.pontos_oculta_nomes", text="Hide Names", icon="GHOST_DISABLED") row = layout.row() linha=row.operator("object.pontos_mostra_nomes", text="Show Names", icon="GHOST_ENABLED") row = layout.row() row.label(text="Mode:") row = layout.row() linha=row.operator("wm.tool_set_by_id", text="Cursor", icon="PIVOT_CURSOR").name="builtin.cursor" linha=row.operator("wm.tool_set_by_id", text="Select", icon="RESTRICT_SELECT_OFF").name="builtin.select_box" row = layout.row() linha=row.operator("object.tooth_8_pt", text="Tooth 8 (11)") linha=row.operator("object.tooth_9_pt", text="Tooth 9 (21)") row = layout.row() linha=row.operator("object.tooth_6_pt", text="Tooth 6 (13)") linha=row.operator("object.tooth_11_pt", text="Tooth 11 (23)") row = layout.row() linha=row.operator("object.tooth_3_pt", text="Tooth 3 (16)") linha=row.operator("object.tooth_14_pt", text="Tooth 14 (26)") row = layout.row() row = layout.row() row = layout.row() linha=row.operator("object.tooth_24_pt", text="Tooth 24 (31)") linha=row.operator("object.tooth_25_pt", text="Tooth 25 (41)") row = layout.row() linha=row.operator("object.tooth_22_pt", text="Tooth 22 (33)") linha=row.operator("object.tooth_27_pt", text="Tooth 27 (43)") row = layout.row() linha=row.operator("object.tooth_19_pt", text="Tooth 19 (36)") linha=row.operator("object.tooth_30_pt", text="Tooth 30 (46)") row = layout.row() linha=row.operator("object.head_of_condyle_pt", text="Condyle Rotation Point") row = layout.row() row = layout.row() row = layout.row() circle=row.operator("object.parenteia_emp", text="Parent Points", icon="LINKED") row = layout.row() row.label(text="Splint:") row = layout.row() row = layout.row() row.operator("object.splint_maxila_origi_mand_final", text="Maxilla-Origin Mandible-Final", icon="GROUP_BONE") row = layout.row() row.operator("object.splint_mand_origi_maxila_final", text="Mandible-Origin Maxilla-Final", icon="GROUP_BONE") row = layout.row() row = layout.row() row.operator("screen.frame_jump", text="Start", icon="TRIA_LEFT_BAR").end=False row.operator("screen.animation_play", text="", icon="PLAY_REVERSE").reverse=True row.operator("anim.ortog_loc_rot", text="", icon="VIEW_CAMERA") row.operator("screen.animation_play", text="", icon="PLAY") row.operator("screen.frame_jump", text="End", icon="TRIA_RIGHT_BAR").end=True row = layout.row() row.operator("object.cria_splint", text="Create Splint", icon="OUTLINER_OB_CURVE") # row = layout.row() # row.operator("object.duplica_max_mand", text="Prepares Maxilla & Mandible", icon="SHADERFX") row = layout.row() circle=row.operator("object.boolean_splint", text="Boolean Difference", icon="MOD_BOOLEAN") row = layout.row() row.operator("object.visualiza_max_mand", text="View Maxilla & Mandible", icon="VISIBLE_IPO_ON") # ---------------------- row = layout.row() row = layout.row() row = layout.row() row.label(text="Collision Test:") row = layout.row() row.prop(scn, "my_enum_archscollision") my_enum_ct = scn.my_enum_archscollision if my_enum_ct == ENUM_VALUES_ARCHSCOLLISION.DEFAULT: row = layout.row() linha=row.operator("object.colisao_arcos", text="Solve Collision Default", icon="STYLUS_PRESSURE") row = layout.row() row = layout.row() linha=row.operator("object.aplica_anima_cor", text="Contact Color", icon="COLORSET_01_VEC") row = layout.row() row.label(text="Press ESC to enable Apply!") row = layout.row() linha=row.operator("object.trava_arco", text="Apply!", icon="FREEZE") if my_enum_ct == ENUM_VALUES_ARCHSCOLLISION.INVERTED: row = layout.row() linha=row.operator("object.colisao_arcos_inverso", text="Solve Collision Inverted", icon="STYLUS_PRESSURE") row = layout.row() row = layout.row() linha=row.operator("object.aplica_anima_cor", text="Contact Color", icon="COLORSET_01_VEC") row = layout.row() row.label(text="Press ESC to enable Apply!") row = layout.row() linha=row.operator("object.trava_arco", text="Apply!", icon="FREEZE") # ---------------------- row = layout.row() row = layout.row() row.label(text="Finishing") row = layout.row() row.operator("object.prepara_impressao_3d", text="Prepares 3D Printing", icon="META_CUBE") row = layout.row() row.operator("export_mesh.stl", text="Export STL", icon="TRACKING_REFINE_FORWARDS").use_selection=True#.use_mesh_modifiers=True row = layout.row() row = layout.row() box = layout.box() col = box.column(align=True) row = col.row() row.scale_y=1.5 row.alignment = 'CENTER' row.operator("object.gera_dir_nome_paciente_guide", text="SAVE!", icon="FILE_TICK") class ORTOG_PT_ImportTomoImg(bpy.types.Panel): bl_label = "Importing & Editing CT-Scan" bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' bl_category = "Ortog" # bl_category = "Image" def draw(self, context): layout = self.layout # layout.use_property_split = True # row = layout.row() # row.label(text="Free Draw Solid:") row = layout.row() row.operator("object.importa_img_tomo", text="Import CT-Scan IMG Slices", icon="IMAGE_DATA") row = layout.row(align = True) row.prop(context.scene, "IMGPathSeq") row = layout.row(align = True) row.prop(context.scene, "SliceThickness") row = layout.row(align = True) row.prop(context.scene, "PixelSpacingX") row = layout.row(align = True) row.prop(context.scene, "PixelSpacingY") row = layout.row(align = True) row.prop(context.scene, "IMGDimX") row = layout.row(align = True) row.prop(context.scene, "IMGDimY") row = layout.row() row = layout.row() row.operator("image.save_sequence", text="Save Sequence", icon="EXPORT") row = layout.row() row.operator("object.exporta_img_tomo", text="Export DICOM Slices", icon="EXPORT") class ORTOG_PT_Render(bpy.types.Panel): bl_label = "Render" bl_region_type = 'UI' bl_space_type = 'VIEW_3D' bl_category = "Ortog" def draw(self, context): layout = self.layout row = layout.row() linha=row.operator("object.forensic_importa_luzes", text="ILLUMINATE!", icon="LIGHT_DATA") def register(): bpy.utils.register_class(EMP1a) bpy.utils.register_class(EMP2a) bpy.utils.register_class(EMP3a) bpy.utils.register_class(EMP1b) bpy.utils.register_class(EMP2b) bpy.utils.register_class(EMP3b) bpy.utils.register_class(Orbital_right_pt) bpy.utils.register_class(Orbital_left_pt) bpy.utils.register_class(N_pt) bpy.utils.register_class(Po_right_pt) bpy.utils.register_class(Po_left_pt) bpy.utils.register_class(Pt_right_pt) bpy.utils.register_class(Pt_left_pt) bpy.utils.register_class(Ba_pt) bpy.utils.register_class(S_pt) bpy.utils.register_class(U1_Tip_pt) bpy.utils.register_class(U1_LabGenBor_pt) bpy.utils.register_class(U1_LinGenBor_pt) bpy.utils.register_class(M_U6_pt) bpy.utils.register_class(D_U6_pt) bpy.utils.register_class(U6_Occlusal_pt) bpy.utils.register_class(PNS_pt) bpy.utils.register_class(A_pt) bpy.utils.register_class(ANS_pt) bpy.utils.register_class(U1_Root_pt) bpy.utils.register_class(L1_Tip_pt) bpy.utils.register_class(L1_Root_pt) bpy.utils.register_class(L1_LabGenBor_pt) bpy.utils.register_class(L1_LinGenBor_pt) bpy.utils.register_class(B_pt) bpy.utils.register_class(M_L6_pt) bpy.utils.register_class(L6_Occlusal_pt) bpy.utils.register_class(ORTOG_UI_Local) bpy.utils.register_class(D_L6_pt) bpy.utils.register_class(MidRamusRight_pt) bpy.utils.register_class(MidRamusLeft_pt) bpy.utils.register_class(R_right_pt) bpy.utils.register_class(R_left_pt) bpy.utils.register_class(Go_right_pt) bpy.utils.register_class(Go_left_pt) bpy.utils.register_class(Ar_right_pt) bpy.utils.register_class(Ar_left_pt) bpy.utils.register_class(Sigmoid_right_pt) bpy.utils.register_class(Sigmoid_left_pt) bpy.utils.register_class(Co_right_pt) bpy.utils.register_class(Co_left_pt) bpy.utils.register_class(Pg_pt) bpy.utils.register_class(Gn_pt) bpy.utils.register_class(Me_pt) bpy.types.Scene.my_tool = PointerProperty(type=ORTOG_UI_Local) bpy.utils.register_class(ORTOG_PT_AtualizaAddonSec) bpy.utils.register_class(ORTOG_PT_NomePaciente) bpy.types.Scene.nome_paciente = bpy.props.StringProperty \ ( name = "Name", description = "Patient's name", default = "" ) bpy.types.Scene.sobrenome_paciente = bpy.props.StringProperty \ ( name = "Surname", description = "Patient's surname", default = "" ) bpy.utils.register_class(AtualizaScript) bpy.utils.register_class(AreasInfluencia) bpy.utils.register_class(CriaAreasDeformacao) bpy.utils.register_class(ConfiguraDinamicaMole) bpy.utils.register_class(ConfiguraMento) bpy.utils.register_class(ConfiguraCorpoMand) bpy.utils.register_class(ConfiguraRamoEsq) bpy.utils.register_class(ConfiguraRamoDir) bpy.utils.register_class(ConfiguraMaxila) bpy.utils.register_class(ConfiguraCabeca) bpy.utils.register_class(ImportaArmature) bpy.utils.register_class(ConfOsteotomiaAuto) bpy.utils.register_class(BooleanaOsteoGeral) bpy.utils.register_class(CriaMaxila) bpy.utils.register_class(CriaRamo) bpy.utils.register_class(CriaMento) bpy.utils.register_class(DesenhaLinhaVertex) bpy.utils.register_class(DesenhaLinhaVertexFin) bpy.utils.register_class(BooleanaOsteoClass) bpy.utils.register_class(DesenhaLinhaCorte) bpy.utils.register_class(LinhaCorte) bpy.utils.register_class(SegmentaDesenho) bpy.utils.register_class(BooleanaMand) bpy.utils.register_class(MantemPintado) bpy.utils.register_class(ApagaPintado) bpy.utils.register_class(Weight0) bpy.utils.register_class(Weight1) bpy.utils.register_class(SegmentaLinked) bpy.utils.register_class(LinhaBase) bpy.utils.register_class(ORTOG_PT_CTScanSelect) # bpy.utils.register_class(ORTOG_PT_CTScanOrgFIX) bpy.utils.register_class(CorrigeDicom) bpy.utils.register_class(AjustaTomo) bpy.types.Scene.my_enum_ct = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_CTSCAN.MANUAL, "MANUAL", "Manual CT-Scan Reconstruction"), (ENUM_VALUES_CTSCAN.DEFAULT, "DEFAULT", "Default CT-Scan Reconstruction"), (ENUM_VALUES_CTSCAN.VOXEL, "VOXEL", "Voxel Data CT-Scan Reconstruction"), (ENUM_VALUES_CTSCAN.VOXEL_FULL, "VOXEL-FULL!", "Voxel Axial + Coronal + Sagital"), (ENUM_VALUES_CTSCAN.AUTO, "AUTOMATIC", "Automatic CT-Scan Reconstruction"), (ENUM_VALUES_CTSCAN.CUSTOM, "CUSTOM", "Customized CT-Scan Reconstruction"), (ENUM_VALUES_CTSCAN.AUTOEXP, "AUTO EXP.!!!", "Manual CT-Scan Reconstruction")],) bpy.utils.register_class(GeraModelosTomo) # bpy.utils.register_class(ORTOG_PT_CTScanFerrImg) # bpy.utils.register_class(ORTOG_PT_CTScanRec) bpy.types.Scene.interesse_geral = bpy.props.StringProperty \ ( name = "Reconst. Factor", description = "Reconstruction Factor", default = "NONE" ) bpy.types.Scene.fator_simplificacao = bpy.props.StringProperty \ ( name = "Decimate Factor", description = "Decimate Factor", default = "0.90" ) bpy.types.Scene.nome_objeto = bpy.props.StringProperty \ ( name = "Object Name", description = "Object Name", default = "CT-Scan Reconstructed" ) bpy.types.Scene.interesse_ossos = bpy.props.StringProperty \ ( name = "Bone Factor", description = "Fatos interesse ossos", default = "200" ) bpy.types.Scene.interesse_mole = bpy.props.StringProperty \ ( name = "Soft Factor", description = "Fatos interesse mole", default = "-300" ) bpy.types.Scene.interesse_dentes = bpy.props.StringProperty \ ( name = "Teeth Factor", description = "Fatos interesse dentes", default = "1430" ) bpy.utils.register_class(ORTOG_PT_GraphicRefs) bpy.types.Scene.interesse_arco = bpy.props.StringProperty \ ( name = "Factor", description = "Fatos interesse arco", default = "226" ) bpy.types.Scene.my_enum_archscollision = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_ARCHSCOLLISION.DEFAULT, "DEFAULT", "Default gravity."), (ENUM_VALUES_ARCHSCOLLISION.INVERTED, "INVERTED", "Inverted gravity.")],) bpy.utils.register_class(ORTOG_PT_ImportaArc) # bpy.data.scenes['Scene'].render.filepath bpy.utils.register_class(AlinhaTresPontos) bpy.utils.register_class(ORTOG_OT_GeraModelosTomoArc) bpy.utils.register_class(ORTOG_PT_Segmentation) bpy.utils.register_class(ORTOG_PT_SegmentacaoFace) bpy.utils.register_class(ORTOG_PT_Converte_Video) bpy.types.Scene.d_factor = bpy.props.StringProperty \ ( name = "D Factor", description = "D Factor", default = "6" ) bpy.types.Scene.smooth_factor = bpy.props.StringProperty \ ( name = "Smooth Factor", description = "Smooth Factor", default = "16" ) bpy.types.Scene.my_enum = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_PHOTOGRAMMETRY.OPENMVG, "OpenMVG+OpenMVS", "Standard Photogrammetry"), (ENUM_VALUES_PHOTOGRAMMETRY.SMVS, "SMVS+MeshLab", "Alternative Photogrammetry I"), (ENUM_VALUES_PHOTOGRAMMETRY.MESHROOM, "Meshroom (AliceVision)", "Alternative Photogrammetry II"), (ENUM_VALUES_PHOTOGRAMMETRY.OPENMVGWIN, "OpenMVS Linux on Win", "Alternative Photogrammetry III")],) bpy.utils.register_class(ORTOG_PT_Fotogrametria) bpy.utils.register_class(ORTOG_PT_AlinhaFace) bpy.utils.register_class(ORTOG_PT_FotogramModif) bpy.utils.register_class(ORTOG_PT_AlinhaFaceCT) bpy.utils.register_class(ORTOG_PT_PontosAnatomicos) bpy.types.Scene.plano_oclusal_maxila_classico = bpy.props.StringProperty \ ( name = "Maxillary Occlusal Angle", description = "Maxilla Occlusal", default = "NONE" ) bpy.types.Scene.my_enum_ana = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_ANATOMICAL.HEAD, "HEAD", "Head Points"), (ENUM_VALUES_ANATOMICAL.MAXILLA, "MAXILLA", "Maxilla Points"), (ENUM_VALUES_ANATOMICAL.MANDIBLE, "MANDIBLE", "Mandible Points"), (ENUM_VALUES_ANATOMICAL.TEETH, "TEETH", "Teeth Points"), (ENUM_VALUES_ANATOMICAL.SOFTTISSUE, "SOFT TISSUE", "Soft Tissue Points")],) # bpy.utils.register_class(ORTOG_PT_PontosAnatomicosCabeca) # bpy.utils.register_class(ORTOG_PT_PontosAnatomicosMaxila) # bpy.utils.register_class(ORTOG_PT_PontosAnatomicosMandibula) # bpy.utils.register_class(ORTOG_PT_PontosAnatomicosDentes) # bpy.utils.register_class(ORTOG_PT_PontosAnatomicosMole) bpy.types.Scene.my_enum_cefalometria = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_CEFALOMETRIA.USP, "USP", "USP Cephalometry."), (ENUM_VALUES_CEFALOMETRIA.ARNETT, "ARNETT", "ARNETT Cephalometry.")],) bpy.types.Scene.plano_mandibula_usp = bpy.props.StringProperty \ ( name = "Mandibular Plane", description = "Mandibular Plane", default = "NONE" ) bpy.utils.register_class(ORTOG_PT_Cefalometria) bpy.types.Scene.my_enum_osteotomy = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_OSTEOTOMY.AUTO, "AUTO", "Automatic Ostetotomy Cut Planes"), (ENUM_VALUES_OSTEOTOMY.MANUAL, "MANUAL", "Manual Ostetotomy Cut Planes"), (ENUM_VALUES_OSTEOTOMY.BOOLEAN, "BOOLEAN", "Boolean Ostetotomy Cut"), (ENUM_VALUES_OSTEOTOMY.DRAW, "DRAW", "Draw Ostetotomy")],) bpy.utils.register_class(ORTOG_PT_Osteotomia) bpy.types.Scene.medida_real2 = bpy.props.StringProperty \ ( name = "", description = "Real size distance between eyes", default = "None" ) bpy.types.Scene.my_enum_dynamic = bpy.props.EnumProperty( name="Select", description= "", items=[(ENUM_VALUES_DYNAMIC.DEFAULT, "DEFAULT", "Default dynamic."), (ENUM_VALUES_DYNAMIC.NOSE, "NOSE EXP.", "Better deformation of nose."), (ENUM_VALUES_DYNAMIC.EXPERIMENTAL, "EXPERIMENTAL SLICES", "Dynamic with indetermined slices.")],) bpy.utils.register_class(ORTOG_PT_ArmatureDynamic) bpy.types.Scene.nome_ponto_customizado = bpy.props.StringProperty \ ( name = "Object Name", description = "Object Name", default = "MeasurePoint" ) bpy.utils.register_class(ORTOG_PT_CinematicaPanel) bpy.utils.register_class(ORTOG_PT_FechaLabios) bpy.utils.register_class(ORTOG_PT_GuideCreation) bpy.utils.register_class(ORTOG_PT_ImportTomoImg) bpy.utils.register_class(ORTOG_PT_Render) bpy.types.Scene.IMGPathSeq = bpy.props.StringProperty \ ( name = "IMGPathSeq", description = "IMGPathSeq", default = "NONE" ) bpy.types.Scene.SliceThickness = bpy.props.StringProperty \ ( name = "SliceThickness", description = "Slice Thickness", default = "NONE" ) bpy.types.Scene.PixelSpacingX = bpy.props.StringProperty \ ( name = "PixelSpacingX", description = "Pixel SpacingX", default = "NONE" ) bpy.types.Scene.PixelSpacingY = bpy.props.StringProperty \ ( name = "PixelSpacingY", description = "Pixel SpacingY", default = "NONE" ) bpy.types.Scene.IMGDimX = bpy.props.StringProperty \ ( name = "IMGDimX", description = "IMGDimX", default = "NONE" ) bpy.types.Scene.IMGDimY = bpy.props.StringProperty \ ( name = "IMGDimY", description = "IMGDimY", default = "NONE" ) def unregister(): bpy.utils.unregister_class(NomePaciente) bpy.utils.unregister_class(NomePacienteTomo) bpy.utils.unregister_class(NomePacienteArc) bpy.utils.unregister_class(NomePacienteRef) bpy.utils.unregister_class(NomePacienteSeg) bpy.utils.unregister_class(NomePacienteFotogram) bpy.utils.unregister_class(ORTOG_PT_NomePaciente) bpy.utils.unregister_class(Orbital_right_pt) bpy.utils.unregister_class(Orbital_left_pt) bpy.utils.unregister_class(N_pt) bpy.utils.unregister_class(Po_right_pt) bpy.utils.unregister_class(Po_left_pt) bpy.utils.unregister_class(Pt_right_pt) bpy.utils.unregister_class(Pt_left_pt) bpy.utils.unregister_class(Ba_pt) bpy.utils.unregister_class(S_pt) bpy.utils.unregister_class(U1_Tip_pt) bpy.utils.unregister_class(U1_LabGenBor_pt) bpy.utils.unregister_class(U1_LinGenBor_pt) bpy.utils.unregister_class(M_U6_pt) bpy.utils.unregister_class(D_U6_pt) bpy.utils.unregister_class(U6_Occlusal_pt) bpy.utils.unregister_class(PNS_pt) bpy.utils.unregister_class(A_pt) bpy.utils.unregister_class(ANS_pt) bpy.utils.unregister_class(L1_Tip_pt) bpy.utils.register_class(U1_Root_pt) bpy.utils.unregister_class(L1_LabGenBor_pt) bpy.utils.unregister_class(L1_LinGenBor_pt) bpy.utils.unregister_class(B_pt) bpy.utils.unregister_class(M_L6_pt) bpy.utils.unregister_class(L6_Occlusal_pt) bpy.utils.unregister_class(D_L6_pt) bpy.utils.unregister_class(MidRamusRight_pt) bpy.utils.unregister_class(MidRamusLeft_pt) bpy.utils.unregister_class(R_right_pt) bpy.utils.unregister_class(R_left_pt) bpy.utils.unregister_class(Go_right_pt) bpy.utils.unregister_class(Go_left_pt) bpy.utils.unregister_class(Ar_right_pt) bpy.utils.unregister_class(Ar_left_pt) bpy.utils.unregister_class(Sigmoid_right_pt) bpy.utils.unregister_class(Sigmoid_left_pt) bpy.utils.unregister_class(Co_right_pt) bpy.utils.unregister_class(Co_left_pt) bpy.utils.unregister_class(Pg_pt) bpy.utils.unregister_class(Gn_pt) bpy.utils.unregister_class(Me_pt) bpy.utils.unregister_class(ORTOG_PT_AtualizaAddonSec) bpy.utils.unregister_class(AtualizaScript) bpy.utils.unregister_class(AreasInfluencia) bpy.utils.unregister_class(CriaAreasDeformacao) bpy.utils.unregister_class(ConfiguraDinamicaMole) bpy.utils.unregister_class(ConfiguraMento) bpy.utils.unregister_class(ConfiguraCorpoMand) bpy.utils.unregister_class(ConfiguraRamoEsq) bpy.utils.unregister_class(ConfiguraRamoDir) bpy.utils.unregister_class(ConfiguraMaxila) bpy.utils.unregister_class(ConfiguraCabeca) bpy.utils.unregister_class(ImportaArmature) bpy.utils.unregister_class(ConfOsteotomiaAuto) bpy.utils.unregister_class(BooleanaOsteoGeral) bpy.utils.unregister_class(CriaMaxila) bpy.utils.unregister_class(CriaRamo) bpy.utils.unregister_class(CriaMento) bpy.utils.unregister_class(DesenhaLinhaVertex) bpy.utils.unregister_class(DesenhaLinhaVertexFin) bpy.utils.unregister_class(BooleanaOsteoClass) bpy.utils.unregister_class(DesenhaLinhaCorte) bpy.utils.unregister_class(LinhaCorte) bpy.utils.unregister_class(AlinhaTresPontos) bpy.utils.unregister_class(SegmentaDesenho) bpy.utils.unregister_class(BooleanaMand) bpy.utils.unregister_class(MantemPintado) bpy.utils.unregister_class(ApagaPintado) bpy.utils.unregister_class(Weight0) bpy.utils.unregister_class(Weight1) bpy.utils.unregister_class(SegmentaLinked) bpy.utils.unregister_class(LinhaBase) # bpy.utils.unregister_class(ORTOG_PT_CTScanOrgFIX) bpy.utils.unregister_class(CorrigeDicom) bpy.utils.unregister_class(AjustaTomo) bpy.utils.unregister_class(GeraModelosTomo) # bpy.utils.unregister_class(ORTOG_PT_CTScanFerrImg) # bpy.utils.unregister_class(CTScanRec) bpy.utils.unregister_class(ORTOG_PT_ImportaArc) bpy.utils.unregister_class(ORTOG_UI_CapturaLocal) bpy.utils.unregister_class(ORTOG_OT_GeraModelosTomoArc) bpy.utils.unregister_class(ORTOG_PT_GraphicRefs) bpy.utils.unregister_class(ORTOG_PT_Segmentation) bpy.utils.unregister_class(ORTOG_PT_Fotogrametria) bpy.utils.unregister_class(ORTOG_PT_AlinhaFace) bpy.utils.unregister_class(ORTOG_PT_FotogramModif) bpy.utils.unregister_class(ORTOG_PT_AlinhaFaceCT) # bpy.utils.unregister_class(ORTOG_PT_PontosAnatomicosCabeca) # bpy.utils.unregister_class(ORTOG_PT_PontosAnatomicosMaxila) # bpy.utils.unregister_class(ORTOG_PT_PontosAnatomicosMandibula) # bpy.utils.unregister_class(ORTOG_PT_PontosAnatomicosDentes) # bpy.utils.unregister_class(ORTOG_PT_PontosAnatomicosMole) bpy.utils.unregister_class(ORTOG_PT_Cefalometria) bpy.utils.unregister_class(ORTOG_PT_Osteotomia) del bpy.types.Scene.medida_real2 bpy.utils.unregister_class(EMP1a) bpy.utils.unregister_class(EMP2a) bpy.utils.unregister_class(EMP3a) bpy.utils.unregister_class(EMP1b) bpy.utils.unregister_class(EMP2b) bpy.utils.unregister_class(EMP3b) bpy.utils.unregister_class(ORTOG_PT_ArmatureDynamic) bpy.utils.unregister_class(ORTOG_PT_CinematicaPanel) bpy.utils.unregister_class(ORTOG_PT_GuideCreation) bpy.utils.unregister_class(ORTOG_PT_ImportTomoImg) if __name__ == "__main__": register()