TheSwamp
CAD Forums => CAD General => Topic started by: MSTG007 on July 21, 2006, 03:04:38 PM
-
How could i chage a text style and dim style in multiple dwgs (1,000) dwgs , without opening eachone of the them?
Thanks!
-
with a script. Although the script would be opening each one and saving it
-
Hi,
Look for in autodesk.com the program Scriptpro.
Bye
Yolanda
-
It would be something like:
OPEN C:\DIRECTORY\FILENAME1.DWG -STYLE;ROMANS;ROMANS.SHX;;;;;;;qsave;close
OPEN C:\DIRECTORY\FILENAME2.DWG -STYLE;ROMANS;ROMANS.SHX;;;;;;;qsave;close
...And so on...
First, you need to go into one of your drawings and make sure you can do everything you need to do from the command prompt.
-
Lets say I do not have a text style created and I want to change textstyle1 to be textstyle2.
I want to change my arrowheads on dimstyle to be from what it is a closed arrowhead to another arrow head.
Thats it.
and I have several drawings.
So setup a script and just drag each one to it or can i batch do a directory / folder?
thxs
-
Lets say I do not have a text style created and I want to change textstyle1 to be textstyle2.
I'm pretty sure all you would need is something like this:
OPEN C:\DIRECTORY\FILENAME1.DWG -STYLE;ROMANS;ROMANS.SHX;;;;;;;qsave;close
OPEN C:\DIRECTORY\FILENAME2.DWG -STYLE;ROMANS;ROMANS.SHX;;;;;;;qsave;close
I want to change my arrowheads on dimstyle to be from what it is a closed arrowhead to another arrow head.
I'm trying to figure that one out right now... ( DIMBLK? )
and I have several drawings.
So setup a script and just drag each one to it or can i batch do a directory / folder?
You create one script file with every drawing's path in it, then start AutoCAD, type SCRIPT and select the .scr file you created. Then all you have to do is sit and watch AutoCAD work away. It's actually kind of fun for a while.
-
If you're new to scripts though, I would suggest starting with a few test drawings (copies) before you start overwriting hundreds of them.
-
creating the style is easy, changing the text from one style to another is harder to do commandline. Is it possible just to change textstyle1 to the properties that you want? If not, the best way would be to use a lisp statement to select all of the text that is style textstyle1, then you can use the CHANGE command to change the style.
For the arrowheads, I would cover all of your bases for different ways that the dimensions could be set up and set DIMBLK, DIMBLK1, and DIMBLK2 to your arrow block, then do a DIM UPDATE ALL
-
i would do it through VBA cuz its easier. I have example code to shange all text to Romans and change dims
-
Public Sub ChangeTextToRomans()
Dim objSelected As Object
Dim objTxt As AcadText
Dim objstyle As AcadTextStyle
Dim objLayer As AcadLayer
Dim objSelSet As AcadSelectionSet
Dim intAnswer As Integer
On Error GoTo ErrControl
Set objstyle = ThisDrawing.TextStyles.Add("ROMANS")
objstyle.fontFile = "romans.shx"
objstyle.Width = 1#
Set objstyle = ThisDrawing.TextStyles.Add("TEP-TITLE")
objstyle.fontFile = "C:\WINNT\Fonts\ARIAL.TTF"
objstyle.Width = 0.85
Set objSelSet = ThisDrawing.SelectionSets.Add("Text")
objSelSet.Select acSelectionSetAll
For Each objSelected In objSelSet
If TypeOf objSelected Is AcadText Then
Set objTxt = objSelected
If UCase(objTxt.StyleName) <> "ROMANS" Then
objTxt.StyleName = "ROMANS"
objTxt.ScaleFactor = 1#
Else
objTxt.ScaleFactor = 1#
End If
End If
Next
ThisDrawing.SelectionSets.Item("Text").Delete
ThisDrawing.Application.Update
Exit_Here:
Exit Sub
ErrControl:
MsgBox Err.Description
End Sub
-
Do the same for your dims
-
Great code CmdrDuh.
I am also a bit new to scripts. Can you invoke a VBA routine through script?
-
Absolutely. Just paste the code into the VBAIDE save it as a dvb, then use VBARUN in your script to run it. Although I would still set the dimblk* variable and do a dim update for them.
-
Thanks Bob,
I'll try it at work.
-
OK...I am dumb... can not figure this out... I am trying to make this alot easier on me...
trying to create a script which will do the following:
-change text style l75 from simplex to arial
-replace words of CONCRETE TO CONC.
-replace words of PAVEMENT to PVMT.
- Paste Block or insert block
- Plot to a certain printer with pen settings.
----------------
thats it...
any ideas?
thanks!
-
Here's what I would use for your script...
-style;l75;arial.ttf;;;;;;cht;ALL;;T;G;CONCRETE;CONC;T;G;PAVEMENT;PVMT;;
That will take care of the first three items, but the block you want to insert, is it going in at the same coordinates on every drawing?
Plotting can also be done via a script, but it would be easier to use the Batch Plot utility.
-
Same advice I have on any script. Type it into the command line. All a script is, is an automated set of comands. If you can type it in, you can script it. If you type it in and a dialog box pops up, try typing it again with a - before the command. The below makes use of an autodesk lisp called chtext
-STYLE
l75
ARIAL.TTF
chtxt
all
s
l75
t
g
CONCRETE
CONC.
t
g
PAVEMENT
PVMT.
_pasteclip
0,0
-plot
Y
<certain printer name>
<paper size>
<units>
<orientation>
n
e
<plot scale>
c
y
<pen settings>
-
i am getting a error
Command: -STYLE
Enter name of text style or [?] <L70>: l75
New style.
Specify full font name or font filename (TTF or SHX) <txt>: ARIAL.TTF
Specify height of text <0.00>:
Specify width factor <1.00>:
Specify obliquing angle <0d0'0">:
Display text backwards? [Yes/No] <N>:
Display text upside-down? [Yes/No] <N>:
"l75" is now the current text style.
Command: chtxt
Unknown command "CHTXT". Press F1 for help.
-
Try CHT in place of CHTXT
-
ok... I guess this would be a smart time to tell you i still can not get the script to work. I am running CIVIL3D2006. Here is the following error i get:
\DesktopProfile\detail.scr"
Command: -STYLE
Enter name of text style or [?] <L70>: l75
New style.
Specify full font name or font filename (TTF or SHX) <txt>: ARIAL.TTF
Specify height of text <0.00>:
Specify width factor <1.00>:
Specify obliquing angle <0d0'0">:
Display text backwards? [Yes/No] <N>:
Display text upside-down? [Yes/No] <N>:
"l75" is now the current text style.
Command:
-STYLE Enter name of text style or [?] <l75>: ARIAL.TTF
New style.
Specify full font name or font filename (TTF or SHX) <txt>: s
Font not available.
Command:
-STYLE Enter name of text style or [?] <l75>: l175
Existing style.
Specify full font name or font filename (TTF or SHX) <simplex>: find
Font not available.
Command: CONCRETE
Unknown command "CONCRETE". Press F1 for help.
thxs
-
Looks like one too many "enter" lines after the style definition. Instead of using blank lines for entering defaults, I go ahead and add the default values in the script files just to make sure I'm running with the right syntax.
-
Well, we can see where the script turned south by knowing what we wanted it to do and comparing it to what the script did.
Here, we see that it went through and changed the font file in L75 to Arial, but it looks like there's one too many "Return"s in there, as it starts the -Style command again.
Try this
-STYLE
l75
ARIAL.TTF
cht
all
t
g
CONCRETE
CONC.
t
g
PAVEMENT
PVMT.
_pasteclip
0,0
-plot
Y
<certain printer name>
<paper size>
<units>
<orientation>
n
e
<plot scale>
c
y
<pen settings>
-
it would help if you put the contents of your script instead of the command dump. You are setting the style, seems to work fine, then you go through the style command again but not correctly, then partially again, trying to launch a find command (more on this in a sec) as the font file. Then try to change CONCRETE using FIND which you didn't launch above in a way that AFAIK you can't. FIND is not a command line usable command.
Again, type the commands in, one at a time, manually in a drawing. What you have to type to get it to work is EXACTLY what you need in the script. Why did you decide not to use chtext.lsp?
<edit>outsped by m-daddy(almost)</edit>
-
..., then you go through the style command again but not correctly, then partially again, trying to launch a find command (more on this in a sec) as the font file. ...
I'm guessing there's too many "enter" lines and he's trying to repeat the last command a couple of times, maybe not.
-
cad has no clue what "CHT" is.
-STYLE
l75
ARIAL.TTF
cht
all
t
g
CONCRETE
CONC.
t
g
PAVEMENT
PVMT.
_pasteclip
0,0
-plot
Y
<certain printer name>
<paper size>
<units>
<orientation>
n
e
<plot scale>
c
y
<pen settings>
-
Again, type the commands in, one at a time, manually in a drawing. What you have to type to get it to work is EXACTLY what you need in the script. Why did you decide not to use chtext.lsp?
I concur.
Go into one of the drawings you want to change and make sure you can do EVERYTHING you're trying to do at the command prompt.
The above should work. _pasteclip is where it's going to get sketchy and <certain printer name is going to throw a wrench in the gears and bring you to a screeching halt. Let's get you to that point first.
Again, is the block you want to insert A) The same block for each drawing and B) going to be inserted in the same location for each drawing?
-
agree that pasteclip is sketchy but that's what was asked for. I'm assuming that said block is a title block and would need to be copied befroe the script is run. You would be a lot better off using INSERT than pasteclip IMO but you can do it either way if you make sure that you are doing it correctly.
-
-STYLE <<<<<<<<<<<<WORKS
l75
ARIAL.TTF
cht (NO CLUE WHAT CHT IS)<<<<<<<<<<<<----------------- DOES NOT WORK
all
t
g
CONCRETE
CONC.
t
g
PAVEMENT
PVMT. <<<<<<<<<<<<----------------- DOES NOT WORK
SPELL <<<<<<<WORKS
ALL
_pasteclip 0,0 <<<<<<<<<<<<-------- DOES NOT WORK
-plot <<<<<<<<WORKS
yes
IR2270.pc3
Inches
PORTRAIT
no
extents
FIT
Center
yes
OCE DEBOY.CTB
yes
no
no
no
yes
<<<<<<WORKS
-
cht, look on your computer for a lisp routine called chtext.lsp make sure it's loaded.
_pasteclip should work IF you copyclip the block that you want to paste before running the script, i didn't test it though, you're better off doing
-insert
<blockname>
0,0
1
0
-
CHTXT IS WORKING.
t (per cmd line thinks its mtext
g (group)
I was trying to bring in a external block at 0,0
here is where i am at
-STYLE
L175
ARIAL.TTF
.2
chtXT
t
g
CONCRETE
CONC.
t
g
PAVEMENT
PVMT.
SPELL
ALL
_INSERT
E:\CAD\WATERMARK.DWG
0,0
-plot
yes
IR2270.pc3
Inches
PORTRAIT
no
extents
FIT
Center
yes
OCE DEBOY.CTB
yes
no
no
no
yes
-
i just stumbled upon this post and am still perplexed as to how you guys got scriptpro to work. i was never able to get that thing to do anything. in my instance all i wanted to do is open a bunch of drawings and import our current page setups. it would also be splendid if it could trash the ones which apply to obselete plotters. i put this project aside for awhile because i could not get it to work but maybe this is a call to pick it up again.
-
I've never used ScriptPro...
I use Directory Printer to get my directory listings, then Excel to create my scripts...
-
Holy multiscript thread BATTMAN!
trashing the unused pagesetups is a more differenter thing and cannot be done form the commandline but to import pagesetups via a script,
-PSETUPIN
<drawing with the page setups in it>
*
I also have never used scriptpro. Also Excel. Rarely do scripts these days, as there is a lot less reason to do them IMO.
-
CHTXT IS WORKING.
t (per cmd line thinks its mtext
g (group)
I was trying to bring in a external block at 0,0
here is where i am at
-STYLE
L175
ARIAL.TTF
.2
chtXT
t
g
CONCRETE
CONC.
t
g
PAVEMENT
PVMT.
SPELL
ALL
_INSERT
E:\CAD\WATERMARK.DWG
0,0
-plot
yes
IR2270.pc3
Inches
PORTRAIT
no
extents
FIT
Center
yes
OCE DEBOY.CTB
yes
no
no
no
yes
Ok, that's what you have, but what is the problem? Is it with the CHT routine? I'm at home and can't remember whether it's String or Text, but you're right, G is for Global.
-
um... trying to do a find and replace.
lol - i know why this is frusterating... I AM NEW! grhh...
now the block one is not working! lol
-INSERT
WATERMARK
0,0,0
1
-
Glad you posted, I missed that post in a page change.
T is text
G is global
<string to change>
<new string>
et viola, find and replace
make sure the drawing (WATERMARK) is in your support path or change the script so that it has the full path of the file. You also aren't giving it everything with the block
-insert
watermark
0,0,0
1
0
0,0,0 is the isertion point
1 is the x scale factor
is the yscale factor
0 is the rotation angle.
-
Go watch TV.... worry about this booger tomorrow.
but thanks for everyones help... I appreciate it!
-
it pulls in the dwg... I just can not get the script to place it automatically... I have the speicify the place and scale....
thats all
-
lol - i know why this is frusterating... I AM NEW! grhh...
Hey, don't worry about it! We're not! :)
CHT is what I use(d to use for find and replace... Don't think the Find and Replace thing Acad has now works at the command line). When you type CHT, what do you see? What are your options?
It's a little tougher for me right now, 'cause I'm at home without AutoCAD...
-
MSTG, check the edit to my last post. I still have 15 minutes before I get to leave work.
-
You're too quick, Bob! :)
-
It's a little tougher for me right now, 'cause I'm at home without AutoCAD...
I'm never without AutoCAD, it lives inside my head.
-
trying it right now....
its loading....
and 3 2 1
?????
DesktopProfile\detail.scr"
Command: -STYLE
Enter name of text style or [?] <L175>: L175
Existing style. Full font name = Arial
Specify full font name or font filename (TTF or SHX) <ARIAL.TTF>: ARIAL.TTF
Specify height of text <0.2000>: .2
Specify width factor <1.0000>:
Specify obliquing angle <0d0'0">:
Display text backwards? [Yes/No] <N>:
Display text upside-down? [Yes/No] <N>:
"L175" is now the current text style.
Command: chtXT
Searching BLOCKS for Text..........
Searching ENTITIES for Text
CHBTX Cancelled.
Thanks for Using CHTXT!
Command:
CHTXT
Searching BLOCKS for Text..........
Searching ENTITIES for Text
CHBTX Cancelled.
Thanks for Using CHTXT!
Command:
CHTXT
Searching BLOCKS for Text..........
Searching ENTITIES for Text
CHBTX Cancelled.
Thanks for Using CHTXT!
Command: SPELL
Select objects: ALL
33 found
Select objects:
Command: insert
Enter block name or [?]: watermark
Units: Feet Conversion: 12.0000
Specify insertion point or
[Basepoint/Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]: 0,0,0
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1
Enter Y scale factor <use X scale factor>:
Specify rotation angle <0d0'0">: 0
Command:
INSERT Enter block name or [?] <watermark>:
Units: Feet Conversion: 12.0000
Specify insertion point or
[Basepoint/Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]: -plot
Point or option keyword required.
Specify insertion point or
[Basepoint/Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]: *Cancel*
-
It's a little tougher for me right now, 'cause I'm at home without AutoCAD...
I'm never without AutoCAD, it lives inside my head.
Where does it store all of those error logs? ;)
never mind...
keyword: dmp
-
I remember two different lisp routines that were very close. There's a CHTXT and a CHTEXT. Looks like you've got a different one than I'm used to. We might have to revisit this tomorrow...
-
OK, first you are definitely using a different lisp than I am talking about. Shoot me an email to bob.wahr at gmail.com and we can further discuss ways that this can be solved (shhh, i'll email it)
with the insert, now you have two extra enters in there. The first is firning the command again, the second is saying to use the default block name. Kepp in mind that when you are doing scripts except in very rare circumstances, AutoCAD uses a space as an enter.
-
Is it just me, or is this whole thing just screaming for a lispy solution? (http://www.theswamp.org/Smileys/other/undecided.gif)
-
I don't think so, Randy. He's almost there!
-
I don't think so, Randy. He's almost there!
Well maybe so, but even when he does get "there" he still has, what is in my opinion, a cumbersome script file. I think a startup lisp solution would run considerably cleaner and probably faster. But then again maybe that's just me.
-
Randy, I'm basing what I'm giving him off of
lol - i know why this is frusterating... I AM NEW! grhh...
If a lisp/vba solution is provided, nothing will really be learned although the drawings will get done. This way, I think that there is some learning happening. Personally, I would rather understand a passable method than be handed a perfect method that I don't understand.
-
Randy, I'm basing what I'm giving him off of
lol - i know why this is frusterating... I AM NEW! grhh...
If a lisp/vba solution is provided, nothing will really be learned although the drawings will get done. This way, I think that there is some learning happening. Personally, I would rather understand a passable method than be handed a perfect method that I don't understand.
Oh no, I didn't mean give it to him, (see HERE (http://www.theswamp.org/index.php?topic=2621.msg33156#msg33156)), but walk him through the lisp process just like you guys are doing with the script.
-
Here is a sample of what we have.