Jump to content

Recommended Posts

Posted

This is a part of lisp code. I add  two toggle in the dcl dialog

 

              ": row {"
              ": toggle { key = \"Block\"; label = \"Block\"; value = 1; }"
              ": toggle { key = \"Table\"; label = \"Table\"; value = 1; }"
              "}" ; end row

 

I want the blocks  insert only if the toggle is check. The toggle Block is for

          (action_tile "eArt67" "(done_dialog 1) (setq bk \"0\")")
          (action_tile "eArt68" "(done_dialog 1) (setq bk \"1\")")
          (action_tile "eArt69" "(done_dialog 1) (setq bk \"2\")")
          (action_tile "eArt67b" "(done_dialog 1) (setq bk \"3\")")
          (action_tile "eArt68b" "(done_dialog 1) (setq bk \"4\")")
          (action_tile "eArt69b" "(done_dialog 1) (setq bk \"5\")")
          (action_tile "eCwwd9l" "(done_dialog 1) (setq bk \"6\")")
          (action_tile "eCwwd8l" "(done_dialog 1) (setq bk \"7\")")
          (action_tile "eCwwd8d" "(done_dialog 1) (setq bk \"8\")")
          (action_tile "eCwwd9lb" "(done_dialog 1) (setq bk \"9\")")
          (action_tile "eCwwd8lb" "(done_dialog 1) (setq bk \"10\")")

 

and the toggle Table is for

 

  
  ;; Insert eArt3
  
  (setq scl 1)
  (setq dt1 (getpoint "\n insert"))
  (setvar "attdia" 1)
  (command "insert" "c:\\path\\eArt3.dwg" dt1 scl scl "0")
  (setvar "attdia" 0)

 

 

      ;; DCL DIALOG 
      (if (and (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w")))
        (progn 
          (write-line
            (strcat
              "test : dialog {"
              "label = \"Επιλογή τύπου ανοίγματος\"; width = 30;"
              ": row {"
              ": image_button { key = \"eArt67\"; label = \"eArt67\"; height = 4; width = 4; }"
              ": image_button { key = \"eArt68\"; label = \"eArt68\"; height = 4; width = 4; }"
			  ": image_button { key = \"eArt69\"; label = \"eArt69\"; height = 4; width = 4; }"
              "}" ; end row
              ": row {"
              ": image_button { key = \"eArt67b\"; label = \"eArt67b\"; height = 4; width = 4; }"
              ": image_button { key = \"eArt68b\"; label = \"eArt68b\"; height = 4; width = 4; }"
			  ": image_button { key = \"eArt69b\"; label = \"eArt69b\"; height = 4; width = 4; }"
              "}" ; end row
              ": row {"
              ": image_button { key = \"eCwwd9l\"; label = \"eCwwd9l\"; height = 4; width = 4; }"
              ": image_button { key = \"eCwwd8l\"; label = \"eCwwd8l\"; height = 4; width = 4; }"
			  ": image_button { key = \"eCwwd8d\"; label = \"eCwwd8d\"; height = 4; width = 4; }"
              "}" ; end row
              ": row {"
              ": image_button { key = \"eCwwd9lb\"; label = \"eCwwd9lb\"; height = 4; width = 4; }"
              ": image_button { key = \"eCwwd8lb\"; label = \"eCwwd8lb\"; height = 4; width = 4; }"
              ": image_button { key = \"\"; label = \"\"; height = 4; width = 4; }"
              "}" ; end row
              ": row {"
              ": toggle { key = \"Block\"; label = \"Block\"; value = 1; }"
              ": toggle { key = \"Table\"; label = \"Table\"; value = 1; }"
              "}" ; end row
              ": column { width = 17;"
              ": button { key = \"OK\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 10; }"
              "}" ; end column
              "}" 
            )
            f
          )
          (close f)
        )
        (alert "Can't load the temporary file <!>")
      )
      
      (if (or (not d) (> 0 (setq id (load_dialog d))) (not (new_dialog "test" id)))
        (progn 
          (if (> id 0)
            (unload_dialog id)
          )
          (if (and d (setq d (findfile d)))
            (vl-file-delete d)
          )
        )

        (progn 
          ;; Load and display the slide images
          (mapcar '(lambda (s k)
                      (start_image k)
                      (fill_image 0 0 (dimx_tile k) (dimy_tile k) 0)
                      (slide_image 0 0 (dimx_tile k) (dimy_tile k) s)
                      (end_image)
                    )
                   (list "C:\\path\\eArt67.sld" 
                         "C:\\path\\eArt68.sld"
                         "C:\\path\\eArt69.sld"						 
                         "C:\\path\\eArt67b.sld" 
                         "C:\\path\\eArt68b.sld"				 
                         "C:\\path\\eArt69b.sld"						 
	                     "C:\\path\\eCwwd9l.sld"
                         "C:\\path\\eCwwd8l.sld"
                         "C:\\path\\eCwwd8d.sld"
	                     "C:\\path\\eCwwd9lb.sld"
                         "C:\\path\\eCwwd8lb.sld"				 
						 ) 
                   (list "eArt67" "eArt68" "eArt69" 
				         "eArt67b" "eArt68b" "eArt69b" 
						 "eCwwd9l" "eCwwd8l" "eCwwd8d"
                         "eCwwd9lb" "eCwwd8lb" "eCwwd8db")
          )
          
          ;; Set up action tiles for the image buttons
          (action_tile "eArt67" "(done_dialog 1) (setq bk \"0\")")
          (action_tile "eArt68" "(done_dialog 1) (setq bk \"1\")")
          (action_tile "eArt69" "(done_dialog 1) (setq bk \"2\")")
          (action_tile "eArt67b" "(done_dialog 1) (setq bk \"3\")")
          (action_tile "eArt68b" "(done_dialog 1) (setq bk \"4\")")
          (action_tile "eArt69b" "(done_dialog 1) (setq bk \"5\")")
          (action_tile "eCwwd9l" "(done_dialog 1) (setq bk \"6\")")
          (action_tile "eCwwd8l" "(done_dialog 1) (setq bk \"7\")")
          (action_tile "eCwwd8d" "(done_dialog 1) (setq bk \"8\")")
          (action_tile "eCwwd9lb" "(done_dialog 1) (setq bk \"9\")")
          (action_tile "eCwwd8lb" "(done_dialog 1) (setq bk \"10\")")		  
          (action_tile "OK" "(done_dialog 1)")
          
          ;; Start the dialog
          (setq ret (start_dialog))
          (unload_dialog id)
          
          ;; Handle the selection
          (if (= ret 1)  
            (cond
              ((= bk "0") (_eArt67))
              ((= bk "1") (_eArt68))
              ((= bk "2") (_eArt69))
              ((= bk "3") (_eArt67b))
              ((= bk "4") (_eArt68b))
              ((= bk "5") (_eArt69b))
              ((= bk "6") (_eCwwd9l))
              ((= bk "7") (_eCwwd8l))
              ((= bk "8") (_eCwwd8d))
              ((= bk "9") (_eCwwd9lb))
              ((= bk "10") (_eCwwd8lb))
            )
          )
        )
      )
    )
  )
  
  ;; Insert eArt3
  
  (setq scl 1)
  (setq dt1 (getpoint "\n insert"))
  (setvar "attdia" 1)
  (command "insert" "c:\\path\\eArt3.dwg" dt1 scl scl "0")
  (setvar "attdia" 0)
 
 ;; Επαναφορά OSMODE και LAYER 0
 
  (setvar "OSMODE" 13) ; NODE,END,CENTER
  (command "setvar" "clayer" "0")
) ;--- end defun

 

 

