連想リストを使用するとき、どのようなキー値を使用するかを決める必要があります。庭園の歩道では、キー値 10、11、40、41、50 は次のような意味です。
次に、gp:getPointInput 関数の更新されたバージョンを示します。この中で、AutoLISP の cons (construct a list[リストを構築]の省略形)関数を使用して、連想リスト内の、キー付きのサブリストを作成しています。[コンソール]ウィンドウにこのバージョンをコピーし、[Enter]を押してもう一度 (gp:getPointInput) を実行してください。
(defun gp:getPointInput (/ StartPt EndPt HalfWidth)
(if (setq StartPt (getpoint "\nStart point of path: "))
(if (setq EndPt (getpoint StartPt "\nEndpoint of path: "))
(if (setq HalfWidth (getdist EndPt "\nhalf-width of path: "))
;; if you've made it this far, build the association list
;; as documented above. This will be the return value
;; from the function.
(list
(cons 10 StartPt)
(cons 11 EndPt)
(cons 40 (* HalfWidth 2.0))
(cons 50 (angle StartPt EndPt))
(cons 41 (distance StartPt EndPt))
)
)
)
)
)
リストを作成するときに、ユーザが指定した幅の 1/2 の値に 2 を掛けて、幅全体の値に変換している点に注意してください。
コンソール ウィンドウに、次のような出力が表示されます。
(gp:getPointInput) ((10 2.16098 1.60116 0.0) (11 12.7126 7.11963 0.0) (40 . 0.592604) (50 . 0.481876) (41 . 11.9076))