AutoCAD/Menu/Toolbar customization
Expert: Bill DeShawn - 8/4/2008
QuestionQUESTION: First, thank you for taking the time to read my question. I am an electrical designer for a small engineering company. I am trying to customize some menu's and toolbars/flyouts/pulldowns. We have started a new contract with a client that is based very strictly on NCS. Because my office hasn't done any NCS work, we are having a little trouble. We currently have a system in place that a previous employee customized with toolbar buttons and menus. I am very new to the programming (about 3 weeks of research and trial and error). My goal is to create some menus and toolbars that will retrieve blocks that we create based on NCS and import them into our drawings scaled and on the correct layer. I have tried to base what I am writing on what we currently have but I have had no success. I will include an example of what one current menu is and one toolbar. I will also give you an example of what I have tried and I hope that you may be able to provide some insight as to what I am doing wrong.
If this is way too detailed I understand and I apologize for taking your time. If you can help me, I thank you in advance.
Example of current Menu (excerpt)
//
// AutoCAD menu file - C:\ACAD Standards\Elec Standards\Support\GEN_ELEC.mnc
//
***MENUGROUP=GEN_ELEC
***POP3
**LIGHTING
ID_LIGHTING [Lighting]
[ Lighting]
[--]
[->Lighting ]
[ Lighting]
[--]
ELC2X4H [2x4 Horizontal ]^C^C-INSERT;(strcat ELPATH "EL-C2X4H");\;;;(if (/= 1.0 (getvar "dimscale"))(command "SCALETEXT" "L" "" "E" (/ (GETVAR "DIMSCALE") 12)));LC;EL-CLG;L;;
Example of toolbar corresponding do menu.
^C^CII;;EL-C2X4H;
When clicking on this toolbar button, it imports a 2x4 light fixture with corresponding attributes and changes to the correct layer.
I have based the menu of what I am trying to create exactly to what I have provided here to you with the exception of changing the name of the block. for some reason I am being told when clicking on the toolbar that I create that it cannot be found.
Any ideas????
Thanks again for your time and patience and again, if thiss is too detailed a question for this forum I understand as I do not wish to take anyone's valuable time from more important things.
-Nick
ANSWER: Nick:
One that comes to mind is that (strcat is referring to a symbol which I do not see defined anywhere. That symbol is ELPATH. Why not include the path to the block in your Support File Search Path and exclude the (strcat ELPATH so that it looks like this:
^C^C-INSERT;"EL-C2X4H";\;;;(if (/= 1.0 (getvar "dimscale"))(command "SCALETEXT" "L" "" "E" (/ (GETVAR "DIMSCALE") 12)));
I am assuming that the block contains attributes. SCALETEXT will find those attributes and change the height of the text therein.
Keep the dialog going it we haven't fixed the problem.
Bill DeShawn
http://my.sterling.net/~bdeshawn
---------- FOLLOW-UP ----------
QUESTION: Thanks for the quick response. To add a little bit more information that may have been helpful. 'ELPATH' is actually a path not a symbol. It is referencing 'Electrical Lighting' in a directory. To be more precise when using !ELPATH
"C:/ACAD Standards/Elec Standards/Blocks/Lighting/"
is returned
I think to specify my question a little bit:
I create a block (2x4emer), I put said block into
Z:\Standards\Verizon Wireless\VZW NCS TEMPLATE (created by Precis)\Blocks
I need this block with attributes to be inserted into my drawing scaled (only text as the 2x4 fixture is drawn 1:1 of course) and I need this block to be inserted on Layer E-LITE-EMER with text on Layer E-LITE-TEXT.
I hope this maybe clears up the ELPATH. I wonder if this would be easiest to create only a toolbar/flyout without actually making a new menu? I know (very obviously) that I have a long way and many months/years to go before becoming competent in the language of programming. I am trying vigorously to learn in every way that I can as these skills can help to set me apart in an office that has me surrounded by four year degrees. (I do not have a degree as you may have already guessed, however I am no slacker when it comes to working and doing what it takes to stand out.)
If this is a better explanation of what I am trying to do great. If I confused your first response or you need more, please just let me know I/we can move on from there to figure the best solution.
Again, thank you for your time.
AnswerNick. A symbol in LISP is a variable. The way I read it in the AutoLISP Programming book is that the two are synonymous. In the expression: (strcat ELPATH "EL-C2X4H") ELPATH is a symbol that if AutoCAD knows what the symbol represents, it will return exactly what it stands for. STRCAT (string concatenate) is looking for a series of strings (which are ALWAYS is quotes). If AutoCAD knows what ELPATH is it will allow strcat to evaluate the symbol. If it is indeed a string, then AutoCAD will attach it to the other string in the expression: "EL-C2x4H". One way to test for the validity of the symbol at the command line, is to type an exclamation point and then the symbol name.: !ELPATH AutoCAD will return the value associated with the symbol name. If AutoCAD doesn't know what the symbol represents, it will return nil. The code in your macro can't tell where ELPATH is. There is another piece to the puzzle. It might even be in ACAD.LSP or ACADDOC200?.lsp (the question mark represents the missing character that will complete the correct name of the file. If not one of those two files, perhaps in ACAD.MNL or some other LISP file. But somewhere, somehow, ELPATH is defined as a string. You can find it by searching LISP file contents with a tool like Agent Ransack or SearchWithin. Look for something like (setq ELPATH "C:SOMEFOLDERSOMESUBFOLDER"). It could also be written like this: (setq ELPATH "C:/SOMEFOLDER/SOMESUBFOLDER/"). Just search for:
setq ELPATH
A single or double backslash won't work in a menu macro. So AutoLISP let you put in the forward slash in the path string just for that reason. If drawing "EL-C2X4H" resides in "C:/SOMEFOLDER/SOMESUBFOLDER", AutoCAD will find it and insert it.
If you know where ELPATH is, you can add it to the macro right after ^C^C thus:
(setq elpath "X:/FOLDER1/FOLDER2/");
Be sure to include the quotes. It needs to be in quotes as all (command) arguments are strings. Add the semicolon between AutoLISP expressions which will be seen as an <ENTER> by AutoCAD.
As you put it: You are trying "vigorously" to learn the skills. Please read these instructions carefully. I can see by your description of the problem that AutoCAD can't find the drawing file of the name in the macro. This information within this message will help you resolve that problem. Stay with me and lets work on this problem and get it solved.
Bill DeShawn
http://my.sterling.net/~bdeshawn