Jump to content

Recommended Posts

Posted

I have an assignment to write a "simple' menu file that has a script and a lisp file embedded/referenced in it. I'm not sure how to do this. I can write a .mnu file and load it in using the cuiload command. I can write a script and load it using the script command and likewise I can write a lisp routine and load that. How do I begin to go about combining all three in one program? Would it all be a .mnu file?

Posted

You could write an "MNU" file assuming you know the syntax, or you could create a new .CUIX file using the CUI editor.

Either way, you can call a lisp file using a macro like this:

 

^C^C(if (not c:myfun)(load "C:\\cadstuff\\mylispfile"));myfun;

 

...where "mylispfile.lsp" is the name of the file, "C:\cadstuff" is where it's located, and "myfun" is the name of the function.

 

To call a script file, you could do use a macro like this:

 

^C^Cscript;myscript;

 

...where "myscript" is the name of the script file and assuming that it's in the support file search path.

Posted

Just a query RK ... isn't it preferable to use the forward slash "/" instead of a double-backslash "\\" when making macros? It's just that the backslash inside macros usually means "Pause for user input". I know yours would still work as the backslashes are contained inside the lisp brackets, but if you had to specify the path to the script file, it would pause for some user entry, thus is should rather be:

^C^Cscript;"C:/cadstuff/myscript";

Posted
Just a query RK ... isn't it preferable to use the forward slash "/" instead of a double-backslash "\\" when making macros? It's just that the backslash inside macros usually means "Pause for user input". I know yours would still work as the backslashes are contained inside the lisp brackets, but if you had to specify the path to the script file, it would pause for some user entry, thus is should rather be:
^C^Cscript;"C:/cadstuff/myscript";

 

Good catch. I didn't test it and I do recall running into this issue in the past.

Thanks. :-)

Posted

Actually, it is not working. I got the script part to work, but not the lisp. We have only barely scratched each section of writing menus scripts and lisps, so I'm not real good yet. For lisps we have only written very simple ones such as drawing a triangle by getting three points and then using the line command. We haven't touched on other items like if, then, and the multitude of other ways to write lisps. I have been spending a lot of time reviewing online info so I am starting to understand it (but overwhelmed!).

 

With that in mind, it seems like I should be able to write a menu file to load a simple lisp. Like this:

 

This is my lisp that works as a stand-alone lisp; saved as csotriangle.lsp:

(defun c:TRIANG1()

(setq P1 (getpoint"\n Enter first point of Triangle:"))

(setq P2 (getpoint"\n Enter second point of Triangle:"))

(setq P3 (getpoint"\n Enter third point of Triangle:"))

(Command "LINE" P1 P2 P3 "C")

)

 

 

I saved the csotriangle.lsp in the support file path of AutoCAD.

Now if I want to call this up using a menu file (.mnu), it seems like I should be able to do something like this:

 

***POP1

[LISP FRM MENUcso]

[DRAW TRIANGLE]^C^Cload; csotriangle.lsp; TRIANG1

[--]

[EXIT]^C

I’m not sure of the syntax; should I be using parenthesis, etc?; do I have to have conditional statements and/or the file path as part of the program?

Also, it seems that some of the information out there mentions .mnl and .mns extensions. In one example they saved a menu routine as example5.mnu.mns, and loaded it with both extensions and I'm not sure why that was done. Thanks for your help.

Posted

Actually your macro / script should just load the lisp file through a lisp call:

^C^C(load "csotriabgle");TRIANG1

The LOAD command your code was using is the load for a SHX shape file.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...