Está en la página 1de 4

HO ME

SITE MAP

ABO UT

NEW SLETTER

CO NTACT

User Name

Password

Log in

Help

Register

Remember Me?

Tutorials

Michaels Corner

Forum

W hat's New ?

Links

Dow nload Advanced Search

Today's Posts FAQ Calendar ForumActions

Quick Links

Forum

AutoCAD Customization

Application Archive

How to use the LISP routines in this archive

VB.NET for AutoCAD Books, Training, and Consulting for AutoCAD and VB.NET www.vbcad.com Autodesk 3D Mech Design Go beyond 3D design to digital prototyping with Autodesk Inventor www.3eos.com Inventor 3D Manufacturing Optimize your CAD investment Autodesk Manufacturing Specialist www.tatatechnologies.com/autodesk

Welcome to the CADTutor forums, probably the most lively and friendly AutoCAD forums on the w eb. You w ill need to register in order to post a question and to see all the content on this board. See How to register for details. Use the Lost password recovery form if you ever forget either your passw ord or username. Be sure to check out the FAQ for more information.

+ Reply to Thread

Results 1 to 3 of 3

Thread: How to use the LISP routines in this archive


Thread Tools

5th May 2004 10:31 am

#1

CADTutor
Administrator

How to use the LISP routines in this archive

How to use the LISP routines in this archive


Computer Details Using: AutoCAD 2012 Join Date: Aug 2002 Location: Hampshire, UK Posts: 3,424

All of the lisp code posted on this bulletin board may be run on your own installation of AutoCAD. The basic process is pretty simple and is set out below. There are 3 main steps, creating the lisp file, loading the lisp file and running the lisp routine. Note: AutoLISP routines will only run on full versions of AutoCAD, they will not run on AutoCAD LT.

Creating the lisp file


Copy and paste all of the text in the Code: box into Windows Notepad. Take care not to miss anything out. Below is an example: Code:
Registered forum members do not see this ad.

