TOP PAGE > 記事閲覧
図形タイプでフィルタ選択(lisp)
投稿日 : 2015/06/28(Sun) 14:35
投稿者 アルサポ
参照先
指定した図形のタイプのみを選択することが出来る、フィルタ選択の
lispを作成したので掲載します。
今回は、ダイアログボックスも作成するので、lispファイルとdclファイルを
2つ作成しなければいけませんが、どちらもテキストエディタで作成できるので簡単だと思います。
記事編集 編集
Re: MyFilter.DCLの内容
投稿日 : 2015/06/28(Sun) 14:42
投稿者 アルサポ
参照先
下の内容がダイアログボックスのファイルになります。
テキストエディタにコピー貼付でファイルを作成して下さい。

ここからが「MyFilter.DCL」の内容//////////////
MyFilter : dialog
{
label = "フィルタ選択";
:boxed_column /* 図形の種類の選択 */
{
label = "図形の種類で設定";
:toggle{label = "線分"; key = "LINE";}
:toggle{label = "ポリライン"; key = "LWPOLYLINE";}
:toggle{label = "2Dポリライン"; key = "POLYLINE";}
:toggle{label = "円"; key = "CIRCLE";}
:toggle{label = "円弧"; key = "ARC";}
:toggle{label = "楕円"; key = "ELLIPSE";}
:toggle{label = "点"; key = "POINT";}
:toggle{label = "文字"; key = "TEXT";}
:toggle{label = "マルチテキスト"; key = "MTEXT";}
:toggle{label = "ハッチング"; key = "HATCH";}
:toggle{label = "ソリッド"; key = "SOLID";}
:toggle{label = "ブロック参照"; key = "INSERT";}
:toggle{label = "寸法"; key = "DIMENSION";}
}

:boxed_radio_row /* 入力方法の選択 */
{
:button{label = "ALL ON"; key = "obj_kind_all";}
:button{label = "ALL OFF"; key = "obj_kind_clear";}
}
/* OK or CANCEL */
ok_cancel;
}
ここまでが「MyFilter.DCL」の内容//////////////
記事編集 編集
Re: 「MyFilter.LSP」の内容
投稿日 : 2015/06/28(Sun) 14:46
投稿者 アルサポ
参照先
下の内容がLISPファイルになります。
テキストエディタにコピー貼付でファイルを作成して下さい。

ここからが「MyFilter.LSP」の内容//////////////
(defun c:MyFilter ( / dialog_box dcl_id)

(if(not MyFilter)(load "MyFilter"))
(setq dcl_id (load_dialog "MyFilter.DCL"))
(new_dialog "MyFilter" dcl_id)
;チェックボックスのイベント処理
(action_tile "LINE" "(check_Val)")
(action_tile "LWPOLYLINE" "(check_Val)")
(action_tile "POLYLINE" "(check_Val)")
(action_tile "CIRCLE" "(check_Val)")
(action_tile "ARC" "(check_Val)")
(action_tile "ELLIPSE" "(check_Val)")
(action_tile "POINT" "(check_Val)")
(action_tile "TEXT" "(check_Val)")
(action_tile "MTEXT" "(check_Val)")
(action_tile "HATCH" "(check_Val)")
(action_tile "SOLID" "(check_Val)")
(action_tile "INSERT" "(check_Val)")
(action_tile "DIMENSION" "(check_Val)")
;ALL ON と ALL OFFのイベント処理
(action_tile "obj_kind_all" "(obj_kind_all_sel)")
(action_tile "obj_kind_clear" "(obj_kind_all_clear)")

(setq dialog-box (start_dialog))
(unload_dialog dcl_id)
;OKボタンを押した時の処理
(if(= (getvar "DIASTAT") 1)(obj_Val))
(princ)
)
(defun check_Val()
;チェックがついていれば「1」、ついてなければ「0」
(setq LINE_flg (atoi (get_tile "LINE")))
(setq LWPOLYLINE_flg(atoi (get_tile "LWPOLYLINE")))
(setq POLYLINE_flg(atoi (get_tile "POLYLINE")))
(setq CIRCLE_flg(atoi (get_tile "CIRCLE")))
(setq ARC_flg(atoi (get_tile "ARC")))
(setq ELLIPSE_flg(atoi (get_tile "ELLIPSE")))
(setq POINT_flg(atoi (get_tile "POINT")))
(setq TEXT_flg(atoi (get_tile "TEXT")))
(setq MTEXT_flg(atoi (get_tile "MTEXT")))
(setq HATCH_flg(atoi (get_tile "HATCH")))
(setq SOLID_flg(atoi (get_tile "SOLID")))
(setq INSERT_flg(atoi (get_tile "INSERT")))
(setq DIMENSION_flg(atoi (get_tile "DIMENSION")))
)
;ALL ONの処理(すべてにチェックを入れる)
(defun obj_kind_all_sel()
(set_tile "LINE" "1")
(set_tile "LWPOLYLINE" "1")
(set_tile "POLYLINE" "1")
(set_tile "CIRCLE" "1")
(set_tile "ARC" "1")
(set_tile "ELLIPSE" "1")
(set_tile "POINT" "1")
(set_tile "TEXT" "1")
(set_tile "MTEXT" "1")
(set_tile "HATCH" "1")
(set_tile "SOLID" "1")
(set_tile "INSERT" "1")
(set_tile "DIMENSION" "1")
(check_Val)
)
;ALL OFFの処理(すべてにチェックをはずす)
(defun obj_kind_all_clear()
(set_tile "LINE" "0")
(set_tile "LWPOLYLINE" "0")
(set_tile "POLYLINE" "0")
(set_tile "CIRCLE" "0")
(set_tile "ARC" "0")
(set_tile "ELLIPSE" "0")
(set_tile "POINT" "0")
(set_tile "TEXT" "0")
(set_tile "MTEXT" "0")
(set_tile "HATCH" "0")
(set_tile "SOLID" "0")
(set_tile "INSERT" "0")
(set_tile "DIMENSION" "0")
(check_Val)
)

