Author Topic: LT Challenge . . .  (Read 19774 times)

0 Members and 2 Guests are viewing this topic.

M-dub

  • Guest
Re: LT Challenge . . .
« Reply #30 on: March 23, 2009, 08:39:59 PM »
Since my scripts are usually being done for dozens ( +/- ), I usually start with a directory listing.  I bring that into Excel and can use the info from the dir list.  The paths and filenames are used for a multitude of things.  In this case, your dxf and the dwg.

Now, rugrat #2 and 'The Governor' are calling me....


Dinosaur

  • Guest
Re: LT Challenge . . .
« Reply #31 on: March 25, 2009, 09:12:37 AM »
I am failing miserably at this on my own.  It seems inserting the DXF will be the best approach  but I have no idea what that would look like in either a script or macro form on a button.  It appears form help that a script is not able to call a command with a dialog box, is that true for button macros as well?

M-dub

  • Guest
Re: LT Challenge . . .
« Reply #32 on: March 25, 2009, 09:17:34 AM »
Without even having AutoCAD open, could you tell which DXF is to be inserted into which DWG?
If so, you're golden.

Just to give you a hint, type -Insert at the command line and it will suppress the dialog box.

In Scripts and Macros, it's sometimes a good idea to set FILEDIA and CMDDIA to zero to suppress these boxes.  Just gotta remember to turn 'em on at the end of the script when you're done.

M-dub

  • Guest
Re: LT Challenge . . .
« Reply #33 on: March 25, 2009, 09:55:28 AM »
You might find something useful in this old post of mine.

I use Find & Replace text quite often and I think we touched on this in the other forum.  I use Excel to create my scripts.  I don't know if anyone else does, but that's just the way I thought would work best for me.  The reason is because when I use Directory Printer to export directory contents to a csv file, it obviously opens in Excel.
  From there, I get rid of the info I don't need, so I'm left with the Path and the files all in column A.
  I then move all of the filenames to column B and copy the path all the way down column A to the last file in column B.  Before doing this, I'll usually FIND C:\Drawings\Path and replace it with Open C:\Drawings\Path.
  Then, in column C, I put in as much of my script as possible (sometimes, more than one is required).  Something simple would be Zoom Extents qsave close.  *One thing to note is that normally, a space acts as an ENTER (which I'm sure the majority of you already figured out ;)) except after the close command, there is no space required.  Actually, if you put the space in, it won't work at all!  I don't know why, but it took a great deal of trial and error to figure this out.
   After this is done and it has been copied down to the last filename, go up to cell D-1 and enter the concatenate function, which would be =CONCATENATE(A1,B1,C1)
   You then fill the series...down to the last filename.  Now, highlight all of column D and copy it to the clipboard (ctrl+c or right click).  Right click on Cell A-1 and select Paste Special.  In the following dialog box, select Values and hit ok.
   You're done...just highlight Columns B thru D (or wherever you ended up) and delete them.
   Save the file as a text file "Text (OS/2 or MS-DOS) (*.txt)"
   Once it's saved, rename it to *.scr and you should be ready to rock and roll.

Shinyhead

  • Guest
Re: LT Challenge . . .
« Reply #34 on: March 25, 2009, 11:52:20 AM »
I am failing miserably at this on my own.  It seems inserting the DXF will be the best approach  but I have no idea what that would look like in either a script or macro form on a button.  It appears form help that a script is not able to call a command with a dialog box, is that true for button macros as well?

Here are the rules on that sort of thing

macros can use diesel, this allows a certain amount of programming at the macro level.

a script cannot use diesel, the command line interpeter wont work with it when coming from a script.

with both of these, if the command causes a dialog box to open they end and no further automatic action will occur from the macro or script.

filedia=0 (filedia;0; in a macro) will turn any file select dialog box to the command line.

cmddia=0 (cmddia;0; in a macro) will turn off any dialog box that has a command line version.  Some things, like filter, publish, etc do not have a command line version so it won't always help.

Some tricks on macros, use user variables with setenv (SETENV;useri1;23; will set useri1 to 23)
useri1-5 (integers) and userr1-5 (real number) variables (1-5 are available for each) will stay set in a drawing when saved/closed. 
users1-5 (strings) will only last for the current session.
retrieve the values with diesel, for example $m=$(getENV,users1) will return the value of useri1 (in this case 23). Retrieving this way will only work in a macro and not a script because it uses diesel (the $m= tells the command line interpeter that what follows is a diesel statement).

Thats a lot in a short bit and there is a lot more, but I hope it helps.


M-dub

  • Guest
Re: LT Challenge . . .
« Reply #35 on: April 02, 2009, 12:35:17 PM »
Try this one and see what happens...
^C^C-I;\0,0;;;;EXPLODE;L;-PU;B;;;N;Z;E;PS;-VPORTS;L;ON;ALL;;SAVEAS;2000;;Y;FILEDIA;1;

Dinosaur

  • Guest
Re: LT Challenge . . .
« Reply #36 on: April 02, 2009, 12:59:29 PM »
Try this one and see what happens...
^C^C-I;\0,0;;;;EXPLODE;L;-PU;B;;;N;Z;E;PS;-VPORTS;L;ON;ALL;;SAVEAS;2000;;Y;FILEDIA;1;
Thanks Mdub
This works well as the button macro - unless I have spaces in the file name.  Is there any way around that?
I am also trying to make a script doing the same functions as the macro.  It is being far less cooperative.  In response to the "-INSERT" command, I see this in my text window
Quote
Enter block name or [?]: \0,0
Warning: If you are trying to insert the file: 0,0
it must be inserted using the <block>=<filename> syntax.
How would one best get over this hurdle?

M-dub

  • Guest
Re: LT Challenge . . .
« Reply #37 on: April 02, 2009, 01:03:02 PM »
Try this one and see what happens...
^C^C-I;\0,0;;;;EXPLODE;L;-PU;B;;;N;Z;E;PS;-VPORTS;L;ON;ALL;;SAVEAS;2000;;Y;FILEDIA;1;
Thanks Mdub
This works well as the button macro - unless I have spaces in the file name.  Is there any way around that?
When you go to enter the block name, try using quotes around it... "Block Name"

Gimme a bit on the other part of your question.  I have an idea, but have to work on it.

M-dub

  • Guest
Re: LT Challenge . . .
« Reply #38 on: April 02, 2009, 01:16:15 PM »
Oh yeah...

For the script, try replacing this > -I;\
with this:
filedia
0
-insert
"C:\pathname\block name.dwg"



Someone correct me if I'm wrong, but I think you have to hard code the filenames and paths in... (You can't call dialog boxes and select files)

