JuniorNogueira Posted April 25, 2019 Posted April 25, 2019 Hello guys again, some doubts: How do I apply an action in this code? When I click on * insert * the selected block will be inserted. Is there a simple way to insert .dcl along with .lsp? How do you make perfect slides fit? (DEFUN c:efernal (/ dcl_id dx dy erro f_imagem f_rbs hlp item lista0 lista1 lista2 lista3 lista4 lista5 lista6 lista7 reason topico) (SETVAR "CMDECHO" 0) (SETQ dcl_id (LOAD_DIALOG "c:\\Clientes\\C_Efernal.dcl")) (IF (> dcl_id 0) (IF (NEW_DIALOG "efernal" dcl_id) (PROGN (SETQ erro "Atenção:\n\nVocê não selecionou um item na lista..." hlp "Como usar:\n\nPrograme como usar seu help neste evento..." lista1 '("Lona 1" "Lona 2" "Lona 3" "Lona 4" "Lona 5") lista2 '("Ar condicianado 1" "Ar condicianado 2" "Ar condicianado 3" "Ar condicianado 4" "Ar condicianado 5" "Ar condicianado 6") lista3 '("Vestiário 1" "Vestiário 2" "Vestiário 3" "Vestiário 4" "Vestiário 5") lista4 '("Ref. 1" "Ref. 2" "Ref. 3" "Ref. 4" "Ref. 5") lista5 '("Móvel 1" "Móvel 2" "Móvel 3" "Móvel 4" "Móvel 5") lista6 '("Textos" ) lista7 '("Símbolo 01" "Símbolo 02" "Símbolo 03" "Símbolo 04" "Símbolo 05" "Símbolo 06" "Símbolo 07" "Símbolo 08" "Símbolo 09" "Símbolo 10") dx (DIMX_TILE "img") dy (DIMY_TILE "img") ) (DEFUN f_rbs (k) (COND ((= k "rb1") (SETQ lista0 lista1 topico "LONARIA" ) ) ((= k "rb2") (SETQ lista0 lista2 topico "CLIMATIZAÇÃO" ) ) ((= k "rb3") (SETQ lista0 lista3 topico "VESTIÁRIO" ) ) ((= k "rb4") (SETQ lista0 lista4 topico "REFEITÓRIO" ) ) ((= k "rb5") (SETQ lista0 lista5 topico "MÓVEIS" ) ) ((= k "rb6") (SETQ lista0 lista6 topico "TEXTOS" ) ) ((= k "rb7") (SETQ lista0 lista7 topico "SÍMBOLOS" ) ) ) (START_LIST "item" 3) (MAPCAR 'ADD_LIST lista0) (END_LIST) (START_IMAGE "img") (FILL_IMAGE 0 0 dx dy 0) (END_IMAGE) (SET_TILE "msg" "Selecione um item na lista, por favor...") ) (DEFUN f_imagem (/ slide) (IF (SETQ slide (FINDFILE (STRCAT "c:\\Clientes\\Sld\\" item ".sld"))) (PROGN (START_IMAGE "img") (FILL_IMAGE 0 0 dx dy 0) (SLIDE_IMAGE 0 0 dx dy slide) (END_IMAGE) ) (ALERT (STRCAT "Atenção:\n\nF:\\Clientes\\Luciana\\Sld\\" item ".sld\n" "não foi encontrado...")) ) ) (FOREACH x '("rb1" "rb2" "rb3" "rb4" "rb5" "rb6" "rb7") (ACTION_TILE x "(F_Rbs $key)")) (ACTION_TILE "item" "(SETQ item (NTH (ATOI $value) lista0))(f_imagem)") (ACTION_TILE "help" "(ALERT hlp)") (ACTION_TILE "cancel" "(DONE_DIALOG 0)") (ACTION_TILE "accept" "(IF item (DONE_DIALOG 1)(ALERT erro))") (SETQ reason (START_DIALOG)) (UNLOAD_DIALOG dcl_id) (COND ((= reason 0) (PRINC "\n-> Cancelado...")) ((= reason 1) (ALERT (STRCAT "Executar o desejado aqui, com " topico " e " item))) ) ) ) (ALERT "Atenção:\n\nNão foi possível carregar o arquivo dcl.") ) (PRINC) ) DCL efernal:dialog{label="E.Fernal";initial_focus="msg"; :spacer{height=1;} :text{label="Selecione o tópico e depois o item";key="msg";alignment=centered;height=2;} :row{alignment=centered;fixed_width=true; :spacer{width=1;} :column{alignment=top;fixed_width=true;fixed_height=true; :text{label="Selecione tópico";} :radio_column{alignment=top;fixed_height=true; :radio_button{label="Lonaria";key="rb1";} :radio_button{label="Climatização";key="rb2";} :radio_button{label="Vestiário";key="rb3";} :radio_button{label="Refeitório";key="rb4";} :radio_button{label="Móveis Gerais";key="rb5";} :radio_button{label="Textos";key="rb6";} :radio_button{label="Símbolos";key="rb7";}}} :spacer{width=2;} :column{alignment=top;fixed_width=true;fixed_height=true; :text{label="Selecione o item";} :list_box{key="item";width=40;height=16;alignment=top;fixed_width=true;fixed_height=true;}} :spacer{width=1;} :column{alignment=top;fixed_width=true;fixed_height=true; :text{label="Preview";} :image_button{key="img";width=30;aspect_ratio=1.02;color=0;alignment=top;fixed_width=true;fixed_height=true;}} :spacer{width=1;}} :spacer{height=1;} :row{alignment=centered;fixed_width=true; :button{label="Como usar";key="help";width=15;fixed_width=true;} :button{label="Cancelar";key="cancel";is_cancel=true;width=15;fixed_width=true;} :button{label="Inserir";key="accept";width=15;fixed_width=true;}}} Quote
rlx Posted April 26, 2019 Posted April 26, 2019 (defun c:efernal (/ dcl_id dx dy erro f_imagem f_rbs hlp item lista0 lista1 lista2 lista3 lista4 lista5 lista6 lista7 reason topico dialog-fn dialog-fp dcl_id) ; (setvar "CMDECHO" 0) ; command echo could usefull when inserting block unless ins.point/scale/rot. are fixed ; to make perfect slide : ; ":image_button {key=\"img\";width=30;aspect_ratio=1.02;color=0;alignment=top;}}spacer;}" ; this means your slide is about 30x30 .... so insert symbol you want to take slide of in mspace, ; switch to paper space, make viewport size 30x30, make it active (double click), ; zoom to symbol , smile and take picture / slide (Create_Dialog) ; (SETQ dcl_id (LOAD_DIALOG "d:/Temp/Lisp/Cad-tutor/JuniorNogueira/C_Efernal.dcl")) (setq dcl_id (load_dialog dialog-fn)) (if (> dcl_id 0) (if (new_dialog "efernal" dcl_id) (progn (setq erro "Atenção:\n\nVocê não selecionou um item na lista..." hlp "Como usar:\n\nPrograme como usar seu help neste evento..." lista1 '("Lona 1" "Lona 2" "Lona 3" "Lona 4" "Lona 5") lista2 '("Ar condicianado 1" "Ar condicianado 2" "Ar condicianado 3" "Ar condicianado 4" "Ar condicianado 5" "Ar condicianado 6") lista3 '("Vestiário 1" "Vestiário 2" "Vestiário 3" "Vestiário 4" "Vestiário 5") lista4 '("Ref. 1" "Ref. 2" "Ref. 3" "Ref. 4" "Ref. 5") lista5 '("Móvel 1" "Móvel 2" "Móvel 3" "Móvel 4" "Móvel 5") lista6 '("Textos") lista7 '("Símbolo 01" "Símbolo 02" "Símbolo 03" "Símbolo 04" "Símbolo 05" "Símbolo 06" "Símbolo 07" "Símbolo 08" "Símbolo 09" "Símbolo 10") dx (dimx_tile "img") dy (dimy_tile "img") ) (defun f_rbs (k) (cond ((= k "rb1") (SETQ lista0 lista1 topico "LONARIA")) ((= k "rb2") (SETQ lista0 lista2 topico "CLIMATIZAÇÃO")) ((= k "rb3") (SETQ lista0 lista3 topico "VESTIÁRIO")) ((= k "rb4") (SETQ lista0 lista4 topico "REFEITÓRIO")) ((= k "rb5") (SETQ lista0 lista5 topico "MÓVEIS")) ((= k "rb6") (SETQ lista0 lista6 topico "TEXTOS")) ((= k "rb7") (SETQ lista0 lista7 topico "SÍMBOLOS")) ) (start_list "item" 3) (mapcar 'add_list lista0) (end_list) (start_image "img") (fill_image 0 0 dx dy 0) (end_image) (SET_TILE "msg" "Selecione um item na lista, por favor...") ) (defun f_imagem (/ slide) (if (setq slide (findfile (strcat "c:\\clientes\\sld\\" item ".sld"))) (progn (start_image "img") (fill_image 0 0 dx dy 0) (slide_image 0 0 dx dy slide) (end_image) ) (alert (strcat "atenção:\n\nf:\\clientes\\luciana\\sld\\" item ".sld\n" "não foi encontrado...")) ) ) (foreach x '("rb1" "rb2" "rb3" "rb4" "rb5" "rb6" "rb7") (ACTION_TILE x "(F_Rbs $key)")) (action_tile "item" "(setq item (nth (atoi $value) lista0))(f_imagem)") (action_tile "help" "(alert hlp)") (action_tile "cancel" "(done_dialog 0)") (action_tile "accept" "(if item (done_dialog 1)(alert erro))") (setq reason (start_dialog)) (unload_dialog dcl_id) (cond ((= reason 0) (princ "\n-> Cancelado...")) ((= reason 1) (alert (STRCAT "Executar o desejado aqui, com " topico " e " item)) (insert_block topico item) ) ) ) ) (alert "Atenção:\n\nNão foi possível carregar o arquivo dcl.") ) (if (and dialog-fn (setq dialog-fn (findfile dialog-fn)))(vl-file-delete dialog-fn)) (princ) ) (defun insert_block ( %topico %item / path blk) (setq path "f:/clientes/luciana/") (cond ((vl-catch-all-error-p (setq blk (vl-catch-all-apply 'strcat (list path %topico "/" %item ".dwg")))) (alert (strcat "*** Error: \n" (vl-catch-all-error-message blk)))) ((not (findfile blk)) (alert (strcat "Nada noppos blockos :\n" blk))) (t (command "-insert" blk)(while (= 1 (logand (getvar "cmdactive") 1))(command pause))) ) ) (defun Create_Dialog ( ) (if (and (setq dialog-fn (vl-filename-mktemp "tmp.dcl")) (setq dialog-fp (open dialog-fn "w"))) (mapcar '(lambda (x)(write-line x dialog-fp)) (list "efernal:dialog {label=\"E.Fernal\";initial_focus=\"msg\";:spacer {height=1;}" ":text{label=\"Selecione o tópico e depois o item\";key=\"msg\";alignment=centered;height=2;}" ":row {alignment=centered;fixed_width=true;spacer;" ":column {alignment=top;fixed_width=true;fixed_height=true;" ":text {label=\"Selecione tópico\";}" ":radio_column {alignment=top;fixed_height=true;" ":radio_button{label=\"Lonaria\";key=\"rb1\";}" ":radio_button{label=\"Climatização\";key=\"rb2\";}" ":radio_button{label=\"Vestiário\";key=\"rb3\";}" ":radio_button{label=\"Refeitório\";key=\"rb4\";}" ":radio_button{label=\"Móveis Gerais\";key=\"rb5\";}" ":radio_button{label=\"Textos\";key=\"rb6\";}" ":radio_button{label=\"Símbolos\";key=\"rb7\";}}}" "spacer;" ":column {alignment=top;children_fixed_width=true;children_fixed_height=true;" ":text {label=\"Selecione o item\";}:list_box {key=\"item\";width=40;height=16;alignment=top;}}" "spacer;" ":column {alignment=top;children_fixed_width=true;children_fixed_height=true;" ":text {label=\"Preview\";}" ":image_button {key=\"img\";width=30;aspect_ratio=1.02;color=0;alignment=top;}}spacer;}" "spacer;" ":column {:concatenation {alignment=centered;children_fixed_width=true;" ":button {label=\"Como usar\";key=\"help\";width=15;}" ":button {label=\"Cancelar\";key=\"cancel\";is_cancel=true;width=15;}" ":button {label=\"Inserir\";key=\"accept\";width=15;}}}}" ) ) ) (if dialog-fp (close dialog-fp)) ) 1 Quote
JuniorNogueira Posted April 26, 2019 Author Posted April 26, 2019 @rlx Thank you very much!!! it is perfect !! Another question: For me not to use many files (.dwg) I would use the * steal function of lee-mac http://www.lee-mac.com/steal.html * All my blocks in a single .dwg and would steal from there how to adapt to that? Quote
BIGAL Posted April 27, 2019 Posted April 27, 2019 1st question slides I use zoom e then zoom 0.85X this makes them all the same size on screen. 2nd look into the steal code there is an explanation about using it from a lisp. something like steal blocks listblocks dwgname 1 Quote
Lee Mac Posted April 27, 2019 Posted April 27, 2019 23 hours ago, JuniorNogueira said: For me not to use many files (.dwg) I would use the * steal function of lee-mac http://www.lee-mac.com/steal.html * All my blocks in a single .dwg and would steal from there how to adapt to that? To steal all blocks, you can use: (defun c:StealAllBlocks nil (Steal nil '(("Blocks" ("*")))) ) Or, for a predetermined target drawing: (defun c:StealAllBlocksFrom nil (Steal "C:\\YourDrawingFile.dwg" '(("Blocks" ("*")))) ) 1 Quote
JuniorNogueira Posted April 30, 2019 Author Posted April 30, 2019 how to center the slide is the zoom to get bigger? Quote
BIGAL Posted May 1, 2019 Posted May 1, 2019 Like I said I zoom in and get it right then do zoom 0.9xp which shrinks it a bit, make them in model space. I did some pretty drastic deletes on some of my dwgs to get the slide right, removing things like dims to make the object clearer. For your image I would remove the hatching. 1 Quote
JuniorNogueira Posted May 10, 2019 Author Posted May 10, 2019 Thanks @BIGAL it works!! a question, how to replace the 'insert_block' function so that it checks if the block exists and only inserts if it does not exist, I thought of something, but I do not know how to apply: With this I do not need several .dwgs. (defun insert_block (nome) (if (tblsearch "BLOCK" nome) (command "_.Insert" nome pause 1 1 "" "_.Explode" "_Last" "") (and (Steal "c:\\Blocks\\FTTx_Blocos.dwg" (list (list "BLOCKS" (list nome)))) (command "_.Insert" nome pause 1 1 "" "_.Explode" "_Last" "") ) ) ) Quote
dlanorh Posted May 10, 2019 Posted May 10, 2019 (defun insert_block (nome) (if (not (tblsearch "BLOCK" nome)) (Steal "c:\\Blocks\\FTTx_Blocos.dwg" (list (list "BLOCKS" (list nome))))) (command "_.Insert" nome pause 1 1 "" "_.Explode" "_Last" "") ) 1 Quote
JuniorNogueira Posted May 10, 2019 Author Posted May 10, 2019 @dlanorh I would like to replace in .dlc above this code: (defun insert_block ( %topico %item / path blk) (setq path "f:/clientes/luciana/") (cond ((vl-catch-all-error-p (setq blk (vl-catch-all-apply 'strcat (list path %topico "/" %item ".dwg")))) (alert (strcat "*** Error: \n" (vl-catch-all-error-message blk)))) ((not (findfile blk)) (alert (strcat "Nada noppos blockos :\n" blk))) (t (command "-insert" blk)(while (= 1 (logand (getvar "cmdactive") 1))(command pause))) ) ) by a similar code: (defun insert_block (nome) (if (not (tblsearch "BLOCK" nome)) (Steal "c:\\Blocks\\FTTx_Blocos.dwg" (list (list "BLOCKS" (list nome))))) (command "_.Insert" nome pause 1 1 "" "_.Explode" "_Last" "") ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.