Sponsored links

【AutoLISP サンプル】文字のスタイルを変更 ダイアログボックス編

Sponsored links
サンプル
Sponsored links
Sponsored links

コマンドの内容

Jagaimo
Jagaimo

ポップアップリストのダイアログボックスのサンプルコマンドです。

ダイアログボックスで文字スタイルを選び、グループ選択したテキスト/マルチテキストの文字スタイルを変更します。

概要

フィルターを入れた選択セットでテキスト/マルチテキストのみを選び、文字スタイルを変更します。

図形選択

グループ選択で複数の文字を変更することができます。
フィルターがかかっているので、テキスト/マルチテキストのみが選択されます。

文字スタイル

ダイアログボックスに表示される文字スタイルは無ければ作成されます。
設定してある文字スタイルは、
“Jaga-Style” “Jaga-Style-L” “Jaga-Style-M” “Jaga-Style-S”
の4つです。

“Jaga-Style” は文字高さを設定していない文字スタイルなので、文字の高さは変更されません。

“Jaga-Style-L” “Jaga-Style-M” “Jaga-Style-S”は文字スタイルで設定してある文字高さに変更されます。

AutoLISP プログラム

コマンド名は JagaTx です。

;//////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////
;JagaimoLisp コマンド関数
;文字スタイル変更(ポップアップリスト)  var.20200707
;---------------------------------------

(defun c:JagaTx (/ dcl_id Act Lst Num )

   (setq dcl_id (load_dialog "JagaDCL.dcl"))
   
      (if (not (new_dialog "TxStlCh" dcl_id))
	      (progn
            (princ "***ダイアログボックスが見つかりません***")
            (exit)
      ));if 
  
          ;-----------------------------------------------------------
           (if (null gTxStl) (setq gTxStl "Jaga-Style"))
  
           (setq Lst '("Jaga-Style" "Jaga-Style-L" "Jaga-Style-M" "Jaga-Style-S"))
            (start_list "TxStl")
              (mapcar 'add_list Lst)
            (end_list)

            (setq Num (itoa (vl-position gTxStl Lst)))		
            (set_tile  "TxStl" Num)
          ;-----------------------------------------------------------
            (action_tile "accept" "(JagaTx_GetVar)(done_dialog 1)")
            (action_tile "cancel" "(done_dialog 0)")
          ;-----------------------------------------------------------
            (setq Act (start_dialog))
            (unload_dialog dcl_id)
          ;-----------------------------------------------------------
            (cond 
              ((= Act 0) (princ "ユーザーキャンセル"))
              ((= Act 1) (Jaga00TxStlCh gTxStl));act1
            );cond
          ;----------------------------------------------------------				
(princ))

;===========================================
(defun JagaTx_GetVar ( / TxStl )
  (setq TxStl (atoi (get_tile "TxStl")))
  (setq gTxStl (nth TxStl Lst))
)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun Jaga00TxStlCh ( StlNm / Objs ObjNum Cnt TxH Ent)
  
	(setq Objs (Jaga00TxSs)) 
			(setq ObjNum (sslength OBJs) Cnt 0)
  
  (Jaga00StlJagaL)
   (setq TxH (assoc 40 (tblsearch "style" StlNm)))
   
	(while (< Cnt ObjNum)
		(setq Ent (entget (ssname OBJs Cnt)))
	  	(setq Ent (subst (cons '7 StlNm)(assoc 7 Ent) Ent))
   	    (if (/= 0 (cdr TxH)) (setq Ent (subst TxH (assoc '40 Ent) Ent)))
		(entmod Ent)

		(setq Cnt (+ Cnt 1))
	);while

  (princ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun Jaga00StlJagaL ()

  (if (null (tblsearch "style" "Jaga-Style-L"))
    (command-s "._STYLE"
            "Jaga-Style-L"  ;文字スタイル名
            "romans" ;フォント名
            "5" ;文字高さもしくは異尺度
            "1" ;幅係数
            "0" ;傾斜角度
            "N" ;左右反転
            "N" ;上下反転
            "N" ;縦書き 
    ) ;command-s
  );if    

  
  (if (null (tblsearch "style" "Jaga-Style-M"))
    (command-s "._STYLE"
            "Jaga-Style-M"  ;文字スタイル名
            "romans" ;フォント名
            "3" ;文字高さもしくは異尺度
            "1" ;幅係数
            "0" ;傾斜角度
            "N" ;左右反転
            "N" ;上下反転
            "N" ;縦書き 
    ) ;command-s
  );if    
  
  (if (null (tblsearch "style" "Jaga-Style-S"))
    (command-s "._STYLE"
            "Jaga-Style-S"  ;文字スタイル名
            "romans" ;フォント名
            "1" ;文字高さもしくは異尺度
            "1.5" ;幅係数
            "0" ;傾斜角度
            "N" ;左右反転
            "N" ;上下反転
            "N" ;縦書き 
    ) ;command-s
  );if 
  
    (if (null (tblsearch "style" "Jaga-Style"))
    (command-s "._STYLE"
            "Jaga-Style"  ;文字スタイル名
            "romans" ;フォント名
            "0" ;文字高さもしくは異尺度
            "1" ;幅係数
            "0" ;傾斜角度
            "N" ;左右反転
            "N" ;上下反転
            "N" ;縦書き 
    ) ;command-s
  );if    
  
);defun

;------------------------------------------------

(defun Jaga00TxSs ( / OBJs ObjNum Lst)

	(setq OBJs (ssget "_I" '((0 . "TEXT,MTEXT"))))
	(if (null OBJs)
		(setq OBJs (ssget '((0 . "TEXT,MTEXT"))))
  );if
Objs
);defun

DCL (ダイアログボックス コントロール言語)

JagaDCL.dcl というファイル名でサポートファイルの検索パス内にあるフォルダに保存してあることを前提で上のAutoLISPにプログラムされています。

TxStlCh :dialog
      {label = "Text Style"; 
//-------------------------------------------------------- 
   :popup_list {key="TxStl";}
//--------------------------------------------------------   
        ok_cancel;
      }

参考記事

ポップアップリストの作り方について。

文字スタイルを作る

文字スタイルを変更

Comments