ブロックテスト
^C^C(command "._copybase" (getpoint) (ssget) "" "._erase" "_p" "" "._pasteblock" "@")
^C^C(setq s1(ssget "_I"))(if (not s1)(setq s1(ssget)))(setq p1(getpoint))(command "._copybase" p1 s1 "")(command "._erase" s1 "")(command "._pasteblock" p1)
ブロック
^C^C(LOAD "ブロック.lsp");pb
ブロック.lsp
(defun c:pb ()
(prompt "\nオブジェクトを選択してください...")
(setq ss (ssget)) ; 先にオブジェクトを選択
(if ss
(progn
(prompt "\n基点を指定してください(ENDP/MID/CEN/INT などのスナップを使用)...")
(command "_copybase" pause ss "") ; 基点と選択セットを一緒に渡す
(command "_erase" ss "") ; オブジェクトを削除
(command "pasteblock" "@") ; 元の位置に貼り付け
)
(prompt "\nオブジェクトが選択されていません。")
)
(princ)
)
ブロック名変更
^C^C(LOAD "BLOCK_RE_S.LSP");BLOCK_RE_S
;ブロック名を別名にする
;ブロック編集中は使用不可
(DEFUN C:BLOCK_RE_S (/)
;初期設定
;1の場合は、選択ブロックのみ名前変更
;2の場合は、全ブロックを名前変更
(SETQ BLOCK_SYOKI 1)
(setq ZUKEI(ENTSEL))
(if (not ZUKEI)(progn
(prompt "\n何も選択されませんでした。処理を中断します\n")
(exit)
))
(setq ZUMEI_NAME(CAR ZUKEI))
(setq B_ITI(CDR(assoc 10(entget(car ZUKEI)))))
(setq B_GASOU(CDR(assoc 8(entget(car ZUKEI)))))
(setq B_NAME(CDR(assoc 2(entget(car ZUKEI)))))
(IF (= BLOCK_SYOKI 1)(PROGN
(SETQ ONE_T 1)
(SETQ EVERYONE_T 0)
))
(IF (= BLOCK_SYOKI 2)(PROGN
(SETQ ONE_T 0)
(SETQ EVERYONE_T 1)
))
(IF (AND (/= BLOCK_SYOKI 1)(/= BLOCK_SYOKI 2))(PROGN
(SETQ ONE_T 1)
(SETQ EVERYONE_T 0)
))
(setq dcl_id (load_dialog "BLOCK_RE_S.dcl"))
(if (not (new_dialog "BLOCK_ONE_RENAME" dcl_id)) (exit))
(SET_TILE "B_NAME" B_NAME)
(SET_TILE "ONE_T" (itoa ONE_T))
(SET_TILE "EVERYONE_T" (itoa EVERYONE_T))
(action_tile "B_NAME" "(setq B_NAME (get_tile \"B_NAME\"))")
(action_tile "B_NAME_RENAME" "(setq B_NAME_RENAME (get_tile \"B_NAME_RENAME\"))")
(action_tile "ONE_T" "(setq ONE_T 1)(setq EVERYONE_T 0)")
(action_tile "EVERYONE_T" "(setq ONE_T 0)(setq EVERYONE_T 1)")
(action_tile "accept" "(setq I 1)(done_dialog)")
(action_tile "cancel" "(setq I 0)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(IF (= I 1)(progn
(if (or (= B_NAME "")(= B_NAME_RENAME ""))(progn
(prompt "\n文字が空です。処理を中断します\n")
(exit)
))
(if (not (tblsearch "block" B_NAME))(progn
(prompt "\n指定されたブロックが存在しません。処理を中断します\n")
(exit)
))
(if (not (not (tblsearch "block" B_NAME_RENAME)))(progn
(prompt "\n既にブロックが存在します。手動で名前を変更して下さい。処理を中断します\n")
(exit)
))
(IF (= ONE_T 1)(PROGN
(COMMAND "EXPLODE" ZUMEI_NAME)
(COMMAND "-BLOCK" B_NAME_RENAME B_ITI "P" "")
(COMMAND "-INSERT" B_NAME_RENAME "S" "1" B_ITI "0")
(COMMAND "CHANGE" "LAST" "" "P" "LA" B_GASOU "")
(prompt (strcat "\n" B_NAME_RENAME "に変更されました\n"))
))
(IF (= EVERYONE_T 1)(progn
(command "-rename" "b" B_NAME B_NAME_RENAME)
(prompt (strcat "\n" B_NAME_RENAME "に変更されました\n"))
))
))
(IF (= I 0)
(EXIT)
)
)
BLOCK_RE_S.dcl
BLOCK_ONE_RENAME: dialog {
label = "BLOCK_ONE_RENAME";
initial_focus = "B_NAME_RENAME";
: text {
label = "現在のブロック名" ;
fixed_width = 1 ;
}
: edit_box {
key = "B_NAME" ;
fixed_width = 1 ;
}
: text {
label = "変更後のブロック名" ;
fixed_width = 1 ;
}
: edit_box {
key = "B_NAME_RENAME" ;
fixed_width = 1 ;
allow_accept = true;
}
: radio_button
{
key = "ONE_T" ;
label = "選択ブロックのみ名前変更";
}
: radio_button
{
key = "EVERYONE_T" ;
label = "全ブロックを名前変更";
}
ok_cancel ;
}
=現在の設定=
名前に入力
$(eval," 全体尺度 : 1/"$(getvar,DIMSCALE))
$(eval," 寸法値尺度 : 1/"$(rtos,$(*,$(getvar,DIMSCALE),$(getvar,DIMLFAC))))