庭園の歩道を描くには、歩道の境界とタイルを定義するための情報をユーザが提供する必要があります。庭園の歩道を描くための情報は、3 つの関数を使用して要求します。
Gardenpath 関数のユーザとの対話処理は、3 つのセカンダリ関数で定義されています。これらのセカンダリ関数は、AutoLISP プログラミング言語の一部である getxxx 関数を 1 つまたは複数使用して、庭園の歩道の寸法と配置だけでなく、庭園の歩道内に配置するタイルも定義します。ユーザからの入力を取得するために使用するセカンダリ関数は、次のとおりです。
次に、Gardenpath 関数のユーザとの対話処理関数を格納するために使用する LSP ファイルの作成方法を説明します。
[すべてのプログラム]
[アクセサリ]
[メモ帳]をクリックします。
[名前を付けて保存]を選択します。 LSP ファイルは閉じません。
[アプリケーション]を選択します。
[環境設定]を選択します。
[保存]を選択します。 LSP ファイルは閉じません。
次の手順では、gp:getPathInput という名前の関数を定義します。この関数は、2 点と距離を指定するようユーザに求めます。ユーザに求める 1 番目と 2 番目の値は、庭園の歩道の中心と長さを定義するために使用する点の値です。ユーザに求める 3 番目の値は、庭園の歩道の 1/2 幅です。これらの 3 つの値は、庭園の歩道の全体の幅と角度を計算するためにも使用されます。
gp:getPathInput 関数の戻り値は、5 つのドット ペアを含むリストです。
| DXF コード | 説明 |
|---|---|
|
10 |
庭園の歩道の始点を表す 3 つの実数のリスト。 |
|
11 |
庭園の歩道の終点を表す 3 つの実数のリスト。 |
|
40 |
庭園の歩道の幅を示す実数。 |
|
41 |
庭園の歩道の長さを表す実数。 |
|
50 |
庭園の歩道の角度を示す実数。 |
(defun gp:getPathInput ( / StartPt EndPt HalfWidth)
; Prompt for the start point of the path
(if (setq StartPt (getpoint "\nSpecify start point of path: "))
; If a valid start point was prompted, prompt for an endpoint
(if (setq EndPt (getpoint StartPt "\nSpecify endpoint of path: "))
; If a valid enpoint was provided, prompt for the paths half width
(if (setq HalfWidth (getdist EndPt "\nSpecify half width of path: "))
; Return a list of the values that define the path based on the input provided
(list
(cons 10 StartPt) ;| Start point |;
(cons 11 EndPt) ;| Endpoint |;
(cons 40 (* HalfWidth 2.0)) ;| Calculated full width of path |;
(cons 50 (angle StartPt EndPt)) ;| Angle of path |;
(cons 41 (distance StartPt EndPt)) ;| Length of the path |;
)
)
)
)
)
次の手順では、gp:getTileInput という名前の関数を定義します。この関数は、2 つの距離とキーワードを指定するようユーザに求めます。距離の値は、庭園の歩道に配置するタイルの半径とタイルの間隔を定義するために使用します。キーワードは、描画するタイルの形状(円または六角形)を指定するために使用します。
gp:getTileInput 関数の戻り値は、3 つのドット ペアを含むリストです。
| DXF コード | 説明 |
|---|---|
|
42 |
庭園の歩道のタイルの半径を示す実数。 |
|
43 |
庭園の歩道のタイルの間隔を示す実数。 |
|
5 |
庭園の歩道に描画するタイルの形状を示す文字列。有効な値: Circular および Hexagon |
(defun gp:getTileInput ( / tileSize tileOffset tileShape)
; Prompt for the radius of the tiles
(if (setq tileSize (getdist "\nSpecify radius of tiles: "))
; If a valid start point was prompted, prompt for an endpoint
(if (setq tileOffset (getdist "\nSpecify spacing between tiles: "))
(progn
(initget "Circular Hexagonal")
(if (setq tileShape (getkword "\nSpecify tile shape [Circular/Hexagonal]: "))
; Return a list of the values that define the tile size and offset
; based on the input provided
(list
(cons 42 tileSize) ;| Radius of the tile |;
(cons 43 tileOffset) ;| Offset distance between tiles |;
(cons 5 tileShape) ;| Shape of the tile |;
)
)
)
)
)
)
次の手順では、gp:getBorderStyleInput という名前の関数を定義します。この関数は、ユーザにキーワードを求めます。指定されたキーワードは、庭園の歩道の境界を描画するポリラインのタイプ(旧スタイルのポリラインまたはライトウェイト ポリライン)をコントロールします。
gp:getBorderStyleInput 関数の戻り値は、1 つのドット ペアを含むリストです。
| DXF コード | 説明 |
|---|---|
|
4 |
庭園の歩道の境界を描くために使用するポリ ラインのタイプを示す文字列。有効な値: Pline および Light |
(defun gp:getBorderStyleInput ( / borderStyle)
; Prompt for the border style keyword
(initget "Pline Light")
(if (setq borderStyle (getkword "\nSpecify polyline style of path boundary [Pline/Light]: "))
; Return a list containing the keyword the user specified
(list
(cons 4 borderStyle) ;| Polyline style for path |;
)
)
)