Getting Started with Visual LISP
 
 
 

Now that you've seen how the application is supposed to work, you can begin developing it with VLISP. But first, it helps to demonstrate what can happen when VLISP is waiting for control to return from AutoCAD. You may have already encountered this.

To see Visual LISP wait for control to return from AutoCAD

  1. From the AutoCAD Tools menu, choose Load Application.
  2. Select gardenpath.vlx from the Tutorial\VisualLISP directory, and choose Load.
  3. Choose Close.
  4. At the AutoCAD Command prompt, enter vlisp to start Visual LISP.
  5. Switch back to the AutoCAD window (either select AutoCAD from the taskbar or press ALT + TAB and choose AutoCAD), and enter gpath at the AutoCAD Command prompt.
  6. Before responding to the prompts from gpath, switch back to the VLISP window.

    In the VLISP window, the mouse pointer appears as a VLISP symbol, and you cannot choose any commands or enter text anywhere in the VLISP window. The pointer symbol is a reminder that there is an activity you must complete in AutoCAD before resuming work with VLISP. Remember this whenever you see the VLISP pointer.

  7. Return to the AutoCAD window and respond to all the prompts from gpath.

Now you are ready to begin building the garden path application.

To begin application development with Visual LISP

  1. From the VLISP File menu, choose New File.

  2. Enter the following code in the text editor window (it is the window titled “<Untitled-0>”); you can omit the comments, if you wish:
    ;;; Function C:GPath is the main program function and defines the 
    
    ;;; AutoCAD GPATH command.
    
    (defun C:GPath ()
    
      ;; Ask the user for input: first for path location and
    
      ;; direction, then for path parameters. Continue only if you have
    
      ;; valid input.
    
      (if (gp:getPointInput)	; 
    
    	(if (gp:getDialogInput)
    
    	(progn
    
    		;; At this point, you have valid input from the user.
    
    		;; Draw the outline, storing the resulting polyline 
    
    		;; "pointer" in the variable called PolylineName.
    
    		(setq PolylineName (gp:drawOutline))
    
    		(princ "\nThe gp:drawOutline function returned <")
    
    		(princ PolylineName)
    
    		(princ ">")
    
    		(Alert "Congratulations - your program is complete!")
    
    	)
    
    	(princ "\nFunction cancelled.")
    
       )
    
       (princ "\nIncomplete information to draw a boundary.")
    
      )
    
      (princ)  ; exit quietly
    
    )
    
    ;;; Display a message to let the user know the command name.
    
    (princ "\nType gpath to draw a garden path.")
    
    (princ)
    
  3. Choose File Save As from the menu, and save the code in the new file as <AutoCAD directory>\Tutorial\VisualLISP\MyPath\gpmain.lsp.
  4. Review your work.