Spike Wilbury

  • Guest
Re: LT Challenge . . .
« Reply #39 on: April 02, 2009, 01:24:35 PM »
Oh yeah...

For the script, try replacing this > -I;\
with this:
filedia
0
-insert
"C:\pathname\block name.dwg"



Someone correct me if I'm wrong, but I think you have to hard code the filenames and paths in... (You can't call dialog boxes and select files)

totally forgot.... but guess was a tilde ~

for the filenames, there is a little app that I did... ShortLongPathName.exe somewhere around here - that convert the filename to the appropriate format.

see if helps...

Dinosaur

  • Guest
Re: LT Challenge . . .
« Reply #40 on: April 02, 2009, 01:34:05 PM »
Oh yeah...

For the script, try replacing this > -I;\
with this:
filedia
0
-insert
"C:\pathname\block name.dwg"



Someone correct me if I'm wrong, but I think you have to hard code the filenames and paths in... (You can't call dialog boxes and select files)

That restriction may toss the idea of a script for good ... the pathing to where this will take place will be variable as will the DXF names.  Hard coding those will require a different script for each drawing.

M-dub

  • Guest
Re: LT Challenge . . .
« Reply #41 on: April 02, 2009, 01:40:35 PM »
Hard coding those will require a different script for each drawing.

If I were you, I wouldn't even be bothering with a script if you're only dealing with one or two drawings at a time.  A script would be better suited for an entire project.

If it takes just as long to write the script as it would to do the work manually, then ... it's up to you.

I sent you an .xls that might help with the creation of the script.  Have you had a chance to look at it at all?

Dinosaur

  • Guest
Re: LT Challenge . . .
« Reply #42 on: April 02, 2009, 01:57:52 PM »
That giant "THUD" you heard was the idea of a batch file running a start up script for this project.  An elegant idea defeated by its simplicity and some orneryness on the part of AutoCAD scripts ... at least the macro works for the exploded option.  It looks like I can even call up a dialog box for file selection if I choose that route.
The next hurdle is the unexploded option that will let the user update the drawing with a new DXF.  The first time through should be golden but what happens when the macro finds the existing block with the same name?  Can that event be handled within the same script or will it require a new one?

Dinosaur

  • Guest
Re: LT Challenge . . .
« Reply #43 on: April 03, 2009, 11:00:14 PM »
totally forgot.... but guess was a tilde ~

for the filenames, there is a little app that I did... ShortLongPathName.exe somewhere around here - that convert the filename to the appropriate format.

see if helps...
Thanks Luis, I found the little app and it should be help.  Many times on projects with a single sheet, the file name winds up being the project name (including the company name and location.  The path names may be more trouble unless some discipline can be instilled ... there are currently 9 different people doing things about 10 different ways.

Chris, diesel is another one of those things I heard about 15 years ago and poked at only once or twice and promptly forgot about after drifting into the vertical apps.  Is there anything in THAT bag of tricks that may point in a different direction to take this little project?

Bob

  • Guest
Re: LT Challenge . . .
« Reply #44 on: April 10, 2009, 03:32:09 AM »
Would 'paste special>autocad entities' help at all?

It works with some applications