(defun c:zone ( / ss la rv i tv op en ) (while (not ss) (princ "\nPick any object o n the required layer") (setq ss (ssget))) (initget "Length Area") (setq rv (getkword "\nWould you li ke to measure Length/<Area> : ")) (and (not rv) (setq rv "Area")) (setq la (cdr (assoc 8 (entget (ss name ss 0)))) ss (ssget "X" (list (cons 0 "*POLYLINE") (cons 8 la))) i (sslength ss) tv 0 op 0) (while (not (minusp (setq i (1- i) ))) (setq en (ssname ss i)) (command "_.AREA" "_E" en) When you have (cond ((= code into Notepad, you pasted the rv "Length")
converted by Web2PDFConvert.com

should have something like this:

You must now save the file. You can call it whatever you like as long as it has a .LSP file extension but it is always a good idea to give the file the same name at the lisp routine to avoid confusion. You will always find the name of the routine preceded with a c: at the beginning of the code. In the example above, you will see that that the routine is called "zone". So, in this case, the file should be saved as zone.lsp.

Loading the lisp file


Next, open AutoCAD and select Tools AutoLISP Load... from the pull-down menu. You will see the dialogue box shown below:

Use the following sequence to load zone.lsp: 1. Navigate to the folder where you saved the lisp file. 2. Select the file you want from the list. 3. Click the Load button. If all went well, you will see a message saying "zone.lsp successfully loaded". 4. Click the Close button to close the dialogue box.

Running the lisp routine


Once the lisp file is loaded, you can run the routine from the command line. The routine is run simply by entering its name. In this example, enter zone at the command line. Remember, the routine name is the bit following the c: near the beginning of the code. Tip: You may also load the lisp file by dragging-and-

converted by Web2PDFConvert.com

dropping the file icon onto the AutoCAD drawing area.


Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner. AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ

Reply With Quote

14th Jul 2009 04:48 pm

#2

Lee Mac
Quantum Mechanic

Additional Loading Instructions


In addition to the above advice, there are a few other filetypes to be aware of when delving into the world of LISP programming.

Computer Details Using: AutoCAD 2010 Join Date: Aug 2008 Location: London, England Posts: 12,792

VLX/FAS Files
You may discover that some programs are posted in the form of either a .VLX or .FAS file. These are programs that have been compiled into one file to make them not only easier to load (with only one file to deal with), but also more secure as far as code protection is concerned. To load a .VLX or .FAS file, just save the file to a known location, and follow the instructions in the above post, as if you were dealing with a LISP file. Of course, the syntax to invoke the function is not readily available, but may be either provided by the program developer, or appear at the command line upon loading the file.

DCL Files
DCL (Dialog Control Language) gives the user the ability to create dialog boxes with relative ease. These files run in conjunction with LISP files, and may be compiled with the relevant LISP file into a VLX or FAS file. DCL language looks like this: Code:

// Increment Numerical Text Sign Selector adder : dialog { label = "Specify Increment Direction"; : text { label = ""; key = "sel_text"; alignment = centered; } : row { : button { label = "+1"; key = "sel_add"; fixed_width = true; mnem onic = "+"; } : button { label = "-1"; key = "sel_sub"; fixed_width = true; mnem onic = "-"; } } // row ok_only; } // dialog

To run a program that uses a DCL file, save the provided DCL file into your AutoCAD Search Path. The AutoCAD Search Path is normally found: C:\Program Files\AutoCAD <version>\Support\ But additonal Search Path locations may be added by going to: Tools > Options > Files (tab) > Support File Search Path And adding a new filepath. The LISP file associated with the DCL file can be loaded and run as normal, using the instructions provided in the above post. If you are still puzzled, search the forums, or our FAQ for more information.

Lee Mac Programming


With Mathematics there is the possibility of perfect rigour, so why se le for less? Just another Swamper
Reply With Quote

5th Jul 2010 02:57 pm

#3

Lee Mac
Quantum Mechanic

converted by Web2PDFConvert.com

Quantum Mechanic

"Error: No Function Definition vlax-get-acad-object"


If you find yourself receiving this error or a similar error message, check that (vl-load-com) is present near the top of the LISP code you are trying to run.

Computer Details Using: AutoCAD 2010 Join Date: Aug 2008 Location: London, England Posts: 12,792

The error normally occurs because the Visual LISP functions that many developers use need to be loaded before use. Many users will have (vl-load-com) in their ACADDOC.lsp/ACAD.lsp files so that it may be loaded on startup; hence, when testing code, a developer may not notice the omission of (vl-load-com).

Example:
Code missing (vl-load-com) : Code:

(defun c:test ( / acapp ) (setq acapp (vlax-get-acad-object)) (vlax-release-object acapp) (princ) )

Corrected: Code:

(defun c:test ( / acapp )


(vl-load-com)

(setq acapp (vlax-get-acad-object)) (vlax-release-object acapp) (princ) )

If you are still stuck, search the forums/FAQ for more help.

Lee Mac Programming


With Mathematics there is the possibility of perfect rigour, so why se le for less? Just another Swamper
Reply With Quote

+ Reply to Thread
Previous Thread | Next Thread
Bookmarks Posting Permissions

Quick Navigation

Application Archive Top

Digg del.icio.us StumbleUpon Google

You may not post new threads You may not post replies You may not post attachments You may not edit your posts

BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

Ads by Google

AutoCAD

Auto CAD Lisp

AutoCAD LT 2011

CAD Tutorials

Contact Us CADTutor Home Archive Top


C onceived, created and cared for by David Watson 19962011 All times are GMT +1. The time now is 04:11 pm. Powered by vBulletin Version 4.1.2 Copyright 2011 vBulletin Solutions, Inc. All rights reserved.

converted by Web2PDFConvert.com

También podría gustarte