You are on page 1of 5

Public Class ClassTC <CommandMethod("TC")> _ Public Sub llamado() Call ModAtt_TC_SinCAJA() End Sub Public Sub ModAtt_TC_SinCAJA() Dim

doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor ed.WriteMessage(vbLf + "****************************************************") ed.WriteMessage(vbLf + "*******RUTINA PARA TUBOS DE CONCRETO SIN CAJA*******") '*******************INICIA EL CARGADO DE DATOS******************** 'Ruta de Trabajo Dim Ruta As String = Path.GetDirectoryName(doc.Database.Filename) Dim Ruta2() As String = Split(Ruta, "\004_PRY_CONST") Dim RutaFin As String = Ruta2(0) & "\008_DAT_LECTURA" 'Nombre del Archivo Dim NameDoc As String = Path.GetFileName(doc.Database.Filename) Dim NameDoc2() As String = Split(NameDoc, ".dwg") Dim NameDocFin As String = NameDoc2(0) Dim fileexist1 As String = RutaFin & "\" & NameDocFin & ".VOL" Dim fileexist2 As String = RutaFin & "\" & NameDocFin & ".RVAR" Dim fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(fileexist1) And fso.FileExists(fileexist2) Then MsgBox("Archivos de Lectura!!! Encontrados" & " " & "", vbInformation, "PROGRAMO: J. Armando Velez V. ") ed.WriteMessage(vbLf + "Seleccione la Obra:") Else MsgBox("No Existe Archivo de Lectura" & " " & "", vbInformation, "PROGRAMO: J. Armando Velez V. ") ed.WriteMessage(vbLf + "************Primero Genere las Memorias************") ed.WriteMessage(vbLf + "************NO SE COMPLETO EL PROCESO**************") ed.WriteMessage(vbLf + "*****************FIN DE LA RUTINA******************") ed.WriteMessage(vbLf + "******PROGRAMO: Ing. Jose Armando Velez Vargas*****") Exit Sub End If '*********************COMIENZA LA LECTURA DE VOLUMETRIAS************ Dim VGVOL As String() 'Vector General Dim linea1 As String Dim texto1 As String = "" Dim filefree1 As Integer filefree1 = FileSystem.FreeFile FileSystem.FileOpen(filefree1, fileexist1, OpenAccess.Read, OpenShare.Default, -1) Try Do While Not FileSystem.EOF(filefree1) linea1 = FileSystem.LineInput(filefree1) If (linea1 = Nothing) Then linea1 = " " End If texto1 = (texto1 & " " & linea1) Loop FileSystem.FileClose(New Integer() {filefree1}) texto1 = Module1.Eliminar_Espacios(texto1) VGVOL = Strings.Split(texto1, " ", -1, CompareMethod.Binary) Catch exception1 As Exception End Try '*********************TERMINA LECTURA DE VOLUMETRIAS: COMIENZA LA LECTURA DE VARIABLES************ Dim VGRAL As String() 'Vector General Dim linea2 As String Dim texto2 As String = "" Dim filefree2 As Integer filefree2 = FileSystem.FreeFile FileSystem.FileOpen(filefree2, fileexist2, OpenAccess.Read, OpenShare.Default, -1) Try

Do While Not FileSystem.EOF(filefree2) linea2 = FileSystem.LineInput(filefree2) If (linea2 = Nothing) Then linea2 = " " End If texto2 = (texto2 & "--" & linea2) Loop FileSystem.FileClose(New Integer() {filefree2}) 'texto3 = Module1.Eliminar_Espacios(texto3) VGRAL = Strings.Split(texto2, "--", -1, CompareMethod.Binary) Catch exception1 As Exception End Try '****************SE TERMINA EL CARGADO DE DATOS******************* '****************INICIA PARA PASAR LOS DATOS********************* 'Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim Dim Dim Dim Try attref As AttributeReference = Nothing bref As BlockReference = Nothing blkname As String = "C_TC_SC" '<--- CAMBIAR EL NOMBRE DEL BLOQUE attTag As String = String.Empty

