Passing Pick Points to AutoCAD Commands
 
 
 

Some AutoCAD commands (such as TRIM, EXTEND, and FILLET) require the user to specify a pick point as well as the object itself. To pass such pairs of object and point data by means of the command function without the use of a PAUSE, you must first store them as variables. Points can be passed as strings within the command function or can be defined outside the function and passed as variables, as shown in the following example. This code fragment shows one method of passing an entity name and a pick point to the command function.

(command "circle" "5,5" "2")		Draws
circle
(command "line" "3,5" "7,5" "")	 Draws
line
(setq el  (entlast))				Gets
last entity name
(setq pt  '(5 7))				 Sets point pt
(command "trim" el "" pt "")		Performs
trim

If AutoCAD is at the Command prompt when these functions are called, AutoCAD performs the following actions:

  1. Draws a circle centered at (5,5) with a radius of 2.
  2. Draws a line from (3,5) to (7,5).
  3. Creates a variable el that is the name of the last object added to the database. (See Using AutoLISP to Manipulate AutoCAD Objects for more discussion of objects and object-handling functions.)
  4. Creates a pt variable that is a point on the circle. (This point selects the portion of the circle to be trimmed.)
  5. Performs the TRIM command by selecting the el object and by selecting the point specified by pt.