DCL/LISP to insert block at 0,0 and explode according to multiple radio options

DCL/LISP to insert block at 0,0 and explode according to multiple radio options

Nathan_Tigner
Advocate Advocate
722 Views
7 Replies
Message 1 of 8

DCL/LISP to insert block at 0,0 and explode according to multiple radio options

Nathan_Tigner
Advocate
Advocate

Hello All,

I am trying to create a dcl and lisp for inserting title blocks. We have many and I am trying to simplify the process.

I have created a dcl that will let you pick the size, logo and orientation of the title block. I would then like the user to press ok and the corresponding title block to those options be inserted at 0,0 and then exploded, (we xref our title blocks, so I don't want it to remain a block once inserted.)

 

The problem is, I have no clue where to start with the lisp portion of the project. I would imagine I need to create a list of selected options and then insert a block according to that list, but I have no clue how to do that. Any help would be greatly appreciated. The DCL and LISP I have are below. The lisp now pretty much just runs the dcl and that's about it.

 

tb : dialog {
	label = "Title Block Utility";
	: text {
	label = "Version 1.0 : May 2022 : NWT";
	}
	: row {
		: column {
			: radio_column {
				label = "Size";
				key = "s1";
				: radio_button {
					key = "s2";
					label = "8.5 x 11";
				}
				: radio_button {
					key = "s3";
					label = "11 x 17";
				}
				: radio_button {
					key = "s4";
					label = "22 x 34";
				}
				: radio_button {
					key = "s5";
					label = "24 x 36";
				}
				: radio_button {
					key = "s6";
					label = "30 x 42";
				}
			}
		}
			
		: column {
			: radio_column {
				label = "Logo";
				key = "l1";
				: radio_button {
					key = "l2";
					label = "CESO";
				}
				: radio_button {
					key = "l3";
					label = "CESO Arch";
				}
				: radio_button {
					key = "l4";
					label = "Arch of Note";
				}
             
			}
		}
		: column {
			: radio_column {
				label = "Orientation";
				key = "o1";
				: radio_button {
					key = "02";
					label = "Landscape";
				}
				: radio_button {
					key = "03";
					label = "Portrait";
				}
			}
		}
	}
	: boxed_row {
		: button {
			key = "accept";
			label = " Okay ";
			is_default = true;
		}
		: button {
			key = "cancel";
			label = " Cancel ";
			is_default = false;
			is_cancel = true;
		}
	}
}

(defun C:tb()

  (if(not(setq dcl_id (load_dialog "tb.dcl")))
    (progn
      (alert "The DCL file could not be loaded!")
      (exit)
    )

    (progn

      (if (not(new_dialog "tb" dcl_id))
        (progn
        (alert "The tb definition could not be loaded!")
          (exit)
        )
   
        (progn

          (action_tile "accept" "(saveVars)(done_dialog 2)")
          (action_tile "cancel" "(done_dialog 1)")

          (setq ddiag(start_dialog))

          (unload_dialog dcl_id)

          (if(= ddiag 1)
            (princ "\n TITLEBLOCK cancelled!")
          )

          (if(= ddiag 2)
            (progn
              (princ "\n The user pressed Okay!")
            )
          )
        )
      )
    )
  )

  (princ)
)
0 Likes
723 Views
7 Replies
Replies (7)
Message 2 of 8

jotaferrer
Advocate
Advocate

Hey @Nathan_Tigner about the "size" column, are those blocks the same or you have a different block (which means a different name) for each one? Does the same goes to logo?

0 Likes
Message 3 of 8

Nathan_Tigner
Advocate
Advocate
I planned on having a different block for each radio button selection:

So if you check 22x34, CESO and Landscape, there would be a corresponding block for that selection with it's own name.

There would be a few instances where there wouldn't be a block, like if you checked 30x42, then there would not be a portrait option.

I hope that makes sense.
0 Likes
Message 4 of 8

jotaferrer
Advocate
Advocate
Ok then, got it! It's totally possible to avoid user doing wrong selections. But you need someone to write it to you or do you want a guide?
0 Likes
Message 5 of 8

Nathan_Tigner
Advocate
Advocate
I tried looking through others people lisps to see if I could make it work myself, but I never even got close. My lisp knowledge isn't great, so I'm not sure I could get there even with a guide.
Message 6 of 8

jotaferrer
Advocate
Advocate

Oh it's fine, I'm going to start your code asap...

0 Likes
Message 7 of 8

Sea-Haven
Mentor
Mentor

Something like this its a library routine for 2 radio button columns.

 

SeaHaven_0-1651022356219.png

 

(if (not ah:buttscol)(load "Multi Radio buttons 2col.lsp"))
(if (= ah:2col nil)(setq ah:2col 1))
(if (= ah:2col2 nil)(setq ah:2col2 1))
(setq lst1 (list "Select number" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"))
(setq lst2 (list "Select Char" "A" "B" "C" "D"))
(ah:buttscol ah:2col ah:2col2 "Please choose" lst1 lst2)
(setq ans1 (nth ah:2col lst1))
(setq ans2 (nth ah:2col2 lst2))

 

Edit lst1 and lst2 to suit

0 Likes
Message 8 of 8

jotaferrer
Advocate
Advocate

Here is your lisp to insert the blocks but I need your blocks to set the everything and put it to work! Or you can take my code and try to figure it out, it's up do you buddy.

 

About the orientation, I couldn't make it work because I didn't have the blocks, but I can make it work

0 Likes