Dim tr As Transaction = db.TransactionManager.StartTransaction() Using tr Dim selres As PromptSelectionResult = Nothing Dim tvs() As TypedValue = New TypedValue() {New TypedValue(0, "Insert"), New TypedValue(66, 1), New TypedValue(2, "`U*," + blkname)} Dim filt As SelectionFilter = New SelectionFilter(tvs) selres = ed.GetSelection(filt) If selres.Status <> PromptStatus.OK Then Return End If Dim selset As SelectionSet = selres.Value Dim bname As String = String.Empty For Each selobj As SelectedObject In selset Dim sent As Entity = DirectCast(tr.GetObject(selobj.ObjectId, OpenMode.ForRead), Entity) If TypeOf sent Is BlockReference Then Dim obr As BlockReference = DirectCast(sent, BlockReference) If obr.IsDynamicBlock Then Dim dynId As ObjectId = obr.DynamicBlockTableRecord If dynId.IsNull Or dynId.IsErased Then Continue For End If Dim dynbtr As BlockTableRecord = TryCast(tr.GetObject(dynId, OpenMode.ForRead), BlockTableRecord) If dynbtr IsNot Nothing Then bname = dynbtr.Name End If Else bname = obr.Name End If If bname = blkname Then For Each attId As ObjectId In obr.AttributeCollection attref = DirectCast(tr.GetObject(attId, OpenMode.ForWrite, False), AttributeReference) '********ESCRITURA DE VARIABLES DE VARILLAS************ 'ESCRITURA DE VOLUMETRIAS If attref.Tag = "EXC" Then attref.TextString = VGVOL(0) '**********TERMINA ESCRITURA DE VARILLAS*************** '**********INICIA ESCRITURA DE CANTIDADES*************** ElseIf attref.Tag = "FC150CTE" Then attref.TextString = VGVOL(1) ElseIf attref.Tag = "FC150CAJA" Then attref.TextString = VGVOL(2) ElseIf attref.Tag = "CARENA" Then attref.TextString = VGVOL(3)

ElseIf attref.Tag = "ACTEMP" Then attref.TextString = VGVOL(4) ElseIf attref.Tag = "VARROPE" Then attref.TextString = VGVOL(5) ElseIf attref.Tag = "MELEC" Then attref.TextString = VGVOL(6) ElseIf attref.Tag = "VDCON" Then attref.TextString = VGVOL(7) ElseIf attref.Tag = "TCC" Then attref.TextString = VGVOL(8) ElseIf attref.Tag = "TRTC" Then attref.TextString = VGVOL(9) ElseIf attref.Tag = "TC" Then attref.TextString = VGVOL(10) '**********TERMINA ESCRITURA DE CANTIDADES*************** '**********INICIA ESCRITURA DE VARIABLES*************** 'Lllenado de la Caratula ElseIf attref.Tag = "CARR" Then attref.TextString = VGRAL(1) ElseIf attref.Tag = "TRAMO" Then attref.TextString = VGRAL(2) ElseIf attref.Tag = "ESTACION" Then attref.TextString = VGRAL(3) ElseIf attref.Tag = "TOBRA" Then attref.TextString = VGRAL(4) ElseIf attref.Tag = "ALIN" Then attref.TextString = VGRAL(5) ElseIf attref.Tag = "ORIGEN" Then attref.TextString = VGRAL(6) ElseIf attref.Tag = "ODD" Then attref.TextString = VGRAL(7) ElseIf attref.Tag = "CESV" Then attref.TextString = VGRAL(8) ElseIf attref.Tag = "ESV" Then attref.TextString = VGRAL(9) ElseIf attref.Tag = "GO" Then attref.TextString = VGRAL(10) ElseIf attref.Tag = "ESP" Then attref.TextString = VGRAL(11) ElseIf attref.Tag = "MATERIALTC" Then attref.TextString = VGRAL(12) ' ElseIf attref.Tag = "TCAJA" Then ' attref.TextString = VGRAL(13) ElseIf attref.Tag = "RT" Then attref.TextString = VGRAL(13) ElseIf attref.Tag = "SR" Then attref.TextString = VGRAL(14) ElseIf attref.Tag = "PN" Then attref.TextString = VGRAL(15) ElseIf attref.Tag = "SCI" Then attref.TextString = VGRAL(16) ElseIf attref.Tag = "SCD" Then attref.TextString = VGRAL(17) ElseIf attref.Tag = "DI" Then attref.TextString = VGRAL(18) ElseIf attref.Tag = "DD" Then attref.TextString = VGRAL(19) ElseIf attref.Tag = "SO" Then attref.TextString = VGRAL(20) ElseIf attref.Tag = "FC" Then attref.TextString = VGRAL(21) ElseIf attref.Tag = "HET" Then attref.TextString = VGRAL(22) ElseIf attref.Tag = "HEM" Then attref.TextString = VGRAL(23) ElseIf attref.Tag = "HI" Then attref.TextString = VGRAL(24) ElseIf attref.Tag = "HD" Then

