Message 1 of 6
Looping through attributes

Not applicable
03-17-2002
04:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there. Let me try to explain what's my problem.
I've inserted a block with attributes in the drawing. The names (TagString)
of the attributes are written in the following format DAN1, DAN2, DAN3, ....
Now what I'm trying to do is make an array of all attribute references and
then loop through them until I find the one I'm looking for and then change
it's value (TextString) to a certain date that is written in textbox.
I thought that if I write a code like this all the attributes with the name
DAN + something should be assigned a value of Datum variable. But nothing
happens.
---------------------------------------------------------------
Public Sub IzpisiDan()
Dim Datum As Variant
Dim objAttRef As AcadAttributeReference
Dim varAttributes As Variant
Dim intAttLoop As Integer
Dim intSteviloDni As Integer
Dim intI As String
Dim Dan As String
Datum = Format(txtDatumStart.Text, "dd.mm.")
intI = 0
varAttributes = objHarm.GetAttributes
For intAttLoop = LBound(varAttributes) To UBound(varAttributes)
intI = intI + 1
Dan = "DAN" & intI
Set objAttRef = varAttributes(intAttLoop)
If objAttRef.TagString = Dan Then
objAttRef.TextString = Datum
End If
Next
ThisDrawing.Application.Update
End Sub
---------------------------------------------------------------
But if I change that loop that it looks only for a specific attribute it
works.
---------------------------------------------------------------
For intAttLoop = LBound(varAttributes) To UBound(varAttributes)
intI = 1
Dan = "DAN" & intI
Set objAttRef = varAttributes(intAttLoop)
If objAttRef.TagString = Dan Then
objAttRef.TextString = Datum
End If
Next
---------------------------------------------------------------
If anyone knows what I'm doing wrong or if you have a better idea how to do
that task please let me know.
Thank you.
Marko
I've inserted a block with attributes in the drawing. The names (TagString)
of the attributes are written in the following format DAN1, DAN2, DAN3, ....
Now what I'm trying to do is make an array of all attribute references and
then loop through them until I find the one I'm looking for and then change
it's value (TextString) to a certain date that is written in textbox.
I thought that if I write a code like this all the attributes with the name
DAN + something should be assigned a value of Datum variable. But nothing
happens.
---------------------------------------------------------------
Public Sub IzpisiDan()
Dim Datum As Variant
Dim objAttRef As AcadAttributeReference
Dim varAttributes As Variant
Dim intAttLoop As Integer
Dim intSteviloDni As Integer
Dim intI As String
Dim Dan As String
Datum = Format(txtDatumStart.Text, "dd.mm.")
intI = 0
varAttributes = objHarm.GetAttributes
For intAttLoop = LBound(varAttributes) To UBound(varAttributes)
intI = intI + 1
Dan = "DAN" & intI
Set objAttRef = varAttributes(intAttLoop)
If objAttRef.TagString = Dan Then
objAttRef.TextString = Datum
End If
Next
ThisDrawing.Application.Update
End Sub
---------------------------------------------------------------
But if I change that loop that it looks only for a specific attribute it
works.
---------------------------------------------------------------
For intAttLoop = LBound(varAttributes) To UBound(varAttributes)
intI = 1
Dan = "DAN" & intI
Set objAttRef = varAttributes(intAttLoop)
If objAttRef.TagString = Dan Then
objAttRef.TextString = Datum
End If
Next
---------------------------------------------------------------
If anyone knows what I'm doing wrong or if you have a better idea how to do
that task please let me know.
Thank you.
Marko