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
================================================