Message 1 of 4
creating a table with several attributes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello again,
I'm developing code for counting, numbering and creating a table for dynamic blocks, but I'm dissolving it and the attached code is working, but the code creates an individual table for each block, there could be a table for all selected blocks where each line represents the block and its values
exemplo for final version:
at the moment:
Public NumNCE As Single
Public TagBl As String
Public NumNDT As String
Public NumNDC As String
Public NumNTE As String
Public PV As String
Public NAME As String
Public CodX As Double
Public CodY As Double
Public CodZ As Double
Public col As Double
Public lin As Double
Public key As Double
Public props() As AcadDynamicBlockReferenceProperty
Sub CONT_BOX_ESGOTO_COM_TAB()
Dim FilterData(0 To 1) As Variant 'cria a variavel filtro data
Dim FilterType(0 To 1) As Integer 'cria a variavel filtro type
Dim FlagTCdAnt As Boolean
Dim ModelSpecObj As AcadModelSpace
Dim NCirc As Integer
Dim NCol As Integer, NLin As Integer
Dim NOrig As Integer
Dim NumLinsTCd As Variant
Dim PtoInsTCd As Variant
Dim PtoLL As Variant, PtoUR As Variant
Dim PtoMR(0 To 2) As Double
Dim TabEnt As AcadTable
Dim TCCdEnt As AcadTable
Dim Verde As AcadAcCmColor
Dim Dad() As String
Dim TagShf As String
Dim LrgShf As Single
Dim PrfShf As Single
Dim dados As String
col = 8
lin = 3
key = 0
LrgShf = 1
PrfShf = 1
FlagOsnap = ThisDrawing.ObjectSnapMode
If FlagOsnap Then
ThisDrawing.ObjectSnapMode = True
End If
'MENSAGEM DO inputbox
NumNCE = InputBox("Entre o numero inicial para numeração de caixas de esgoto", "Numero de caixas de esgoto")
TagBl = InputBox("Defina o código inicial da tag (3 caracteres)", "Tag do bloco")
For Each SSet In ThisDrawing.SelectionSets
If SSet.NAME = "CDI" Then
ThisDrawing.SelectionSets.Item("CDI").Delete ' elemina outro selection set chamado cdi
Exit For
End If
Next SSet
Set SelCDI = ThisDrawing.SelectionSets.Add("CDI") 'seta um selection set chamado cdi
Set BlkCol = ThisDrawing.Blocks ' setar o bloco a ser modificado
FilterType(0) = 0
FilterData(0) = "Insert" 'tudo que é inserido
FilterType(1) = 8 ' vai precisar acrescentar desenhos 3d
FilterData(1) = "AHD" ' preciso trocar o shf
FimSel = 1 ' chave para entrar no while
Do While FimSel <> 0
SelCDI.SelectOnScreen FilterType, FilterData ' cria o selection set chamado cdi com um filtro de busca 0,
'inserido, bloco dinamico, layer AHD
key = key + 1
If SelCDI.Count = 1 Then ' se tiver uma seleção entra no if
Set BlkEnt = SelCDI(0) ' se a caixa de esgoto estiver no selection set
AtribCol = BlkEnt.GetAttributes 'pega o atributo da caixa de esgotoBlockReference.InsertionPoint
props = BlkEnt.GetDynamicBlockProperties
X = BlkEnt.insertionPoint
NAME = BlkEnt.EffectiveName
If NAME = "-pvqua" Or NAME = "-pvcir" Then
col = 9
NumNTE = AtribCol(4).TextString
Else
col = 8
End If
NumAtribs = UBoundAtributes 'define o valor do atributo
NumAtribs = UBound(AtribCol) + 1 ' acrescenta o valor ao atributo da caixa de esgoto
AtribCol(0).TextString = TagBl & NumNCE ' re-escreve o valor do atributo
NumNDT = AtribCol(1).TextString
NumNDC = AtribCol(2).TextString
PV = AtribCol(3).TextString
CodX = X(0) 'CORDENADA X
CodY = X(1) 'CORDENADA Y
CodZ = X(2) 'CORDENADA Z
'NumNDT = InputBox("Identifique o nivel da tampa", "Nivel da tampa")
'AtribCol(1).TextString = NumNDT
'NumNDC = InputBox("Identifique o nivel do fundo", "Nivel do fundo")
'AtribCol(2).TextString = NumNDC
Application.Update ' atualiza o desenho
NumNCE = NumNCE + 1
SelCDI.Clear ' limpa o selection set
NumCarTagShf = Len(BlkEnt.NAME)
TagShf = Right(BlkEnt.NAME, NumCarTagShf) ' - 3)
Set BlkDef = BlkCol.Item(BlkEnt.NAME)
NumEntsShf = BlkDef.Count
PtInsShf = BlkEnt.insertionPoint
AngTab = BlkEnt.Rotation
XSFac = BlkEnt.XScaleFactor
AtribColShf = BlkEnt.GetAttributes
For NEnt = 0 To NumEntsShf - 1
Set EntBlkCol = BlkDef.Item(NEnt)
If EntBlkCol.ObjectName = "AcDbBlockReference" Then
If Left(EntBlkCol.NAME, 6) = "HD§COL" Then
NumColShf = NumColShf + 1
AtribColCol = EntBlkCol.GetAttributes
For Each AtribCol In AtribColCol
Select Case AtribCol.TagString
Case "TAG"
Dad(NumColShf, 1) = AtribCol.TextString
Case "DIA"
Dad(NumColShf, 2) = AtribCol.TextString
End Select
Next AtribCol
End If
End If
Next NEnt
HTab = (NumColsShf * 4 + 5) * Esc ' preciso redimencionar tudo isso para o meu objetivo
DistP1 = Sqr((LrgShf / 2) ^ 2 + PrfShf ^ 2)
AngP1 = Atn(PrfShf / LrgShf * 2)
XInsTab = LrgShf / 2 - HTab / 2
YInsTab = PrfShf * SFac + 10 * Esc
DistPtTab = Sqr(XInsTab ^ 2 + YInsTab ^ 2)
AngPtTab = Atn(YInsTab / XInsTab) + Pi
PtTab = ThisDrawing.Utility.PolarPoint(PtInsShf, AngPtTab + AngTab, DistPtTab)
PtP1 = ThisDrawing.Utility.PolarPoint(PtInsShf, AngP1 + AngTab, DistP1)
PtP2 = ThisDrawing.Utility.PolarPoint(PtTab, AngTab, HTab / 2)
If XSFac = -1 Then
CorAng = Pi
Else
CorAng = 0
End If
DesTCol PtTab, AngTab + CorAng + Pi / 2, Val(NumColShf), TagShf, Dad
' Set LineObj = ThisDrawing.ModelSpace.AddLine(PtP1, PtP2)
' LineObj.Layer = "AHD"
'End If
'Next BlkEnt
'ThisDrawing.ModelSpace.AddTable(3, col + 1, 3, 4, 10)
Else
FimSel = 0 ' libera do while
End If
Loop
'NumNCE +2 IGUAL NUMERO DE LINHAS
End Sub
Sub DesTCol(PtInsTC As Variant, AngTC, NumCols As Integer, TagShf, Dad() As String)
Dim NCol As Integer, NLin As Integer
Dim TColsEnt As AcadTable
Dim DimeA As Single
Dim DimeB As Single
If NAME = "-pvqua" Then
DimeA = props(1).Value
DimeB = props(3).Value
ElseIf NAME = "-pvcir" Then
DimeA = props(0).Value
DimeB = props(2).Value
Else
DimeA = props(0).Value + props(2).Value
DimeB = props(4).Value + props(8).Value
End If
'DimeA = props(0).Value + props(2).Value
'DimeB = props(4).Value + props(8).Value
'AZI = props(10).Value
Set Verd = AcadApplication.GetInterfaceObject("AutoCAD.acCmColor.20") ' talvez trocar as cores
Set Cyan = AcadApplication.GetInterfaceObject("AutoCAD.acCmColor.20")
Verd.ColorIndex = acGreen
Cyan.ColorIndex = acCyan
Set TColsEnt = ThisDrawing.ModelSpace.AddTable(PtInsTC, 3, col, 0.07, 3) 'o 8 é a posição das colunas, NumCols +1 são as linhas
With TColsEnt
.AllowManualHeights = True
'.SetColumnWidth 1, 8
'.SetColumnWidth 2, 8
.MergeCells 0, 0, 0, 0
.SetRowHeight 0, 0.4
.SetCellContentColor 0, 0, Verd
.SetCellTextHeight 0, 0, 0.3
If NAME = "-pvqua" Then
.SetCellTextHeight 1, 0, 0.12
.SetCellTextHeight 1, 1, 0.12
.SetCellTextHeight 1, 2, 0.12
.SetCellTextHeight 1, 3, 0.12
.SetCellTextHeight 1, 4, 0.12
.SetCellTextHeight 1, 5, 0.12
.SetCellTextHeight 1, 6, 0.12
.SetCellTextHeight 1, 7, 0.12
.SetCellTextHeight 1, 8, 0.12
.SetCellTextHeight 2, 0, 0.13
.SetCellTextHeight 2, 1, 0.13
.SetCellTextHeight 2, 2, 0.13
.SetCellTextHeight 2, 3, 0.13
.SetCellTextHeight 2, 4, 0.13
.SetCellTextHeight 2, 5, 0.13
.SetCellTextHeight 2, 6, 0.13
.SetCellTextHeight 2, 7, 0.13
.SetCellTextHeight 2, 8, 0.13
.SetCellAlignment 0, 0, acMiddleCenter
.SetCellGridColor 0, 0, AcCellEdgeMask.acLeftMask, Cyan
.SetCellGridColor 0, 2, AcCellEdgeMask.acRightMask, Cyan
.SetCellGridColor 0, 0, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 1, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 2, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 3, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 4, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 5, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 6, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 7, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 8, AcCellEdgeMask.acBottomMask, Verd
'For NLin = 1 To NumCols
'For NCol = 0 To 2
' .SetCellAlignment NLin, NCol, acMiddleCenter
' .SetCellTextStyle NLin, NCol, "SIMPLEX"
' Next NCol
'Next NLin
.SetCellGridColor NumCols, 0, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 1, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 2, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 3, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 4, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 5, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 6, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 7, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 8, AcCellEdgeMask.acBottomMask, Cyan
.SetCellTextStyle 0, 0, "SIMPLEX"
.SetCellTextStyle 1, 0, "SIMPLEX"
.SetCellTextStyle 1, 1, "SIMPLEX"
.SetCellTextStyle 1, 2, "SIMPLEX"
.SetCellTextStyle 1, 3, "SIMPLEX"
.SetCellTextStyle 1, 4, "SIMPLEX"
.SetCellTextStyle 1, 5, "SIMPLEX"
.SetCellTextStyle 1, 6, "SIMPLEX"
.SetCellTextStyle 1, 7, "SIMPLEX"
.SetCellTextStyle 1, 8, "SIMPLEX"
.SetCellTextStyle 2, 0, "SIMPLEX"
.SetCellTextStyle 2, 1, "SIMPLEX"
.SetCellTextStyle 2, 2, "SIMPLEX"
.SetCellTextStyle 2, 3, "SIMPLEX"
.SetCellTextStyle 2, 4, "SIMPLEX"
.SetCellTextStyle 2, 5, "SIMPLEX"
.SetCellTextStyle 2, 6, "SIMPLEX"
.SetCellTextStyle 2, 7, "SIMPLEX"
.SetCellTextStyle 2, 8, "SIMPLEX"
.SetText 0, 0, "TABELA DE DADOS - CAIXA DE ESGOTO" '& TagShf
.SetText 1, 0, "CAIXA"
.SetText 1, 1, "NIVEL TAMPA (m)"
.SetText 1, 2, "NIVEL TETO (m)"
.SetText 1, 3, "NIVEL FUNDO (m)"
.SetText 1, 4, "DIMENS A (m)"
.SetText 1, 5, "DIMENS B (m)"
.SetText 1, 6, "COORD X (m)"
.SetText 1, 7, "COORD Y (m)"
.SetText 1, 8, "AZIMUTE (graus)"
.SetText 2, 0, TagBl & NumNCE - 1
.SetText 2, 1, NumNDT
.SetText 2, 2, NumNDC
.SetText 2, 3, PV
.SetText 2, 4, DimeA
.SetText 2, 5, DimeB
.SetText 2, 6, CodX
.SetText 2, 7, CodY
.SetText 2, 8, NumNTE
'---------------------------------------------------------------------------------------------------------
ElseIf NAME = "-pvcir" Then
.SetCellTextHeight 1, 0, 0.12
.SetCellTextHeight 1, 1, 0.12
.SetCellTextHeight 1, 2, 0.12
.SetCellTextHeight 1, 3, 0.12
.SetCellTextHeight 1, 4, 0.12
.SetCellTextHeight 1, 5, 0.12
.SetCellTextHeight 1, 6, 0.12
.SetCellTextHeight 1, 7, 0.12
.SetCellTextHeight 1, 8, 0.12
.SetCellTextHeight 2, 0, 0.13
.SetCellTextHeight 2, 1, 0.13
.SetCellTextHeight 2, 2, 0.13
.SetCellTextHeight 2, 3, 0.13
.SetCellTextHeight 2, 4, 0.13
.SetCellTextHeight 2, 5, 0.13
.SetCellTextHeight 2, 6, 0.13
.SetCellTextHeight 2, 7, 0.13
.SetCellTextHeight 2, 8, 0.13
.SetCellAlignment 0, 0, acMiddleCenter
.SetCellGridColor 0, 0, AcCellEdgeMask.acLeftMask, Cyan
.SetCellGridColor 0, 2, AcCellEdgeMask.acRightMask, Cyan
.SetCellGridColor 0, 0, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 1, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 2, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 3, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 4, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 5, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 6, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 7, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 8, AcCellEdgeMask.acBottomMask, Verd
'For NLin = 1 To NumCols
'For NCol = 0 To 2
' .SetCellAlignment NLin, NCol, acMiddleCenter
' .SetCellTextStyle NLin, NCol, "SIMPLEX"
' Next NCol
'Next NLin
.SetCellGridColor NumCols, 0, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 1, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 2, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 3, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 4, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 5, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 6, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 7, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 8, AcCellEdgeMask.acBottomMask, Cyan
.SetCellTextStyle 0, 0, "SIMPLEX"
.SetCellTextStyle 1, 0, "SIMPLEX"
.SetCellTextStyle 1, 1, "SIMPLEX"
.SetCellTextStyle 1, 2, "SIMPLEX"
.SetCellTextStyle 1, 3, "SIMPLEX"
.SetCellTextStyle 1, 4, "SIMPLEX"
.SetCellTextStyle 1, 5, "SIMPLEX"
.SetCellTextStyle 1, 6, "SIMPLEX"
.SetCellTextStyle 1, 7, "SIMPLEX"
.SetCellTextStyle 1, 8, "SIMPLEX"
.SetCellTextStyle 2, 0, "SIMPLEX"
.SetCellTextStyle 2, 1, "SIMPLEX"
.SetCellTextStyle 2, 2, "SIMPLEX"
.SetCellTextStyle 2, 3, "SIMPLEX"
.SetCellTextStyle 2, 4, "SIMPLEX"
.SetCellTextStyle 2, 5, "SIMPLEX"
.SetCellTextStyle 2, 6, "SIMPLEX"
.SetCellTextStyle 2, 7, "SIMPLEX"
.SetCellTextStyle 2, 8, "SIMPLEX"
.SetText 0, 0, "TABELA DE DADOS - CAIXA DE ESGOTO" '& TagShf
.SetText 1, 0, "CAIXA"
.SetText 1, 1, "NIVEL TAMPA (m)"
.SetText 1, 2, "NIVEL TETO (m)"
.SetText 1, 3, "NIVEL FUNDO (m)"
.SetText 1, 4, "DIMENS A (m)"
.SetText 1, 5, "DIMENS B (m)"
.SetText 1, 6, "COORD X (m)"
.SetText 1, 7, "COORD Y (m)"
.SetText 1, 8, "AZIMUTE (graus)"
.SetText 2, 0, TagBl & NumNCE - 1
.SetText 2, 1, NumNDT
.SetText 2, 2, NumNDC
.SetText 2, 3, NumNTE
.SetText 2, 3, PV
.SetText 2, 4, DimeA
.SetText 2, 5, DimeB
.SetText 2, 6, CodX
.SetText 2, 7, CodY
.SetText 2, 8, NumNTE
'---------------------------------------------------------------------------------------------------
Else
.SetCellAlignment 0, 0, acMiddleCenter
.SetCellGridColor 0, 0, AcCellEdgeMask.acLeftMask, Cyan
.SetCellGridColor 0, 2, AcCellEdgeMask.acRightMask, Cyan
.SetCellGridColor 0, 0, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 1, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 2, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 3, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 4, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 5, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 6, AcCellEdgeMask.acBottomMask, Verd
.SetCellGridColor 0, 7, AcCellEdgeMask.acBottomMask, Verd
'For NLin = 1 To NumCols
'For NCol = 0 To 2
' .SetCellAlignment NLin, NCol, acMiddleCenter
' .SetCellTextStyle NLin, NCol, "SIMPLEX"
' Next NCol
'Next NLin
.SetCellGridColor NumCols, 0, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 1, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 2, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 3, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 4, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 5, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 6, AcCellEdgeMask.acBottomMask, Cyan
.SetCellGridColor NumCols, 7, AcCellEdgeMask.acBottomMask, Cyan
.SetCellTextStyle 0, 0, "SIMPLEX"
.SetCellTextStyle 1, 0, "SIMPLEX"
.SetCellTextStyle 1, 1, "SIMPLEX"
.SetCellTextStyle 1, 2, "SIMPLEX"
.SetCellTextStyle 1, 3, "SIMPLEX"
.SetCellTextStyle 1, 4, "SIMPLEX"
.SetCellTextStyle 1, 5, "SIMPLEX"
.SetCellTextStyle 1, 6, "SIMPLEX"
.SetCellTextStyle 1, 7, "SIMPLEX"
.SetCellTextStyle 2, 0, "SIMPLEX"
.SetCellTextStyle 2, 1, "SIMPLEX"
.SetCellTextStyle 2, 2, "SIMPLEX"
.SetCellTextStyle 2, 3, "SIMPLEX"
.SetCellTextStyle 2, 4, "SIMPLEX"
.SetCellTextStyle 2, 5, "SIMPLEX"
.SetCellTextStyle 2, 6, "SIMPLEX"
.SetCellTextStyle 2, 7, "SIMPLEX"
.SetText 0, 0, "TABELA DE DADOS - CAIXA DE ESGOTO" '& TagShf
.SetText 1, 0, "CAIXA"
.SetText 1, 1, "NIVEL TAMPA (m)"
.SetText 1, 2, "NIVEL FUNDO (m)"
.SetText 1, 3, "DIMENS A (m)"
.SetText 1, 4, "DIMENS B (m)"
.SetText 1, 5, "COORD X (m)"
.SetText 1, 6, "COORD Y (m)"
.SetText 1, 7, "AZIMUTE (graus)"
.SetText 2, 0, TagBl & NumNCE - 1
.SetText 2, 1, NumNDT
.SetText 2, 2, NumNDC
.SetText 2, 3, DimeA
.SetText 2, 4, DimeB
.SetText 2, 5, CodX
.SetText 2, 6, CodY
.SetText 2, 7, PV
End If
' .SetCellTextStyle 0, 0, "SIMPLEX"
' .SetCellTextStyle 0, 1, "SIMPLEX"
' .SetCellTextStyle 0, 2, "SIMPLEX"
' .SetCellTextStyle 0, 3, "SIMPLEX"
' .SetCellTextStyle 0, 4, "SIMPLEX"
' .SetCellTextStyle 0, 5, "SIMPLEX"
' .SetCellTextStyle 0, 6, "SIMPLEX"
' .SetCellTextStyle 0, 7, "SIMPLEX"
' .SetText 0, 0, TagBl & NumNCE - 1
' .SetText 0, 1, NumNDT
' .SetText 0, 2, NumNDC
' .SetText 0, 3, DimeA
' .SetText 0, 4, DimeB
' .SetText 0, 5, CodX
' .SetText 0, 6, CodY
' .SetText 0, 7, PV
'End If
'For NLin = 1 To NumCols
'.SetText NLin, 0, Dad(NLin, 1) ' 'PRENCHE A COLUNA 1
'.SetText NLin, 2, Dad(NLin, 2) ''PRENCHE A COLUNA 3
'Next NLin
'.StyleName = "SIMPLEX"
' .ScaleEntity PtInsTC, 1 * Esc
.Rotate PtInsTC, AngTC
.Layer = "AHD"
End With
End Sub