attref.TextString = VGRAL(25) ElseIf attref.Tag = "TI" Then attref.TextString = VGRAL(26) ElseIf attref.Tag = "TD" Then attref.TextString = VGRAL(27) ElseIf attref.Tag = "LI" Then attref.TextString = VGRAL(28) ElseIf attref.Tag = "LD" Then attref.TextString = VGRAL(29) ElseIf attref.Tag = "LT" Then attref.TextString = VGRAL(30) ElseIf attref.Tag = "LP" Then attref.TextString = VGRAL(31) ElseIf attref.Tag = "NOTC" Then attref.TextString = VGRAL(32) ElseIf attref.Tag = "FI" Then attref.TextString = VGRAL(33) ElseIf attref.Tag = "FD" Then attref.TextString = VGRAL(34) ElseIf attref.Tag = "CH" Then attref.TextString = VGRAL(35) ElseIf attref.Tag = "CM" Then attref.TextString = VGRAL(36) ElseIf attref.Tag = "TIC" Then attref.TextString = VGRAL(37) ElseIf attref.Tag = "TDC" Then attref.TextString = VGRAL(38) ElseIf attref.Tag = "LIC" Then attref.TextString = VGRAL(39) ElseIf attref.Tag = "LDC" Then attref.TextString = VGRAL(40) ElseIf attref.Tag = "LTC" Then attref.TextString = VGRAL(41) ' ElseIf attref.Tag = "A" Then attref.TextString = VGRAL(42) ElseIf attref.Tag = "BI" Then attref.TextString = VGRAL(43) ElseIf attref.Tag = "V" Then attref.TextString = VGRAL(44) ElseIf attref.Tag = "BT" Then attref.TextString = VGRAL(45) ElseIf attref.Tag = "PP" Then attref.TextString = VGRAL(46) ElseIf attref.Tag = "LM" Then attref.TextString = VGRAL(47) ElseIf attref.Tag = "H" Then attref.TextString = VGRAL(48) ElseIf attref.Tag = "HT" Then attref.TextString = VGRAL(49) ' '***DATOS PARA EL PROCESO DEL TRAMO**** ElseIf attref.Tag = "SMCI" Then attref.TextString = VGRAL(50) ElseIf attref.Tag = "SMCD" Then attref.TextString = VGRAL(51) ElseIf attref.Tag = "SEI" Then attref.TextString = VGRAL(52) ElseIf attref.Tag = "SED" Then attref.TextString = VGRAL(53) ElseIf attref.Tag = "TIN" Then attref.TextString = VGRAL(54) ElseIf attref.Tag = "TDN" Then attref.TextString = VGRAL(55) ElseIf attref.Tag = "REV" Then attref.TextString = VGRAL(56) ElseIf attref.Tag = "DIRSO" Then attref.TextString = VGRAL(57) ElseIf attref.Tag = "SOA" Then

attref.TextString = VGRAL(58) '**********TERMINA ESCRITURA DE VARIABLES*************** End If ed.WriteMessage(vbLf + "Tag: {0}" + vbLf + "Value: {1}", attref.Tag, attref.TextString) Next 'For ii = 0 To UBound(VGRAL) 'MsgBox("Valor VGRAL!! = " & VGRAL(ii)) 'Next ii ed.WriteMessage(vbLf + "*****************PROCESO CORRECTO******************") ed.WriteMessage(vbLf + "*****************FIN DE LA RUTINA******************") ed.WriteMessage(vbLf + "******PROGRAMO: Ing. Jose Armando Velez Vargas*****") End If End If Next tr.Commit() End Using Catch ex As Autodesk.AutoCAD.Runtime.Exception MsgBox(ex.ToString) End Try End Sub End Class

You might also like