(defun obj_Val()
(setq conditions (list (cons -4 "<or")))
;チェックがついていれば条件(リスト)に加える
(if (= LINE_flg 1) (setq conditions (append conditions (list (cons 0 "LINE")))))
(if (= LWPOLYLINE_flg 1) (setq conditions (append conditions (list (cons 0 "LWPOLYLINE")))))
(if (= POLYLINE_flg 1) (setq conditions (append conditions (list (cons 0 "POLYLINE")))))
(if (= CIRCLE_flg 1) (setq conditions (append conditions (list (cons 0 "CIRCLE")))))
(if (= ARC_flg 1) (setq conditions (append conditions (list (cons 0 "ARC")))))
(if (= ELLIPSE_flg 1) (setq conditions (append conditions (list (cons 0 "ELLIPSE")))))
(if (= POINT_flg 1) (setq conditions (append conditions (list (cons 0 "POINT")))))
(if (= TEXT_flg 1) (setq conditions (append conditions (list (cons 0 "TEXT")))))
(if (= MTEXT_flg 1) (setq conditions (append conditions (list (cons 0 "MTEXT")))))
(if (= HATCH_flg 1) (setq conditions (append conditions (list (cons 0 "HATCH")))))
(if (= SOLID_flg 1) (setq conditions (append conditions (list (cons 0 "SOLID")))))
(if (= INSERT_flg 1) (setq conditions (append conditions (list (cons 0 "INSERT")))))
(if (= DIMENSION_flg 1) (setq conditions (append conditions (list (cons 0 "DIMENSION")))))
(setq conditions (append conditions (list (cons -4 "or>"))))
(setq ss1 (ssget conditions))
(command "_pselect" ss1 "")
(setq ss1 nil)
(princ)
)
ここまでが「MyFilter.LSP」の内容//////////////
記事編集 編集
Re: 使用する時の注意
投稿日 : 2015/06/28(Sun) 15:00
投稿者 アルサポ
参照先
使い方の注意は、この2つのファイル(MyFilter.LSP、MyFilter.DCL)が保存されている場所が
「サポートファイルの検索パス」に登録されている事です。
「オプション」-「ファイルの場所」-「システム」-「サポートファイルの検索パス」で登録が出来ます。

余談ですが、このlispはAutoCADでも使用することが出来ます。
しかし、AutoCADの場合ではAutoCAD起動後、一度だけオブジェクトプロパティ管理を起動させておく必要があるようなので、ご注意下さい。

このLISPファイルのカスタマイズは、ソース自体は文字数が長いですが、同じ処理を繰り返し書いてあるタイプなので中身は割と単純なつくりです。
もっとたくさんの図形のタイプに対応させたり、レイヤ、色などでフィルタ選択できるようにカスタマイズしてみると面白いと思います。
記事編集 編集
Re: 図形タイプでフィルタ選択(lisp)
投稿日 : 2015/12/11(Fri) 09:24
投稿者 アルサポ
参照先
レイヤでフィルタ選択ができるLISPを作成してみましたので、
興味がある方は、こちらも参考にしてみてはどうでしょうか?
http://r-support.org/bbs/patio.cgi?read=50
記事編集 編集
ページの上に移動
件名 スレッドをトップへソート
名前
メールアドレス
URL
暗証キー
画像認証 (右画像の数字を入力) 投稿キー
コメント


- WEB PATIO -