Need to change the ATTRIBUTE TEXT WIDTH FACTOR ON MANY DWGs!!!

Need to change the ATTRIBUTE TEXT WIDTH FACTOR ON MANY DWGs!!!

Anonymous
Not applicable
2,959 Views
15 Replies
Message 1 of 16

Need to change the ATTRIBUTE TEXT WIDTH FACTOR ON MANY DWGs!!!

Anonymous
Not applicable
I used the ATTSYNC command in a batch process and it reset the TEXT WIDTH property for the MATERIAL tag in the TITLE_BLOCK block for all of the dwgs. (100's). I need a LISP or VBA routine that will reset the width of the text to 0.55.

THIS DWG . BLOCK ("TITLE_BLOCK") . TAG ("MATERIAL") . WIDTH FACTOR = 0.55

Please help me with this tool so that I can run another batch process to undo what I did do!! (I already have a batch utility so if your macro works on the attached dwg. I'll fix it from there.)

This is simple for someone - PLEASE HELP!!!

Thanks,
MSR
0 Likes
2,960 Views
15 Replies
Replies (15)
Message 2 of 16

arcticad
Advisor
Advisor
' This is written in AutoCAD 2005
' Add a Reference to Autocad/objectDBX common 16.0 Type Library
' it will get your file list and change whatever values you need in
' the drawing and then save the drawing.
' All without opening each individual file in the interface.

Function GetFileList()
Dim Folder As String
Dim fs, f, f1, fc
Dim MyColl As New Collection
Folder = "c:\cadd\"

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(Folder)
Set fc = f.Files

For Each f1 In fc
If UCase(Right(f1.name, 4)) = UCase(".dwg") Then
MyColl.Add f1.path
End If
Next

If MyColl.Count > 0 Then
For Each item In MyColl
GetDBX (item)
Next
End If

End Function

Public Function GetDBX(FName)
Dim oSpace As AcadBlock
Dim aNumber As Double
Dim BlockName As String
Dim OBJ, item
dim att, atts
aNumber = 8#

Set odbx = GetInterfaceObject("ObjectDBX.AxDbDocument.16")
If Err Then
MsgBox "Error with ObjectDBX object"
Set odbx = Nothing
Else
odbx.Open FName
Set oSpace = odbx.ModelSpace ' Or Paperspace
End If
For Each item In oSpace

If TypeOf item Is AcadBlockReference Then ' get Attributes
If Not TypeOf item Is AcadExternalReference Then
if item.name = BlockName then
atts = item.GetAttributes
For Each att In atts
att.width = 0.55
Next
end if
End If
End If

If TypeOf item Is AcadText Then ' get text
item.width = 0.55
End If
Next
odbx.SaveAs FName
End Function
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 16

Anonymous
Not applicable
Hi,
Change reference to AutoCAD/ObjecDBX XX.X Type Library
to your current Acad version and change
in code string "ObjectDBX.AxDbDocument.16" on
"ObjectDBX.AxDbDocument.17" if you have a
2007 version
Tested in A2005 only
Hth

~'J'~
0 Likes
Message 4 of 16

Anonymous
Not applicable
Is there a way that I can just loop through Thisdrawing.-----

Basically, if I run the macro from the current drawing it will change the attribute property. This way I can do other things with my batch script. So the script (text file) may look like the following...

open
path...dwg1
;;do some stuff
stuff 1->n
;;do macro
BatchAttWid.dvb!SuperVBAcode
qsave
close
open
path..dwg2
-->repeat
etc....
0 Likes
Message 5 of 16

Anonymous
Not applicable
In my opinion easier yet to write
this script by lisp

~'J'~
0 Likes
Message 6 of 16

arcticad
Advisor
Advisor
odbx is the same as thisdrawing

By changing the reference you can use any existing code.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 7 of 16

Anonymous
Not applicable
I agree with you,
Regards

~'J'~
0 Likes
Message 8 of 16

Anonymous
Not applicable
??

Can you help me?

??

Thanks,
MSR
0 Likes
Message 9 of 16

arcticad
Advisor
Advisor
as Fatty mentioned.

If you want to do a "script" then lisp is better.

The main reason is commands will not synchronize with VBA.

What will happen is you will run a sendcommand and then VBA
will issue the next command without waiting for Autocad to finish
with the last command.

The result is AutoCAD will not run VBA and Lisp at the same time
and will just "hang". it won't crash but it won't run either.

The code I posted can process each drawing in several seconds. It is a magnitude faster then actually opening up a drawing or running any script file. I've used this to process 3000 drawings at a time with no errors. Processing that many files in the interface will simply crash AutoCAD.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 10 of 16

Anonymous
Not applicable
MikeEng,

This is something I used some years back to generate batch script files in a
hurry. It's not pretty but it can save you some time. I hardcoded the script
key strokes pointer file and just saved different versions of the routine
with different names for each task the script was to do like
change-sheet-number or whatever. The routine was done for 2002 but I think
it still will work in 2006. I don't have that loaded to test sorry.

In the sample you have a keystrokes.txt file this is the script operations
that are passed / copied between each filename. just change the commands in
the base script or pointer text file to your operations.
I never got around to adding a browse for the base script pointer file or
the save script file. If you do add these I'd love to see what you came up
with.

If nothing else it might give you some ideas if you like working script
files as I do.

Have a great day

John Coon

wrote in message news:5465827@discussion.autodesk.com...
as Fatty mentioned.

If you want to do a "script" then lisp is better.

The main reason is commands will not synchronize with VBA.

What will happen is you will run a sendcommand and then VBA
will issue the next command without waiting for Autocad to finish
with the last command.

The result is AutoCAD will not run VBA and Lisp at the same time
and will just "hang". it won't crash but it won't run either.

The code I posted can process each drawing in several seconds. It is a
magnitude faster then actually opening up a drawing or running any script
file. I've used this to process 3000 drawings at a time with no errors.
Processing that many files in the interface will simply crash AutoCAD.
0 Likes
Message 11 of 16

Anonymous
Not applicable
Thanks guys...

Although I'm a little confused.

I just ran this script on 500+ dwgs and it worked great.

Here is a small snippet from the script generator:
___________________________________________
open
h:\FW00107\PARTS\BEAMS\100.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\101.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\102.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\103.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\104.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\105.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\106.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\107.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\108.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\109.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\110.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
_______________________________________


Where quicken.dvb!changeattribute is defined as:

Sub ChangeAttribute()

For Each item In ThisDrawing.PaperSpace

'
'Look for a specific Block Reference"
'
If TypeOf item Is AcadBlockReference Then ' get Attributes

If Not TypeOf item Is AcadExternalReference Then
If item.Name = "TITLE_BLOCK" Then

atts = item.GetAttributes

For Each att In atts
If att.TagString = "MATERIAL" Then att.ScaleFactor = 0.55
Next

End If
End If
End If
Next
_____________________________
I would like to learn LISP more but I am a little more (not zero) familiar with VBA. To me LISP looks awful!!!! LOL!!!!

Where should I start?

Thanks again.
MSR
0 Likes
Message 12 of 16

Anonymous
Not applicable
If you means about web here is the
very best place to start:
www.afralisp.net

Trust me

~'J'~
0 Likes
Message 13 of 16

Anonymous
Not applicable
MikeEng,

How did you generate the script and file names ? That looks similar to
results of sample I sent.. yours loops thru the files names somehow then
inserts

-vbarun
quicken.dvb!changeattribute
qsave
close

then the next file name and saves as a script. is that coorect?

John Coon

wrote in message news:5466879@discussion.autodesk.com...
Thanks guys...

Although I'm a little confused.

I just ran this script on 500+ dwgs and it worked great.

Here is a small snippet from the script generator:
___________________________________________
open
h:\FW00107\PARTS\BEAMS\100.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\101.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\102.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\103.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\104.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\105.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\106.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\107.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\108.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\109.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
open
h:\FW00107\PARTS\BEAMS\110.dwg
-vbarun
quicken.dvb!changeattribute
qsave
close
_______________________________________


Where quicken.dvb!changeattribute is defined as:

Sub ChangeAttribute()

For Each item In ThisDrawing.PaperSpace

'
'Look for a specific Block Reference"
'
If TypeOf item Is AcadBlockReference Then ' get Attributes

If Not TypeOf item Is AcadExternalReference Then
If item.Name = "TITLE_BLOCK" Then

atts = item.GetAttributes

For Each att In atts
If att.TagString = "MATERIAL" Then att.ScaleFactor =
0.55
Next

End If
End If
End If
Next
_____________________________
I would like to learn LISP more but I am a little more (not zero) familiar
with VBA. To me LISP looks awful!!!! LOL!!!!

Where should I start?

Thanks again.
MSR
0 Likes
Message 14 of 16

Anonymous
Not applicable
I used a little script generator called ScriptMate. Basically you pick all of the files that you want to run the script commands on. And then type your commands usually the commands are similar to:

OPEN
{FILENAME}
**AND THEN DO SOMETHING**
**COULD BE A CALL TO VBA OR LISP - WHATEVER**
ZOOM
EXTENTS
REGEN
QSAVE
CLOSE

The final step is to create the script. ScriptMate generates a txt file which is a loop where every filepath from the files selected in step one replaces the {FILENAME} part of the loop.

So I guess that what I've been doing is using the script (text files) to run the same VBA code over and over again. It seems to work great.

Message was edited by: MikeEng

Message was edited by: MikeEng Message was edited by: MikeEng
0 Likes
Message 15 of 16

Anonymous
Not applicable
MikeEng,

Never saw that one before but it looks flexiable. sorry I couldn't help

wrote in message news:5467396@discussion.autodesk.com...
I used a little script generator called ScriptMate. Basically you pick all
of the files that you want to run the script commands on. And then type
your commands usually the commands are similar to:

OPEN
{FILENAME}
**AND THEN DO SOMETHING**
**COULD BE A CALL TO VBA OR LISP - WHATEVER**
ZOOM
EXTENTS
REGEN
QSAVE
CLOSE

The final step is to create the script. ScriptMate generates a txt file
which is a loop where every filepath from the files selected in step one
replaces the {FILE
NAME} part of the loop.

So I guess that what I've been doing is using the script (text files) to run
the same VBA code over and over again. It seems to work great.

Message was edited by: MikeEng

Message was edited by: MikeEng

Message was edited by: MikeEng
0 Likes
Message 16 of 16

Anonymous
Not applicable
You did help a great deal. Thanks for the code!!
0 Likes