Jump to content

Căn chỉnh image trong tile image của dialog

Chào các bác! 

Em có tham khảo qua nhiều topic trong đó có topic của bác @Doan Van Ha 

 

 mà vẫn không thể nào căn chỉnh được img sao cho vừa title  img trong dialog. Em có code này để minh họa. Mong các bác giúp đỡ.

(defun C:VT (/)
(if
        (and
            (setq dcl (vl-filename-mktemp nil nil ".dcl"))
            (setq des (open dcl "w"))
            (foreach x
               '(
                    "pass : dialog"
                    "{"
                    "        label = \"Setting\";"		
                    "            : column "
                    "            {"
                    "                : boxed_row"
                    "                	{"	
                    "        		 label = \"Th\U+00F4ng s\U+1ED1\";"	
                    "            : radio_column "
                    "            {"					
                    "            : edit_box"
                    "            {"
                    "                key = \"k1\";"
                    "       		 label = \"Nh\U+1EADp th\U+00F4ng s\U+1ED1:\";"					
                    "                edit_width = 12;"
                    "                alignment = left;"
                    "                mnemonic = \"L\";"	
                    "            }"	
                    "    spacer;"
                            "        : image"
                            "        {"
                            "            key = \"logo\";"
                            "            width = 33.5;"
                            "            height = 11.62;"
                            "            fixed_width = true;"
                            "            fixed_height = true;"
                            "            alignment = centered;"
                            "        }"
                    "    spacer;"	
                    "            }"	
                    "            }"	
                    "    : row"
                    "    {"	
                    "    : button"
                    "    {"
                    "        key = \"accept\";"
                    "        label = \"Draw\";"
                    "        is_default = true;"	
                    "        is_cancel = true;"
                    "        fixed_width = true;"
                    "        alignment = centered;"
                    "        width = 15;"
                    "        mnemonic = \"x\";"
                    "    }"
					
                    "    : button"
                    "    {"
                    "        key = \"cancel\";"
                    "        label = \"Cancel\";"
                    "        is_default = false;"	
                    "        is_cancel = true;"						
                    "        fixed_width = true;"
                    "        alignment = centered;"
                    "        width = 15;"
                    "        mnemonic = \"G\";"
                    "    }"					
                    "    }"						
                    "}"
					"            }"	
                )
                (write-line x des)
            )
            (not (setq des (close des)))
            (< 0 (setq dch (load_dialog dcl)))
            (new_dialog "pass" dch)
        )
        (progn
(defun logo (key)
  (start_image key)
  (mapcar 'vector_image; Color 1
	(list 86 96 86)
    (list 47 47 47)
    (list 96 96 86)
    (list 47 48 48)
    (list  1  1  1)
  );mapcar
  (end_image)
);defun
 (logo "logo")
			(start_dialog)
        )
        (princ "\nUnable to load password dialog.")
)
(princ)
)

 

Cách dùng

  1. Tải tệp 458342_vt.lsp về máy.
  2. Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
  3. Gõ lệnh VT để chạy lisp.

Mã nguồn 458342_vt.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/188389-help-c%C4%83n-ch%E1%BB%89nh-image-trong-tile-image-c%E1%BB%A7a-dialog/
(defun C:VT (/)
(if
        (and
            (setq dcl (vl-filename-mktemp nil nil ".dcl"))
            (setq des (open dcl "w"))
            (foreach x
               '(
                    "pass : dialog"
                    "{"
                    "        label = \"Setting\";"		
                    "            : column "
                    "            {"
                    "                : boxed_row"
                    "                	{"	
                    "        		 label = \"Th\U+00F4ng s\U+1ED1\";"	
                    "            : radio_column "
                    "            {"					
                    "            : edit_box"
                    "            {"
                    "                key = \"k1\";"
                    "       		 label = \"Nh\U+1EADp th\U+00F4ng s\U+1ED1:\";"					
                    "                edit_width = 12;"
                    "                alignment = left;"
                    "                mnemonic = \"L\";"	
                    "            }"	
                    "    spacer;"
                            "        : image"
                            "        {"
                            "            key = \"logo\";"
                            "            width = 33.5;"
                            "            height = 11.62;"
                            "            fixed_width = true;"
                            "            fixed_height = true;"
                            "            alignment = centered;"
                            "        }"
                    "    spacer;"	
                    "            }"	
                    "            }"	
                    "    : row"
                    "    {"	
                    "    : button"
                    "    {"
                    "        key = \"accept\";"
                    "        label = \"Draw\";"
                    "        is_default = true;"	
                    "        is_cancel = true;"
                    "        fixed_width = true;"
                    "        alignment = centered;"
                    "        width = 15;"
                    "        mnemonic = \"x\";"
                    "    }"
					
                    "    : button"
                    "    {"
                    "        key = \"cancel\";"
                    "        label = \"Cancel\";"
                    "        is_default = false;"	
                    "        is_cancel = true;"						
                    "        fixed_width = true;"
                    "        alignment = centered;"
                    "        width = 15;"
                    "        mnemonic = \"G\";"
                    "    }"					
                    "    }"						
                    "}"
					"            }"	
                )
                (write-line x des)
            )
            (not (setq des (close des)))
            (< 0 (setq dch (load_dialog dcl)))
            (new_dialog "pass" dch)
        )
        (progn
(defun logo (key)
  (start_image key)
  (mapcar 'vector_image; Color 1
	(list 86 96 86)
    (list 47 47 47)
    (list 96 96 86)
    (list 47 48 48)
    (list  1  1  1)
  );mapcar
  (end_image)
);defun
 (logo "logo")
			(start_dialog)
        )
        (princ "\nUnable to load password dialog.")
)
(princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [HELP] Căn chỉnh image trong tile image của dialog. Xem đúng bài viết #458342 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 326)