Message 1 of 6
adding info to an array (attn: Josh and Frank)
Not applicable
03-23-2001
02:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Josh and Frank,
Thanx again for the help! I have incororated the
code that you both gave me.
code that you both gave me.
For those that are interested in helping me, I am trying
to renumber a "roomtag" that contains one attribute value. The block was
preinserted.
to renumber a "roomtag" that contains one attribute value. The block was
preinserted.
I am still having some problems with certain parts of it
and was wondering if you could help me figure them out. Below is the code
(with minor additions and changes in order for it to work with my stuff):
and was wondering if you could help me figure them out. Below is the code
(with minor additions and changes in order for it to work with my stuff):
I noted problems I was having with comments. A lot
of this is going to look strange when you see it becuse I am geussing at most of
it. I am sure that's part of the reason it does not work like it is
supposed to.
of this is going to look strange when you see it becuse I am geussing at most of
it. I am sure that's part of the reason it does not work like it is
supposed to.
Caution: It's pretty long.
Public Function CreateSelectionSet(Optional ssName As String = "ss") As
AcadSelectionSet
AcadSelectionSet
Dim ss As AcadSelectionSet
On Error Resume Next
Set ss =
ThisDrawing.SelectionSets(ssName)
If Err Then Set ss =
ThisDrawing.SelectionSets.Add(ssName)
ss.Clear
Set CreateSelectionSet = ss
On Error Resume Next
Set ss =
ThisDrawing.SelectionSets(ssName)
If Err Then Set ss =
ThisDrawing.SelectionSets.Add(ssName)
ss.Clear
Set CreateSelectionSet = ss
End Function
Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
Dim fType() As Integer, fData()
Dim index As Long, i As Long
index
= LBound(gCodes) - 1
For i = LBound(gCodes) To UBound(gCodes) Step
2
index = index +
1
ReDim Preserve fType(0 To
index)
ReDim Preserve fData(0 To
index)
fType(index) =
CInt(gCodes(i))
fData(index) =
gCodes(i + 1)
Next
typeArray =
fType: dataArray = fData
Dim index As Long, i As Long
index
= LBound(gCodes) - 1
For i = LBound(gCodes) To UBound(gCodes) Step
2
index = index +
1
ReDim Preserve fType(0 To
index)
ReDim Preserve fData(0 To
index)
fType(index) =
CInt(gCodes(i))
fData(index) =
gCodes(i + 1)
Next
typeArray =
fType: dataArray = fData
End Sub
Private Sub cmdRun_Click()
Dim fType, fData, ss As AcadSelectionSet
Dim varblkAttribs As
Variant
Dim strblkAttribs As String
Dim blkRef As
AcadBlockReference
Dim objBlkSelect As AcadSelectionSet
Dim intarray() As
Integer
Dim attarry As AcadAttribute
Dim Point(0 To 2) As Double
Dim
strArray As String
Dim Acadblock As AcadBlockReference
Dim varblkAttribs As
Variant
Dim strblkAttribs As String
Dim blkRef As
AcadBlockReference
Dim objBlkSelect As AcadSelectionSet
Dim intarray() As
Integer
Dim attarry As AcadAttribute
Dim Point(0 To 2) As Double
Dim
strArray As String
Dim Acadblock As AcadBlockReference
With ThisDrawing.Utility
Set ss = CreateSelectionSet()
BuildFilter fType, fData, 0, "INSERT", 2,
"ROOMTAG"
ss.Select acSelectionSetAll, , , fType, fData
.Prompt vbCr &
"There are " & ss.Count & " Roomtags in this drawing. "
BuildFilter fType, fData, 0, "INSERT", 2,
"ROOMTAG"
ss.Select acSelectionSetAll, , , fType, fData
.Prompt vbCr &
"There are " & ss.Count & " Roomtags in this drawing. "
End With
If ss.Count > 0 Then
Do
Dim Ent As AcadEntity
Dim Pt As
Variant
Set Ent = Nothing
Do
Dim Ent As AcadEntity
Dim Pt As
Variant
Set Ent = Nothing
On Error Resume Next
Me.Hide
Me.Hide
'When using the "getentity" method to select the necessary blocks, I
have to select and then 'press enter (mouse or keyboard) to get the
attribute value to change. Is there a way to just go 'through and
select all necessary blocks and then have the attributes update?
have to select and then 'press enter (mouse or keyboard) to get the
attribute value to change. Is there a way to just go 'through and
select all necessary blocks and then have the attributes update?
ThisDrawing.Utility.GetEntity Ent, Pt, "Select
the roomtags in order :"
Ent.Highlight True
If
Err Then
If
ThisDrawing.GetVariable("errno") = "7"
Then
Err.Clear
Else
Err.Clear
Exit Do
End
If
End If
'As you mentioned, I could only get this if statement to work when I
used acadblockreference
used acadblockreference
'insetead od declraing a variable as an acadblockrefernce
If TypeOf Ent Is AcadBlockReference
Then
'Here I had to set blkref = to Ent in order to get the code to
recogognize the Ent as a block
recogognize the Ent as a block
Set blkRef =
Ent
GoTo
EditAttrib
Else
MsgBox "One of the objects selected is not a
Roomtag."
Ent.Highlight
False
End
If
EditAttrib:
With ThisDrawing.Utility
If blkRef.Name = "roomtag"
Then
If blkRef.HasAttributes
Then
varblkAttribs =
blkRef.GetAttributes
End If
End
If
For i =
LBound(varblkAttribs) To
UBound(varblkAttribs)
strblkAttribs = strblkAttribs & " Tag(" & i & "):
" & _
varblkAttribs(i).tagString & vbTab & " value(" & i & "): " &
_
varblkAttribs(i).TextString & vbCr
If blkRef.Name = "roomtag"
Then
If blkRef.HasAttributes
Then
varblkAttribs =
blkRef.GetAttributes
End If
End
If
For i =
LBound(varblkAttribs) To
UBound(varblkAttribs)
strblkAttribs = strblkAttribs & " Tag(" & i & "):
" & _
varblkAttribs(i).tagString & vbTab & " value(" & i & "): " &
_
varblkAttribs(i).TextString & vbCr
'I could not get the ParsedPath or the PrevInstances statements to work
properly. What exactly is 'ParsedPath anyway? When used it just adds
1 to the number of all the roomtags that were 'selected in the drawing. So
in other words all of the roomtags end up being exactly the same. I 'think
I am confused on the Array part.
properly. What exactly is 'ParsedPath anyway? When used it just adds
1 to the number of all the roomtags that were 'selected in the drawing. So
in other words all of the roomtags end up being exactly the same. I 'think
I am confused on the Array part.
varblkAttribs(0).TextString = txtStrtNum.Text & ParsedPath &
(PrevInstances + 1)
Next
Set GetEntity = Ent
End With
Ent.Highlight False
Loop
End With
Ent.Highlight False
Loop
End If
End Sub
Thanx again for any help that anyone can provide.
Rob