blintz Posted April 3, 2017 Posted April 3, 2017 Hello with vba / autocad I make a form for extract, from block, the attributes. This block contains 37 different attributes. A combobox reads the blocks present in model space, select the block in textbox read value attribute e.g. attrib. "1Tag" = "01" value attrib. "2Tag" = "02" value etc .. I want to insert new value of attribute in the block e.g old TextBox2 / attrib. "1Tag" = "01" value new TextBox2 / attrib. "1Tag" = "AA" value code: Private Sub ComboBox1_Change() '<<<<<<<------------- Dim BlockRef As AcadBlockReference Dim varAttributes As Variant Dim intAttribCount As Integer Dim newss As AcadSelectionSet Dim i, o, x As Integer ' Cancella la Selection Set se esiste On Error Resume Next If Not IsNull(ThisDrawing.SelectionSets.Item("ss")) Then Set newss = ThisDrawing.SelectionSets.Item("ss") newss.Delete End If ListBox1.Clear TextBox32.Value = 0 TextBox1.Value = ComboBox1.Value Set newss = ThisDrawing.SelectionSets.Add("ss") newss.Select acSelectionSetAll If newss.Count > 0 Then i = 1 o = 0 For x = 0 To newss.Count - 1 newss.Item (o) If newss.Item(o).ObjectName = "AcDbBlockReference" Then If newss.Item(o).EffectiveName = TextBox1.Value Then i = i + 1 varAttributes = newss.Item(o).GetAttributes For intAttribCount = LBound(varAttributes) To UBound(varAttributes) If varAttributes(intAttribCount).TagString = "1REV" Then TextBox2.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2REV" Then TextBox3.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "3REV" Then TextBox4.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "4REV" Then TextBox5.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "1MOD_REV" Then TextBox6.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2MOD_REV" Then TextBox7.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "3MOD_REV" Then TextBox8.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "4MOD_REV" Then TextBox9.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "1DATA_REV" Then TextBox10.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2DATA_REV" Then TextBox11.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "3DATA_REV" Then TextBox12.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "4DATA_REV" Then TextBox13.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "1FIRMA_REV" Then TextBox14.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2FIRMA_REV" Then TextBox15.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "3FIRMA_REV" Then TextBox16.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "4FIRMA_REV" Then TextBox17.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "DATA_CREAZIONE" Then TextBox18.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "DISEGNATORE" Then TextBox19.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "VISTO" Then TextBox20.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "APPROVATO" Then TextBox21.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "LINK" Then TextBox22.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "1CLIENTE" Then TextBox23.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2CLIENTE" Then TextBox24.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "MOD_MACCHINA" Then TextBox26.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "1MATR" Then TextBox27.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2MATR" Then TextBox28.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "#N-1" Then TextBox29.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "#N" Then TextBox30.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "#N+1" Then TextBox31.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "1SE_POT" Then TextBox33.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "2SE_AUX" Then TextBox34.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "3SE_PLCIN" Then TextBox35.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "4SE_PLCOUT" Then TextBox36.Value = varAttributes(intAttribCount).TextString ElseIf varAttributes(intAttribCount).TagString = "5SE_PLCLAYOUT" Then TextBox37.Value = varAttributes(intAttribCount).TextString '"ETC. ETC." End If If TextBox33.Value = "" Then Else TextBox25.Value = TextBox33.Value End If If TextBox34.Value = "" Then Else TextBox25.Value = TextBox34.Value End If If TextBox35.Value = "" Then Else TextBox25.Value = TextBox35.Value End If If TextBox36.Value = "" Then Else TextBox25.Value = TextBox36.Value End If If TextBox37.Value = "" Then Else TextBox25.Value = TextBox37.Value End If Next intAttribCount ListBox1.AddItem (o) o = o + 1 ElseIf newss.Item(o).EffectiveName <> TextBox1.Value Then o = o + 1 End If ElseIf newss.Item(o).ObjectName <> "AcDbBlockReference" Then o = o + 1 End If Next x End If TextBox32.Value = i - 1 End Sub With the "EXIT" button close the form but strangely vba editor does not end the macro code Private Sub CommandButton3_Click() Unload Me Set UserForm1 = Nothing End Sub I hope for your help regards Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.