It seem that I am having trouble with my email at home so I will repost to the newsgroupe and you.
The ones that I will be doing will have one block to each layout and only
one of these blocks in the drawing, in the paper space layout. The code
runs as expected when I have a string valve "10004567" substituted for the
value of TPn and an value of "B" in the for the second attribute (TDes
value) in the following lines:
If AttArray(I).TagString = "PB2" Then AttArray(I).TextString = TPn
If AttArray(I).TagString = "A" Then AttArray(I).TextString = TDes
I have tried to enter the text in a listbox by typing this as a number
(string value without the quotes) and then having the out put of the listbox set to a string value/s
to the variable/s of TPn and TDes in a second listbox.
---- Original Message -----
From: "Bernard Flavignard"
<be.flavi@infonie.fr>
To: "Robert Funk"
<bob_funk@prodigy.net>
Sent: Tuesday, May 29, 2001 10:42 AM
Subject: Re: Changing Block Attributes
> Robert,
>
> How many title block in a drawing, one for each drawing or ....
>
> Bernard
> ----- Original Message -----
> From: Robert Funk
<bob_funk@prodigy.net>
> To: Bernard Flavignard
<be.flavi@infonie.fr>
> Cc: Robert Funk
<bob_funk@cooksonpm.com>
> Sent: Tuesday, May 29, 2001 7:23 PM
> Subject: Re: Changing Block Attributes
>
>
> > 95% of all the title blocks are the same. The two attributes tags (PB2
&
> A)
> > are all the same in most of the blocks. The current strings have
> different
> > information attached to the blocks. The new information to be written
> into
> > the blocks will be different in each block. I hop to put this in as the
> > code is running for each block.
> >
> > Drawing Attached. Drawing format AutoCad MDT5 Service Pack 3.
> >
> > Thanks for ypu response and HELP.
> >
> > ----- Original Message -----
> > From: "Bernard Flavignard"
<be.flavi@infonie.fr>
> > To: "Robert Funk"
<bob_funk@prodigy.net>
> > Sent: Tuesday, May 29, 2001 6:42 AM
> > Subject: Re: Changing Block Attributes
> >
> >
> > > Robert,
> > >
> > > Do you want the same new string for each block with tagstring = "PB2"
> > > Or do you want differents news strings
> > >
> > > Can you send me one of your drawing with your blocks
> > >
> > > Bernard
> > > ----- Original Message -----
> > > From: Robert Funk
<bob_funk@prodigy.net>
> > > Newsgroups: autodesk.autocad.customization.vba
> > > Sent: Tuesday, May 29, 2001 2:20 PM
> > > Subject: Changing Block Attributes
> > >
> > >
> > > > I have 500+ drawings that I have to change two (2) to four (4) of
the
> > > Title
> > > > Block attributes. So far I have been able to come up with the
> following
> > > > code (with the help of this newsgroup):
> > > >
> > > > Public Sub T_TBChange()
> > > >
> > > > Dim AttArray As Variant
> > > > Dim Obj As Object
> > > > Dim blkRef As AcadBlockReference
> > > > Dim BlockName As String
> > > > Dim returnString As String
> > > > Dim TPn As String
> > > > Dim TDes As String
> > > > Dim objWorksheet As Object
> > > > Dim objWorkBook As Object
> > > > If blnAll = False Then
> > > >
> > > > For Each Obj In ThisDrawing.PaperSpace
> > > > If TypeOf Obj Is AcadBlockReference Then
> > > > Set blkRef = Obj
> > > >
> > > > If blkRef.HasAttributes Then
> > > > AttArray = blkRef.GetAttributes
> > > > For I = LBound(AttArray) To UBound(AttArray)
> > > > ' MsgBox AttArray(i).TagString
> > > > MsgBox returnString
> > > >
> > > > If AttArray(I).TagString = "PB2" Then
> > > > AttArray(I).TextString = TPn
> > > > in VBA.
> > > >
> > > >
> > > > If AttArray(I).TagString = "A" Then
> > > > AttArray(I).TextString = TDes
> > > > Next I
> > > > End If
> > > > End If
> > > > Next
> > > > End If
> > > > End Sub
> > > >
> > > > The problem that I am having the attribute TextString is going to be
> > > > changing in each drawing (along with the other two attributes, that
I
> > have
> > > > not yet defined in this code).
> > > >
> > > > I need to be able to input these new TextString values (TPn and
TDes)
> > > from
> > > > a input routine when the code runs.
> > > > For some reason - I have not been able to do this with my limited
> > > knowledge
> > > > in VBA.
> > > >
> > > > Thanks in advance Robert Funk
Mike Weaver wrote:
Inline comments:
"Robert Funk" <bob_funk@prodigy.net> wrote in message
news:8D87882645738E7DB129F70E5FBEAFD4@in.WebX.maYIadrTaRb...
I have 500+ drawings that I have to change two (2) to four (4) of the
Title
Block attributes. So far I have been able to come up with the following
code (with the help of this newsgroup):
'####################### Following line changed
Public Sub T_TBChange(TPn as string, TDes as string, NewVal1 as string,
NewVal2 as string)
Dim AttArray As Variant
Dim Obj As Object
Dim blkRef As AcadBlockReference
Dim BlockName As String
Dim returnString As String
'#################### the following two lines commented out
'Dim TPn As String
'Dim TDes As String
Dim objWorksheet As Object
Dim objWorkBook As Object
If blnAll = False Then
For Each Obj In ThisDrawing.PaperSpace
If TypeOf Obj Is AcadBlockReference Then
Set blkRef = Obj
If blkRef.HasAttributes Then
AttArray = blkRef.GetAttributes
For I = LBound(AttArray) To UBound(AttArray)
' MsgBox AttArray(i).TagString
MsgBox returnString
'###################### Following line added
if AttArray(i).TagString = "Target1" then
AttArray(i).TextString = NewVal1
'###################### Following line added
if AttArray(i).TagString = "Target2" then
AttArray(i).TextString = NewVal2
If AttArray(I).TagString = "PB2" Then
AttArray(I).TextString = TPn
in VBA.
If AttArray(I).TagString = "A" Then
AttArray(I).TextString = TDes
Next I
End If
End If
Next
End If
End Sub
You might also want to consider using Select Case:
For I = LBound(AttArray) To UBound(AttArray)
Set AttObj = AttArray(i)
Select Case AttObj.TagString
Case is = "Target1"
AttObj.TextString = NewVal1
Case is = "Target2"
AttObj.TextString = NewVal2
Case is = "PB2"
AttObj.TextString = TPn
Case is = "A"
AttObj.TextString = TDes
End Select
Next I
snip...
Mike Weaver