Can any one help?

 

Thanks

Posted

Do you mean you want to prevent the command from finishing by forcing you to insert the block even if you haven't selected one?

Posted

If so, you would just need to condition the execution of '(command "_insert"...)' on 'bk' having some value.
That is:
 

(if bk (command "_insert" nameofblock dt1 scl scl "0")

 

Posted

Of course, for there to be a possibility of 'bk' being nil at the beginning of the command, it must be a local variable.

Posted

Hi GLAVCVS . This is a part  of  a bigger code. The code at the end insert  2 blocks. I want to have the option to insert both of them , or one of them or no block. So the toggles is a solution. Can you help?

 

Thanks

Posted

If it is then a matter of inserting 2 blocks when Block and Table are activated, 1 when only Block or Table is activated, or none if neither of the 2 is activated, you could do:
replace the current '(action_tile "ok"... ) with... 

(action_tile "OK" "(setq blk (get_tile \"Block\") tab (get_tile \"Table\")) (done_dialog 1)")

 

And below, replace the call to '(command "insert"...)' with...

  (cond
    ((and (= blk "1") (= tab "1"))
     (insert2blocks)
    )
    ((= blk "1")
     (insertblock_1)
    )
    ((= tab "1")
     (insertblock_2)
    )
  )

 

Posted
12 minutes ago, GLAVCVS said:

If it is then a matter of inserting 2 blocks when Block and Table are activated, 1 when only Block or Table is activated, or none if neither of the 2 is activated, you could do:
replace the current '(action_tile "ok"... ) with... 

(action_tile "OK" "(setq blk (get_tile \"Block\") tab (get_tile \"Table\")) (done_dialog 1)")

 

And below, replace the call to '(command "insert"...)' with...

  (cond
    ((and (= blk "1") (= tab "1"))
     (insert2blocks)
    )
    ((= blk "1")
     (insertblock_1)
    )
    ((= tab "1")
     (insertblock_2)
    )
  )

 

 

Well: the execution of this 'cond' would also have to be conditioned to whether a block has been selected, of course
That is:

 

(if bk
  (cond
    ... 
    ... 
    ... 

 

Posted (edited)

A not sure comment I normally do this as get value 1st then close dialog. Did not test.

 

(action_tile "eArt67" "(done_dialog 1) (setq bk \"0\")")

(action_tile "eArt67" "(setq bk \"0\")(done_dialog 1)")

 

If you set your c:\path to be a support path then you can just call the slide name, no directory path needed. Just me I would have c:\path\slides & say c:\path\lisps. You may want to look into Slidelibrary this allows you to have one SLB file with all your slide files in it. We had a few slb as group of slides. 

 

An old trick was set support path to c:\path..  note the double full stop means include sub directories, I am pretty sure does not work in my Bricscad but it used to work in Autocad.

Edited by BIGAL

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...