diff --git a/pyRevitMEP.tab/Clear Mark.panel/ClearMark.pushbutton/icon.png b/pyRevitMEP.tab/Clear Mark.panel/ClearMark.pushbutton/icon.png new file mode 100644 index 0000000..48d4461 Binary files /dev/null and b/pyRevitMEP.tab/Clear Mark.panel/ClearMark.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Clear Mark.panel/ClearMark.pushbutton/script.py b/pyRevitMEP.tab/Clear Mark.panel/ClearMark.pushbutton/script.py new file mode 100644 index 0000000..5cd6b0c --- /dev/null +++ b/pyRevitMEP.tab/Clear Mark.panel/ClearMark.pushbutton/script.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +""" Clear Mark Parameter of MEP elements.""" + +__title__ = 'Clear Mark' +__author__ = 'André Rodrigues da Silva' + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) +from rpw.ui.forms import select_file +from Autodesk.Revit.DB import Transaction +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ +import csv + +try: + components = [ Label('Clear Mark Parameter:'), + Label('Mark Parameter:'), + TextBox('textbox1', Text="Mark"), + Separator(), + Button('Process')] + form = FlexForm('Clear Mark Parameter', components) + form.show() + + #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) + AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) + Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) + ConexoesDuto = db.Collector(of_category='OST_DuctFitting',is_not_type=True) + AcessoriosDuto = db.Collector(of_category='OST_DuctAccessory',is_not_type=True) + EquipamentosMecanicos = db.Collector(of_category='OST_MechanicalEquipment',is_not_type=True) + + Elementos = [] + + """ + if len(Tubos)>0: + for i in range(0,len(Tubos)): + Elementos.append(Tubos[i]) + """ + + if len(ConexoesTubo)>0: + for i in range(0,len(ConexoesTubo)): + Elementos.append(ConexoesTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(AcessoriosTubo)): + Elementos.append(AcessoriosTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(Equipamentos)): + Elementos.append(Equipamentos[i]) + if len(ConexoesDuto)>0: + for i in range(0,len(ConexoesDuto)): + Elementos.append(ConexoesDuto[i]) + if len(AcessoriosDuto)>0: + for i in range(0,len(AcessoriosDuto)): + Elementos.append(AcessoriosDuto[i]) + if len(EquipamentosMecanicos)>0: + for i in range(0,len(EquipamentosMecanicos)): + Elementos.append(EquipamentosMecanicos[i]) + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Delete Object') + transaction.Start() + + try: + Mark = form.values['textbox1'] + for i in range(0,len(Elementos)): + Elementos[i].LookupParameter(Mark).Set('') + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Clear Mark.panel/bundle.yaml b/pyRevitMEP.tab/Clear Mark.panel/bundle.yaml new file mode 100644 index 0000000..4cd1b50 --- /dev/null +++ b/pyRevitMEP.tab/Clear Mark.panel/bundle.yaml @@ -0,0 +1,2 @@ +layout: + - ClearMark diff --git a/pyRevitMEP.tab/Code.panel/PipeCode.pushbutton/icon.png b/pyRevitMEP.tab/Code.panel/PipeCode.pushbutton/icon.png new file mode 100644 index 0000000..12a73e4 Binary files /dev/null and b/pyRevitMEP.tab/Code.panel/PipeCode.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Code.panel/PipeCode.pushbutton/script.py b/pyRevitMEP.tab/Code.panel/PipeCode.pushbutton/script.py new file mode 100644 index 0000000..4aa3549 --- /dev/null +++ b/pyRevitMEP.tab/Code.panel/PipeCode.pushbutton/script.py @@ -0,0 +1,209 @@ +# -*- coding: utf-8 -*- +""" Insert code in ALL pipes.""" + +__title__ = 'Pipe' +__author__ = 'André Rodrigues da Silva' + + +import clr +clr.AddReference("PresentationFramework") +from System.Windows import Window + +file = '' +class ButtonClass(Window): + @staticmethod + def Importarbase(sender, e): + global file + file = select_file('csv separated by semicolon (*.csv)|*.csv') + return(file) + +def RevitCodes(dim): + if(dim == '15'): + return ('0.049212598425196846') + if(dim == '16'): + return ('0.052493438320209973') + if(dim == '20'): + return ('0.065616797900262466') + if(dim == '22'): + return ('0.072178477690288706') + if(dim == '25'): + return ('0.082020997375328086') + if(dim == '28'): + return ('0.091863517060367453') + if(dim == '32'): + return ('0.10498687664041995') + if(dim == '35'): + return ('0.11482939632545931') + if(dim == '40'): + return ('0.13123359580052493') + if(dim == '42'): + return ('0.13779527559055119') + if(dim == '50'): + return ('0.16404199475065617') + if(dim == '54'): + return ('0.17716535433070865') + if(dim == '60'): + return ('0.19685039370078738') + if(dim == '63'): + return ('0.20669291338582677') + if(dim == '73'): + return ('0.23950131233595801') + if(dim == '75'): + return ('0.24606299212598426') + if(dim == '85'): + return ('0.27887139107611547') + if(dim == '89'): + return ('0.29199475065616798') + if(dim == '90'): + return ('0.29527559055118108') + if(dim == '100'): + return ('0.32808398950131235') + if(dim == '110'): + return ('0.36089238845144356') + if(dim == '114'): + return ('0.37401574803149606') + if(dim == '150'): + return ('0.49212598425196852') + if(dim == '200'): + return ('0.65616797900262469') + if(dim == '12.7'): + return ('0.041666666666666664') + if(dim == '19.05'): + return ('0.0625') + if(dim == '19.10'): + return ('0.062664041994750661') + if(dim == '25.40'): + return ('0.083333333333333329') + if(dim == '31.75'): + return ('0.10433070866141732') + if(dim == '38.10'): + return ('0.125') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '63.50'): + return ('0.20833333333333334') + if(dim == '76.20'): + return ('0.25') + if(dim == '101.60'): + return ('0.33333333333333331') + if(dim == '45'): + return ('0.7853981633974475') + if(dim == '90'): + return ('1.570796326794895') + + else: + return(dim) + + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) +from rpw.ui.forms import select_file +from Autodesk.Revit.DB import Transaction +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ +import csv + +try: + components = [ Label('Codes in all pipes:'), + Label('Code parameter:'), + TextBox('textbox1', Text="AR - CODIGO"), + Label('Description parameter:'), + TextBox('textbox2', Text="AR - DESCRICAO"), + Button('Search base', on_click=ButtonClass.Importarbase), + Separator(), + Button('Process')] + form = FlexForm('Insert code in all pipes', components) + form.show() + + Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + Dutos = db.Collector(of_category='OST_DuctCurves',is_not_type=True) + TubosFlexiveis = db.Collector(of_category='OST_FlexPipeCurves',is_not_type=True) + DutosFlexiveis = db.Collector(of_category='OST_FlexDuctCurves',is_not_type=True) + + #ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) + #AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) + #Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) + + + Elementos = [] + + + if len(Tubos)>0: + for i in range(0,len(Tubos)): + Elementos.append(Tubos[i]) + if len(Dutos)>0: + for i in range(0,len(Dutos)): + Elementos.append(Dutos[i]) + if len(TubosFlexiveis)>0: + for i in range(0,len(TubosFlexiveis)): + Elementos.append(TubosFlexiveis[i]) + if len(DutosFlexiveis)>0: + for i in range(0,len(DutosFlexiveis)): + Elementos.append(DutosFlexiveis[i]) + + + with open(file,'r') as csv_file: + lines = csv_file.readlines() + + line = lines[0].split(";") + codigo_construtora = form.values['textbox1'] + descricao_construtora = form.values['textbox2'] + a = 0 + b = 0 + + for i in range(0,len(line)): + if(line[i] == codigo_construtora): + a = i + #if(line[i] == descricao_construtora): + #b = i + + + FamilyName = [] + Parameter1 = [] + Parameter2 = [] + Parameter3 = [] + Parameter4 = [] + Angle = [] + Indice = [] + ProductDescription = [] + Parameter5 = [] + CODIGO = [] + DESCRICAO = [] + + for line in lines: + data = line.split(';') + FamilyName.append(data[0]) + Parameter1.append(data[1]) + Parameter2.append(data[2]) + Parameter3.append(data[3]) + Parameter4.append(data[4]) + Angle.append(data[5]) + Indice.append(data[6]) + ProductDescription.append(data[7]) + Parameter5.append(data[8]) + CODIGO.append(data[a]) + DESCRICAO.append(data[a+1]) + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Insert parameters') + transaction.Start() + + try: + for i in range(0,len(Elementos)): + for t in range(0,len(FamilyName)): + if(Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and Indice[t]=='' and ProductDescription[t]=='' and Parameter5[t]==''): + info1 = list(Parameter1[t].split('=')) + if(Elementos[i].Name == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1]))): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Code.panel/PipeCodeSelected.pushbutton/icon.png b/pyRevitMEP.tab/Code.panel/PipeCodeSelected.pushbutton/icon.png new file mode 100644 index 0000000..17d0343 Binary files /dev/null and b/pyRevitMEP.tab/Code.panel/PipeCodeSelected.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Code.panel/PipeCodeSelected.pushbutton/script.py b/pyRevitMEP.tab/Code.panel/PipeCodeSelected.pushbutton/script.py new file mode 100644 index 0000000..4a8db9d --- /dev/null +++ b/pyRevitMEP.tab/Code.panel/PipeCodeSelected.pushbutton/script.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- +""" Insert code in SELECTED pipes.""" + +__title__ = 'Pipe \n Selected' +__author__ = 'André Rodrigues da Silva' + +import clr +clr.AddReference("PresentationFramework") +from System.Windows import Window + +file = '' +class ButtonClass(Window): + @staticmethod + def Importarbase(sender, e): + global file + file = select_file('csv separated by semicolon (*.csv)|*.csv') + return(file) + +def RevitCodes(dim): + if(dim == '15'): + return ('0.049212598425196846') + if(dim == '16'): + return ('0.052493438320209973') + if(dim == '20'): + return ('0.065616797900262466') + if(dim == '22'): + return ('0.072178477690288706') + if(dim == '25'): + return ('0.082020997375328086') + if(dim == '28'): + return ('0.091863517060367453') + if(dim == '32'): + return ('0.10498687664041995') + if(dim == '35'): + return ('0.11482939632545931') + if(dim == '40'): + return ('0.13123359580052493') + if(dim == '42'): + return ('0.13779527559055119') + if(dim == '50'): + return ('0.16404199475065617') + if(dim == '54'): + return ('0.17716535433070865') + if(dim == '60'): + return ('0.19685039370078738') + if(dim == '63'): + return ('0.20669291338582677') + if(dim == '73'): + return ('0.23950131233595801') + if(dim == '75'): + return ('0.24606299212598426') + if(dim == '85'): + return ('0.27887139107611547') + if(dim == '89'): + return ('0.29199475065616798') + if(dim == '90'): + return ('0.29527559055118108') + if(dim == '100'): + return ('0.32808398950131235') + if(dim == '110'): + return ('0.36089238845144356') + if(dim == '114'): + return ('0.37401574803149606') + if(dim == '150'): + return ('0.49212598425196852') + if(dim == '200'): + return ('0.65616797900262469') + if(dim == '12.7'): + return ('0.041666666666666664') + if(dim == '19.05'): + return ('0.0625') + if(dim == '19.10'): + return ('0.062664041994750661') + if(dim == '25.40'): + return ('0.083333333333333329') + if(dim == '31.75'): + return ('0.10433070866141732') + if(dim == '38.10'): + return ('0.125') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '63.50'): + return ('0.20833333333333334') + if(dim == '76.20'): + return ('0.25') + if(dim == '101.60'): + return ('0.33333333333333331') + if(dim == '45'): + return ('0.7853981633974475') + if(dim == '90'): + return ('1.570796326794895') + + else: + return(dim) + + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) +from rpw import ui +from rpw.ui.forms import select_file +from Autodesk.Revit.DB import Transaction +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ +import csv + +try: + components = [ Label('Codes in selected pipes:'), + Label('Code parameter:'), + TextBox('textbox1', Text="AR - CODIGO"), + Label('Description parameter:'), + TextBox('textbox2', Text="AR - DESCRICAO"), + Button('Search base', on_click=ButtonClass.Importarbase), + Separator(), + Button('Process')] + form = FlexForm('Insert code in selected pipes', components) + form.show() + + #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + #ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) + #AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) + #Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) + + Tubos = ui.Selection() + Elementos = Tubos + + """ + if len(Tubos)>0: + for i in range(0,len(Tubos)): + Elementos.append(Tubos[i]) + if len(ConexoesTubo)>0: + for i in range(0,len(ConexoesTubo)): + Elementos.append(ConexoesTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(AcessoriosTubo)): + Elementos.append(AcessoriosTubo[i]) + """ + + with open(file,'r') as csv_file: + lines = csv_file.readlines() + + line = lines[0].split(";") + codigo_construtora = form.values['textbox1'] + descricao_construtora = form.values['textbox2'] + a = 0 + b = 0 + + for i in range(0,len(line)): + if(line[i] == codigo_construtora): + a = i + #if(line[i] == descricao_construtora): + #b = i + + + FamilyName = [] + Parameter1 = [] + Parameter2 = [] + Parameter3 = [] + Parameter4 = [] + Angle = [] + CODIGO = [] + DESCRICAO = [] + + for line in lines: + data = line.split(';') + FamilyName.append(data[0]) + Parameter1.append(data[1]) + Parameter2.append(data[2]) + Parameter3.append(data[3]) + Parameter4.append(data[4]) + Angle.append(data[5]) + CODIGO.append(data[a]) + DESCRICAO.append(data[a+1]) + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Insert parameters') + transaction.Start() + + try: + for i in range(0,len(Elementos)): + for t in range(0,len(FamilyName)): + if(Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]==''): + info1 = list(Parameter1[t].split('=')) + if(Elementos[i].Name == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1]))): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Code.panel/PipeConnectionCode.pushbutton/icon.png b/pyRevitMEP.tab/Code.panel/PipeConnectionCode.pushbutton/icon.png new file mode 100644 index 0000000..58e4d89 Binary files /dev/null and b/pyRevitMEP.tab/Code.panel/PipeConnectionCode.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Code.panel/PipeConnectionCode.pushbutton/script.py b/pyRevitMEP.tab/Code.panel/PipeConnectionCode.pushbutton/script.py new file mode 100644 index 0000000..38c375e --- /dev/null +++ b/pyRevitMEP.tab/Code.panel/PipeConnectionCode.pushbutton/script.py @@ -0,0 +1,316 @@ +# -*- coding: utf-8 -*- +""" Insert code in ALL elements.""" + +__title__ = 'Pipe \n Connection' +__author__ = 'André Rodrigues da Silva' + +import clr +clr.AddReference("PresentationFramework") +from System.Windows import Window + +file = '' +class ButtonClass(Window): + @staticmethod + def Importarbase(sender, e): + global file + file = select_file('csv separated by semicolon (*.csv)|*.csv') + return(file) + + +def RevitCodes(dim): + if(dim == '15'): + return ('0.049212598425196846') + if(dim == '16'): + return ('0.052493438320209973') + if(dim == '20'): + return ('0.065616797900262466') + if(dim == '22'): + return ('0.072178477690288706') + if(dim == '25'): + return ('0.082020997375328086') + if(dim == '28'): + return ('0.091863517060367453') + if(dim == '32'): + return ('0.10498687664041995') + if(dim == '35'): + return ('0.11482939632545931') + if(dim == '40'): + return ('0.13123359580052493') + if(dim == '42'): + return ('0.13779527559055119') + if(dim == '50'): + return ('0.16404199475065617') + if(dim == '54'): + return ('0.17716535433070865') + if(dim == '60'): + return ('0.19685039370078738') + if(dim == '63'): + return ('0.20669291338582677') + if(dim == '73'): + return ('0.23950131233595801') + if(dim == '75'): + return ('0.24606299212598426') + if(dim == '85'): + return ('0.27887139107611547') + if(dim == '89'): + return ('0.29199475065616798') + if(dim == '90'): + return ('0.29527559055118108') + if(dim == '100'): + return ('0.32808398950131235') + if(dim == '110'): + return ('0.36089238845144356') + if(dim == '114'): + return ('0.37401574803149606') + if(dim == '150'): + return ('0.49212598425196852') + if(dim == '200'): + return ('0.65616797900262469') + if(dim == '12.70'): + return ('0.041666666666666664') + if(dim == '19.05'): + return ('0.0625') + if(dim == '19.10'): + return ('0.062664041994750661') + if(dim == '25.40'): + return ('0.083333333333333329') + if(dim == '31.75'): + return ('0.10433070866141732') + if(dim == '38.10'): + return ('0.125') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '63.50'): + return ('0.20833333333333334') + if(dim == '76.20'): + return ('0.25') + if(dim == '101.60'): + return ('0.33333333333333331') + if(dim == '45°'): + return ('0.7853981633974475') + if(dim == '90°'): + return ('1.570796326794895') + if(dim == '45º'): + return ('0.7853981633974475') + if(dim == '90º'): + return ('1.570796326794895') + + else: + return(dim) + + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) +from rpw.ui.forms import select_file +from Autodesk.Revit.DB import Transaction +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ +import csv + +try: + components = [ Label('Codes in all pipe connections:'), + Label('Code parameter:'), + TextBox('textbox1', Text="AR - CODIGO"), + Label('Description parameter:'), + TextBox('textbox2', Text="AR - DESCRICAO"), + Button('Search base', on_click=ButtonClass.Importarbase), + Separator(), + Button('Process')] + form = FlexForm('Insert code in all pipe connections', components) + form.show() + + #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) + AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) + Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) + ConexoesDuto = db.Collector(of_category='OST_DuctFitting',is_not_type=True) + AcessoriosDuto = db.Collector(of_category='OST_DuctAccessory',is_not_type=True) + EquipamentosMecanicos = db.Collector(of_category='OST_MechanicalEquipment',is_not_type=True) + + Elementos = [] + + """ + if len(Tubos)>0: + for i in range(0,len(Tubos)): + Elementos.append(Tubos[i]) + """ + + if len(ConexoesTubo)>0: + for i in range(0,len(ConexoesTubo)): + Elementos.append(ConexoesTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(AcessoriosTubo)): + Elementos.append(AcessoriosTubo[i]) + if len(Equipamentos)>0: + for i in range(0,len(Equipamentos)): + Elementos.append(Equipamentos[i]) + if len(ConexoesDuto)>0: + for i in range(0,len(ConexoesDuto)): + Elementos.append(ConexoesDuto[i]) + if len(AcessoriosDuto)>0: + for i in range(0,len(AcessoriosDuto)): + Elementos.append(AcessoriosDuto[i]) + if len(EquipamentosMecanicos)>0: + for i in range(0,len(EquipamentosMecanicos)): + Elementos.append(EquipamentosMecanicos[i]) + + with open(file,'r') as csv_file: + lines = csv_file.readlines() + + line = lines[0].split(";") + codigo_construtora = form.values['textbox1'] + descricao_construtora = form.values['textbox2'] + a = 0 + b = 0 + + for i in range(0,len(line)): + if(line[i] == codigo_construtora): + a = i + #if(line[i] == descricao_construtora): + #b = i + + + FamilyName = [] + Parameter1 = [] + Parameter2 = [] + Parameter3 = [] + Parameter4 = [] + Angle = [] + Indice = [] + ProductDescription = [] + TypeName = [] + CODIGO = [] + DESCRICAO = [] + + for line in lines: + data = line.split(';') + FamilyName.append(data[0]) + Parameter1.append(data[1]) + Parameter2.append(data[2]) + Parameter3.append(data[3]) + Parameter4.append(data[4]) + Angle.append(data[5]) + Indice.append(data[6]) + ProductDescription.append(data[7]) + TypeName.append(data[8]) + CODIGO.append(data[a]) + DESCRICAO.append(data[a+1]) + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Delete Object') + transaction.Start() + + try: + for i in range(0,len(Elementos)): + for t in range(0,len(FamilyName)): + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + info3 = list(Parameter3[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + info3 = list(Parameter3[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] ==''and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1]))): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]!='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1]))): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + + if(Parameter1[t]!='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]!='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) and Elementos[i].LookupParameter(info4[0]).AsDouble() == float(RevitCodes(info4[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]!='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) and Elementos[i].LookupParameter(info4[0]).AsDouble() == float(RevitCodes(info4[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + if(Elementos[i].Symbol.FamilyName == FamilyName[t]): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] !='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(ProductDescription[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsString() == str(info1[1])): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]!='' and TypeName[t]==''): + info1 = list(Indice[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsInteger() == int(info1[1])): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]!=''): + #info1 = list(TypeName[t].split('=')) + info1 = TypeName[t] + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].Name == str(info1)): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + + + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Code.panel/PipeConnectionCodeSelected.pushbutton/icon.png b/pyRevitMEP.tab/Code.panel/PipeConnectionCodeSelected.pushbutton/icon.png new file mode 100644 index 0000000..2ffb996 Binary files /dev/null and b/pyRevitMEP.tab/Code.panel/PipeConnectionCodeSelected.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Code.panel/PipeConnectionCodeSelected.pushbutton/script.py b/pyRevitMEP.tab/Code.panel/PipeConnectionCodeSelected.pushbutton/script.py new file mode 100644 index 0000000..e48b6b5 --- /dev/null +++ b/pyRevitMEP.tab/Code.panel/PipeConnectionCodeSelected.pushbutton/script.py @@ -0,0 +1,309 @@ +# -*- coding: utf-8 -*- +""" Insert code in SELECTED elements.""" + +__title__ = 'Pipe Connection \n Selected' +__author__ = 'André Rodrigues da Silva' + +import clr +clr.AddReference("PresentationFramework") +from System.Windows import Window + +file = '' +class ButtonClass(Window): + @staticmethod + def Importarbase(sender, e): + global file + file = select_file('csv separated by semicolon (*.csv)|*.csv') + return(file) + +def RevitCodes(dim): + if(dim == '15'): + return ('0.049212598425196846') + if(dim == '16'): + return ('0.052493438320209973') + if(dim == '20'): + return ('0.065616797900262466') + if(dim == '22'): + return ('0.072178477690288706') + if(dim == '25'): + return ('0.082020997375328086') + if(dim == '28'): + return ('0.091863517060367453') + if(dim == '32'): + return ('0.10498687664041995') + if(dim == '35'): + return ('0.11482939632545931') + if(dim == '40'): + return ('0.13123359580052493') + if(dim == '42'): + return ('0.13779527559055119') + if(dim == '50'): + return ('0.16404199475065617') + if(dim == '54'): + return ('0.17716535433070865') + if(dim == '60'): + return ('0.19685039370078738') + if(dim == '63'): + return ('0.20669291338582677') + if(dim == '73'): + return ('0.23950131233595801') + if(dim == '75'): + return ('0.24606299212598426') + if(dim == '85'): + return ('0.27887139107611547') + if(dim == '89'): + return ('0.29199475065616798') + if(dim == '90'): + return ('0.29527559055118108') + if(dim == '100'): + return ('0.32808398950131235') + if(dim == '110'): + return ('0.36089238845144356') + if(dim == '114'): + return ('0.37401574803149606') + if(dim == '150'): + return ('0.49212598425196852') + if(dim == '200'): + return ('0.65616797900262469') + if(dim == '12.70'): + return ('0.041666666666666664') + if(dim == '19.05'): + return ('0.0625') + if(dim == '19.10'): + return ('0.062664041994750661') + if(dim == '25.40'): + return ('0.083333333333333329') + if(dim == '31.75'): + return ('0.10433070866141732') + if(dim == '38.10'): + return ('0.125') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '50.80'): + return ('0.16666666666666666') + if(dim == '63.50'): + return ('0.20833333333333334') + if(dim == '76.20'): + return ('0.25') + if(dim == '101.60'): + return ('0.33333333333333331') + if(dim == '45°'): + return ('0.7853981633974475') + if(dim == '90°'): + return ('1.570796326794895') + if(dim == '45º'): + return ('0.7853981633974475') + if(dim == '90º'): + return ('1.570796326794895') + + else: + return(dim) + + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) +from rpw import ui +from rpw.ui.forms import select_file +from Autodesk.Revit.DB import Transaction +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ +import csv + +try: + components = [ Label('Codes in selected pipe connections:'), + Label('Code parameter:'), + TextBox('textbox1', Text="AR - CODIGO"), + Label('Description parameter:'), + TextBox('textbox2', Text="AR - DESCRICAO"), + Button('Search base', on_click=ButtonClass.Importarbase), + Separator(), + Button('Process')] + form = FlexForm('Insert code in selected pipe connections', components) + form.show() + + #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + #ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) + #AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) + #Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) + + + Elementos = ui.Selection() + + """ + if len(Tubos)>0: + for i in range(0,len(Tubos)): + Elementos.append(Tubos[i]) + + + if len(ConexoesTubo)>0: + for i in range(0,len(ConexoesTubo)): + Elementos.append(ConexoesTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(AcessoriosTubo)): + Elementos.append(AcessoriosTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(Equipamentos)): + Elementos.append(Equipamentos[i]) + + """ + + with open(file,'r') as csv_file: + lines = csv_file.readlines() + + line = lines[0].split(";") + codigo_construtora = form.values['textbox1'] + descricao_construtora = form.values['textbox2'] + a = 0 + b = 0 + + for i in range(0,len(line)): + if(line[i] == codigo_construtora): + a = i + #if(line[i] == descricao_construtora): + #b = i + + + FamilyName = [] + Parameter1 = [] + Parameter2 = [] + Parameter3 = [] + Parameter4 = [] + Angle = [] + Indice = [] + ProductDescription = [] + Parameter5 = [] + TypeName = [] + CODIGO = [] + DESCRICAO = [] + + for line in lines: + data = line.split(';') + FamilyName.append(data[0]) + Parameter1.append(data[1]) + Parameter2.append(data[2]) + Parameter3.append(data[3]) + Parameter4.append(data[4]) + Angle.append(data[5]) + Indice.append(data[6]) + ProductDescription.append(data[7]) + Parameter5.append(data[8]) + TypeName.append(data[8]) + CODIGO.append(data[a]) + DESCRICAO.append(data[a+1]) + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Delete Object') + transaction.Start() + + try: + for i in range(0,len(Elementos)): + for t in range(0,len(FamilyName)): + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + info3 = list(Parameter3[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + info3 = list(Parameter3[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] ==''and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + info2 = list(Parameter2[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1]))): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]!='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1]))): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + + if(Parameter1[t]!='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]!='' and Angle[t]!='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) and Elementos[i].LookupParameter(info4[0]).AsDouble() == float(RevitCodes(info4[1])) and Elementos[i].LookupParameter(angle[0]).AsDouble() == float(RevitCodes(angle[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]!='' and Parameter2[t]!='' and Parameter3[t]!='' and Parameter4[t]!='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(Parameter1[t].split('=')) + angle = list(Angle[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsDouble() == float(RevitCodes(info1[1])) and Elementos[i].LookupParameter(info2[0]).AsDouble() == float(RevitCodes(info2[1])) and Elementos[i].LookupParameter(info3[0]).AsDouble() == float(RevitCodes(info3[1])) and Elementos[i].LookupParameter(info4[0]).AsDouble() == float(RevitCodes(info4[1])) ): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]==''): + if(Elementos[i].Symbol.FamilyName == FamilyName[t]): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] !='' and Indice[t]=='' and TypeName[t]==''): + info1 = list(ProductDescription[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsString() == str(info1[1])): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]!='' and TypeName[t]==''): + info1 = list(Indice[t].split('=')) + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].LookupParameter(info1[0]).AsInteger() == int(info1[1])): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + + if(Parameter1[t]=='' and Parameter2[t]=='' and Parameter3[t]=='' and Parameter4[t]=='' and Angle[t]=='' and ProductDescription[t] =='' and Indice[t]=='' and TypeName[t]!=''): + #info1 = list(TypeName[t].split('=')) + info1 = TypeName[t] + if(Elementos[i].Symbol.FamilyName == FamilyName[t] and Elementos[i].Name == str(info1)): + Elementos[i].LookupParameter(codigo_construtora).Set(CODIGO[t]) + Elementos[i].LookupParameter(descricao_construtora).Set(DESCRICAO[t]) + + + + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Code.panel/bundle.yaml b/pyRevitMEP.tab/Code.panel/bundle.yaml new file mode 100644 index 0000000..dacc5f8 --- /dev/null +++ b/pyRevitMEP.tab/Code.panel/bundle.yaml @@ -0,0 +1,5 @@ +layout: + - PipeCode + - PipeCodeSelected + - PipeConnectionCode + - PipeConnectionCodeSelected \ No newline at end of file diff --git a/pyRevitMEP.tab/Renumber Mark.panel/RenumberMark.pushbutton/icon.png b/pyRevitMEP.tab/Renumber Mark.panel/RenumberMark.pushbutton/icon.png new file mode 100644 index 0000000..bfc7a62 Binary files /dev/null and b/pyRevitMEP.tab/Renumber Mark.panel/RenumberMark.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Renumber Mark.panel/RenumberMark.pushbutton/script.py b/pyRevitMEP.tab/Renumber Mark.panel/RenumberMark.pushbutton/script.py new file mode 100644 index 0000000..6c085f0 --- /dev/null +++ b/pyRevitMEP.tab/Renumber Mark.panel/RenumberMark.pushbutton/script.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +""" Renumber Mark Parameter of MEP elements.""" + +__title__ = 'Renumber Mark' +__author__ = 'André Rodrigues da Silva' + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) +from rpw.ui.forms import select_file +from Autodesk.Revit.DB import Transaction +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ +import csv + +try: + components = [ Label('Renumber Mark Parameter:'), + Label('Description parameter:'), + TextBox('textbox1', Text="AR - DESCRICAO"), + Label('Mark Parameter:'), + TextBox('textbox2', Text="Mark"), + Separator(), + Button('Process')] + form = FlexForm('Renumber Mark Parameter', components) + form.show() + + #Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + ConexoesTubo = db.Collector(of_category='OST_PipeFitting',is_not_type=True) + AcessoriosTubo = db.Collector(of_category='OST_PipeAccessory',is_not_type=True) + Equipamentos = db.Collector(of_category='OST_PlumbingFixtures',is_not_type=True) + ConexoesDuto = db.Collector(of_category='OST_DuctFitting',is_not_type=True) + AcessoriosDuto = db.Collector(of_category='OST_DuctAccessory',is_not_type=True) + EquipamentosMecanicos = db.Collector(of_category='OST_MechanicalEquipment',is_not_type=True) + + Elementos = [] + + """ + if len(Tubos)>0: + for i in range(0,len(Tubos)): + Elementos.append(Tubos[i]) + """ + + if len(ConexoesTubo)>0: + for i in range(0,len(ConexoesTubo)): + Elementos.append(ConexoesTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(AcessoriosTubo)): + Elementos.append(AcessoriosTubo[i]) + if len(AcessoriosTubo)>0: + for i in range(0,len(Equipamentos)): + Elementos.append(Equipamentos[i]) + if len(ConexoesDuto)>0: + for i in range(0,len(ConexoesDuto)): + Elementos.append(ConexoesDuto[i]) + if len(AcessoriosDuto)>0: + for i in range(0,len(AcessoriosDuto)): + Elementos.append(AcessoriosDuto[i]) + if len(EquipamentosMecanicos)>0: + for i in range(0,len(EquipamentosMecanicos)): + Elementos.append(EquipamentosMecanicos[i]) + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Delete Object') + transaction.Start() + + try: + + DESC = [] + REF = [] + ParBase = form.values['textbox1'] + Mark = form.values['textbox2'] + for i in range(0,len(Elementos)): + if (not Elementos[i].LookupParameter(ParBase).AsString()): + Elementos[i].LookupParameter(Mark).Set(0) + else: + REF.append(Elementos[i]) + DESC.append(Elementos[i].LookupParameter(ParBase).AsString()) + + Elementos2 = REF + L1 = DESC + L2 = [] + for i in range(0,len(L1),1): + L2.append(i) + + REF = L2 + + + L3=[] + for i in DESC: + if i not in L3: + L3.append(i) + L3 = sorted(L3, key=str.lower) + + L4 = [] + for i in range(0,len(REF),1): + if(DESC[i] in L3): + L4.append(str(L3.index(DESC[i])+1)) + + for i in range(0,len(Elementos2)): + Elementos2[i].LookupParameter(Mark).Set(L4[i]) + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Renumber Mark.panel/bundle.yaml b/pyRevitMEP.tab/Renumber Mark.panel/bundle.yaml new file mode 100644 index 0000000..6a88e14 --- /dev/null +++ b/pyRevitMEP.tab/Renumber Mark.panel/bundle.yaml @@ -0,0 +1,2 @@ +layout: + - RenumberMark \ No newline at end of file diff --git a/pyRevitMEP.tab/Split Pipes.panel/SplitPipes.pushbutton/icon.png b/pyRevitMEP.tab/Split Pipes.panel/SplitPipes.pushbutton/icon.png new file mode 100644 index 0000000..9991166 Binary files /dev/null and b/pyRevitMEP.tab/Split Pipes.panel/SplitPipes.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Split Pipes.panel/SplitPipes.pushbutton/script.py b/pyRevitMEP.tab/Split Pipes.panel/SplitPipes.pushbutton/script.py new file mode 100644 index 0000000..cb0d9c6 --- /dev/null +++ b/pyRevitMEP.tab/Split Pipes.panel/SplitPipes.pushbutton/script.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +""" Split ALL Pipes by PipeType and distance.""" + +__title__ = 'Split Pipes' +__author__ = 'André Rodrigues da Silva' + +from rpw import revit, db +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) + +from Autodesk.Revit.DB import Transaction + +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ + +try: + Tubos = db.Collector(of_category='OST_PipeCurves',is_not_type=True) + TipoTubo = db.Collector(of_category='OST_PipeCurves',is_type=True) + + PipeTypes = [] + for i in range(0,len(Tubos)): + PipeTypes.append(Tubos[i].Name) + + PipeTypes = list(dict.fromkeys(PipeTypes)) + PipeTypes = dict(zip(PipeTypes, PipeTypes)) + + + components = [Label('Select the pipe type:'), + ComboBox('PipeType', PipeTypes), + Label('Distance:'), + TextBox('distance', Text="3.0"), + Label('Parameters separated by ",":'), + TextBox('parameters', Text=""), + Separator(), + Button('Process')] + form = FlexForm('Split Pipes', components) + form.show() + + TuboMaterial = form.values['PipeType'] + L = float(form.values['distance'])*3.28084 + P = form.values['parameters'] + P = P.split(",") + + TuboSelecionado = [] + for i in range(0,len(Tubos)): + if(Tubos[i].Name == TuboMaterial): + TuboSelecionado.append(Tubos[i]) + + #Tubos com comprimento maior que o selecionado + TuboSecionado3 = [] + + for i in range(0,len(TuboSelecionado)): + if(TuboSelecionado[i].Location.Curve.Length > L): + TuboSecionado3.append(TuboSelecionado[i]) + + points = [] + pointsAUX = [] + for i in range(0,len(TuboSecionado3)): + if((TuboSecionado3[i].Location.Curve.Length/L)>int(TuboSecionado3[i].Location.Curve.Length/L)): + t = int(TuboSecionado3[i].Location.Curve.Length/L) + 1 + else: + t = int(TuboSecionado3[i].Location.Curve.Length/L) + d = L *TuboSecionado3[i].Location.Curve.Direction + for n in range(0,t): + if(n ==0): + continue + else: + pointsAUX.append(TuboSecionado3[i].Location.Curve.GetEndPoint(0) + n*d) + points.append(pointsAUX) + pointsAUX = [] + + pipes = TuboSecionado3 + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Delete Object') + transaction.Start() + try: + for t in range(0,len(pipes),1): + for i in range(0,len(points[t]),1): + dbPoint = points[t][i] + pipe = pipes[t] + newPipeId = BreakCurve(doc, pipe.Id, dbPoint) + newPipe = doc.GetElement(newPipeId) + + if(P[0]!=''): + for z in range(0,len(P)): + newPipe.LookupParameter(P[z]).Set(str(pipe.LookupParameter(P[z]).AsString())) + + newPipeConnectors = newPipe.ConnectorManager.Connectors + connA = None + connB = None + for c in pipe.ConnectorManager.Connectors: + pc = c.Origin + nearest = [x for x in newPipeConnectors if pc.DistanceTo(x.Origin) < 0.01] + if nearest: + connA = c + connB = nearest[0] + takeoff = doc.Create.NewUnionFitting(connA, connB) + + if(P[0]!=''): + for z in range(0,len(P)): + takeoff.LookupParameter(P[z]).Set(str(pipe.LookupParameter(P[z]).AsString())) + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Split Pipes.panel/SplitSelectedPipes.pushbutton/icon.png b/pyRevitMEP.tab/Split Pipes.panel/SplitSelectedPipes.pushbutton/icon.png new file mode 100644 index 0000000..f5dfa00 Binary files /dev/null and b/pyRevitMEP.tab/Split Pipes.panel/SplitSelectedPipes.pushbutton/icon.png differ diff --git a/pyRevitMEP.tab/Split Pipes.panel/SplitSelectedPipes.pushbutton/script.py b/pyRevitMEP.tab/Split Pipes.panel/SplitSelectedPipes.pushbutton/script.py new file mode 100644 index 0000000..8f05bd4 --- /dev/null +++ b/pyRevitMEP.tab/Split Pipes.panel/SplitSelectedPipes.pushbutton/script.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +""" Split SELECTED Pipes by distance.""" + +__title__ = 'Split Selected Pipes' +__author__ = 'André Rodrigues da Silva' + +from rpw import revit, db +from rpw import ui +from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) + +from Autodesk.Revit.DB import Transaction + +from Autodesk.Revit.DB.Plumbing.PlumbingUtils import BreakCurve +from rpw.db.xyz import XYZ + +try: + Tubos = ui.Selection() + + components = [Label('Select the distance for split pipes:'), + Label('Distance:'), + TextBox('distance', Text="3.0"), + Label('Parameters separated by ",":'), + TextBox('parameters', Text=""), + Separator(), + Button('Process')] + form = FlexForm('Split Pipes', components) + form.show() + + L = float(form.values['distance'])*3.28084 + P = form.values['parameters'] + P = P.split(",") + + TuboSelecionado = [] + + #Tubos com comprimento maior que o selecionado + TuboSecionado = [] + for i in range(0,len(Tubos)): + if(Tubos[i].Location.Curve.Length > L): + TuboSecionado.append(Tubos[i]) + + points = [] + pointsAUX = [] + for i in range(0,len(TuboSecionado)): + if((TuboSecionado[i].Location.Curve.Length/L)>int(TuboSecionado[i].Location.Curve.Length/L)): + t = int(TuboSecionado[i].Location.Curve.Length/L) + 1 + else: + t = int(TuboSecionado[i].Location.Curve.Length/L) + d = L *TuboSecionado[i].Location.Curve.Direction + for n in range(0,t): + if(n ==0): + continue + else: + pointsAUX.append(TuboSecionado[i].Location.Curve.GetEndPoint(0) + n*d) + points.append(pointsAUX) + pointsAUX = [] + + pipes = TuboSecionado + + # Typical Transaction in Revit Python Shell / pyRevit + doc = __revit__.ActiveUIDocument.Document + transaction = Transaction(doc, 'Delete Object') + transaction.Start() + try: + for t in range(0,len(pipes),1): + for i in range(0,len(points[t]),1): + dbPoint = points[t][i] + pipe = pipes[t] + newPipeId = BreakCurve(doc, pipe.Id, dbPoint) + newPipe = doc.GetElement(newPipeId) + + if(P[0]!=''): + for z in range(0,len(P)): + newPipe.LookupParameter(P[z]).Set(str(pipe.LookupParameter(P[z]).AsString())) + + newPipeConnectors = newPipe.ConnectorManager.Connectors + connA = None + connB = None + for c in pipe.ConnectorManager.Connectors: + pc = c.Origin + nearest = [x for x in newPipeConnectors if pc.DistanceTo(x.Origin) < 0.01] + if nearest: + connA = c + connB = nearest[0] + takeoff = doc.Create.NewUnionFitting(connA, connB) + + if(P[0]!=''): + for z in range(0,len(P)): + takeoff.LookupParameter(P[z]).Set(str(pipe.LookupParameter(P[z]).AsString())) + + except: + transaction.RollBack() + else: + transaction.Commit() + +except: + pass \ No newline at end of file diff --git a/pyRevitMEP.tab/Split Pipes.panel/bundle.yaml b/pyRevitMEP.tab/Split Pipes.panel/bundle.yaml new file mode 100644 index 0000000..055defd --- /dev/null +++ b/pyRevitMEP.tab/Split Pipes.panel/bundle.yaml @@ -0,0 +1,3 @@ +layout: + - SplitPipes + - SplitSelectedPipes \ No newline at end of file diff --git a/pyRevitMEP.tab/bundle.yaml b/pyRevitMEP.tab/bundle.yaml index 99f8f7a..146110d 100644 --- a/pyRevitMEP.tab/bundle.yaml +++ b/pyRevitMEP.tab/bundle.yaml @@ -1,6 +1,10 @@ layout: - Manage - Modify + - Split Pipes + - Code + - Renumber Mark + - Clear Mark - Create - Data - Samples