PDA

View Full Version : Drop a simple line of text on the command prompt


ahefner
2007-06-20, 02:49 PM
I'm working on automating some of our drawings and everything is working great, I just want to drop the following line of text on the command prompt.

NOW EDIT THE BHB PROJECT NUMBER

In one of my lisps I use, it's formatted like this:
(PRINC "n-> NOW EDIT THE BHB PROJECT NUMBER") But I can't get this to work.

Another way to get around this is to make the "BHB Project Number" automated which I haven't figured out how to do yet. Maybe someone out there knows how to help me with this and I can forget the "dropping a line of text on the command prompt".

Our Network directories are as follows... E:\2007.000.000\2007.012.xxx\2007.012.075
The last folder is where the drawings are located and it's also the project number. I'm needing just the last string of text (2007.012.075) without the forward slashes. Is there a way to access the folder name maybe through a field or a lisp? In the fields I have the option of "FileName", but it lists the entire path, not just the last folder.

jaberwok
2007-06-20, 02:56 PM
I'm working on automating some of our drawings and everything is working great, I just want to drop the following line of text on the command prompt.

NOW EDIT THE BHB PROJECT NUMBER

In one of my lisps I use, it's formatted like this:[code]
(PRINC "\n-> NOW EDIT THE BHB PROJECT NUMBER")[code] But I can't get this to work.

Another way to get around this is to make the "BHB Project Number" automated which I haven't figured out how to do yet. Maybe someone out there knows how to help me with this and I can forget the "dropping a line of text on the command prompt".

Our Network directories are as follows... E:\2007.000.000\2007.012.xxx\2007.012.075\
The last folder is where the drawings are located and it's also the project number. I'm needing just the last string of text (2007.012.075) without the forward slashes. Is there a way to access the folder name maybe through a field or a lisp? In the fields I have the option of "FileName", but it lists the entire path, not just the last folder.

In the lisp, should you be using the "prompt" option with a "getxxx" function?

ahefner
2007-06-20, 02:58 PM
I have no idea. I know VERY little about lisps.

Opie
2007-06-21, 12:25 AM
Here is a small bit of code to extract the last folder from the specified folder.
(defun lastfolder (path /)
(setq folder (substr path 1 (1- (strlen path))))
(while (vl-string-search (chr 47) folder)
(setq folder (vl-string-subst (chr 92) (chr 47) folder))
)
(setq folder (substr folder (+ 2 (vl-string-position 92 folder 2 T))))
)
You will need to save this function to a file with a .lsp extension. You may even save it within your ACADDOC.LSP file if you have one. If you do not have one you could create it within a folder that is listed in your support path folder list.

You would then call this function in this fashion.
(lastfolder foldername)
Replace the foldername above with your desired folder. Remember to place the name within quotes (").

To get the folder the drawing is located in, use the following.
(lastfolder (getvar "dwgprefix"))
Your original request did not specify how you would actually use this. If you could elaborate a bit, someone here may be able to help you a little bit more.

ahefner
2007-06-21, 12:43 AM
I'm wanting something along the lines of a field which will read only the current folder name, not the entire path, so I can use that as my text (Ex: the current path is E:\2007.000.000\2007.012.xxx\2007.012.075\ and I want only the 2007.012.075)

The current folder name is my project number which I need to put onto the drawing (it's within our logo. Currently as MTEXT which we edit every time). I wanting something that'll automatcially read the current folder name and display that as my text.

Opie
2007-06-21, 05:32 AM
I do not remember if 2006 allows you to place an AutoLISP variable into a text field. I'll have to look into it tomorrow at work if I have time. I do know that AutoCAD 2008 does allow an AutoLISP variable to be placed in a text field. You could run that command upon drawing startup to set the variable.

Also, is this MTEXT part of a block?

The code I posted earlier will require (vl-load-com) be executed first. Otherwise the code will error out and not provide you with the results you are expecting.

ahefner
2007-07-17, 04:47 PM
I do not remember if 2006 allows you to place an AutoLISP variable into a text field. I'll have to look into it tomorrow at work if I have time. I do know that AutoCAD 2008 does allow an AutoLISP variable to be placed in a text field. You could run that command upon drawing startup to set the variable.

Also, is this MTEXT part of a block?

The code I posted earlier will require (vl-load-com) be executed first. Otherwise the code will error out and not provide you with the results you are expecting.

The text can be within the block, or exploded, or an attribute or whatever it needs to be to work ;).

I have no idea if or how to place an AutoLisp variable into a text field.

And what is vl-load-com and how do I executed it?

(thanks for the help btw)

Sorry for taking so long to get back to you, I'm not receiving the e-mail notifications.