アプリケーションがどのように動作するかを確認しましたが、それを Visual LISP で開発することができます。しかしその前に、Visual LISP が AutoCAD からコントロールが戻るまで待機しているときに何が起こるかを実験してみましょう。既に、体験された方もいらっしゃることでしょう。
をクリックします。
Visual LISP ウィンドウでは、マウス ポインタは Visual LISP のアイコンとして表示され、どのコマンドも選択できず、Visual LISP ウィンドウのどこにもテキストを入力できません。このポインタ アイコンは、Visual LISP で作業を再開する前に、AutoCAD での操作を完了させる必要があることを表しています。Visual LISP ポインタを目にしたら、このことを思い出してください。
これから、「庭園の歩道」アプリケーションを開発します。
;;; 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)
[名前を付けて保存]を選択し、新しいファイルのコードを <AutoCAD フォルダ>¥Tutorial¥VisualLISP¥MyPath¥gpmain.lsp に保存します。