basepointdesignz
Programmer
Hi,
I'm having a difficult time trying to get part of a VBA program to work. I have (among others) 7 attributes in a titleblock, which represent revision description on the drawing and what I want to do is loop through the 7 attiributes and check which is the next blank entry and put a value in that one.
So, basically it loops through the attributes and checks if it contains a value (textstring) and if it does, then check the next one, if not then put the new value in there..
Here's the part of the code that's doing my head in (the attribute tags are REV1 - REV7)
You may notice that the attributes are not in numerical order - that's how the attributes are arranged in the block when editing the attributes inside AutoCAD:
No matter how I construct the IFs and CASE statements, all the attributes are filled with the value, not the first blank one!!! It just doesn't seem to recognise the GoTo SkipTO function.. Arrgh!!!
Any ideas?
Cheers,
Paul @ basepoint designz..
basepoint designz
renegade@bpdesignz.com
I'm having a difficult time trying to get part of a VBA program to work. I have (among others) 7 attributes in a titleblock, which represent revision description on the drawing and what I want to do is loop through the 7 attiributes and check which is the next blank entry and put a value in that one.
So, basically it loops through the attributes and checks if it contains a value (textstring) and if it does, then check the next one, if not then put the new value in there..
Here's the part of the code that's doing my head in (the attribute tags are REV1 - REV7)
You may notice that the attributes are not in numerical order - that's how the attributes are arranged in the block when editing the attributes inside AutoCAD:
Code:
' Change revision number for all CONSTRUCTION drawings..
Private Sub CONSTRUCTION_STATUS()
' Loop through every layout in the drawing..
For Each layoutX In ThisDrawing.Layouts
ThisDrawing.ActiveLayout = layoutX
For Each entX In ThisDrawing.PaperSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
If entX.HasAttributes Then 'Check if object has attributes..
blnAttributes = True ' True if yes..
Exit For
End If
End If
Next ' End countx HasAttributes check loop..
' Start main loop to get attribute values for the attributes..
For Each entX In ThisDrawing.PaperSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
attribZ = entX.GetAttributes
For countx = LBound(attribZ) To UBound(attribZ)
Select Case attribZ(countx).TagString
' "Titleblock" block..
Case "STATUS"
attribZ(countx).TextString = status_text
Case "REVNUM"
If CheckBox1.Value = True Then
attribZ(countx).TextString = revnumber
ElseIf CheckBox1.Value = False Then
attribZ(countx).TextString = ComboBox1.Text
End If
Case "REV2"
If attribZ(countx).TextString <> "" Then
' Check the next one..
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
Case "REV5"
If attribZ(countx).TextString <> "" Then
' Check the next one..
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
Case "REV7"
If attribZ(countx).TextString <> "" Then
' If the list is full up..
MsgBox "The revision list on this titleblock is full!!", , "Revisons List: Full.."
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
Case "REV6"
If attribZ(countx).TextString <> "" Then
' Check the next one..
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
Case "REV4"
If attribZ(countx).TextString <> "" Then
' Check the next one..
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
Case "REV3"
If attribZ(countx).TextString <> "" Then
' Check the next one..
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
Case "REV1"
If attribZ(countx).TextString <> "" Then
' Check the next one..
Else: attribZ(countx).TextString = revnumber & " - " & revdetails & " - " & Date
GoTo SkipTO
End If
SkipTO:
End Select
Next countx ' End countx loop..
End If
Next ' End attributes loop..
Next layoutX ' End layout loop..
response = MsgBox("All the layouts have now been been updated.." & Chr(10) & Chr(10) & "Finish with the program now?..", vbQuestion + vbYesNo, "End the Program..")
If response = vbNo Then
Exit Sub
End If
If response = vbYes Then
statusform.Hide
End If
End Sub
No matter how I construct the IFs and CASE statements, all the attributes are filled with the value, not the first blank one!!! It just doesn't seem to recognise the GoTo SkipTO function.. Arrgh!!!
Any ideas?
Cheers,
Paul @ basepoint designz..
basepoint designz
renegade@bpdesignz.com