Author Topic: How to add specific name of blocks to my popup_list  (Read 2969 times)

0 Members and 1 Guest are viewing this topic.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
How to add specific name of blocks to my popup_list
« on: October 11, 2011, 02:59:49 PM »
Hello ...

Is it possible to include specific name of blocks to my popup_list dialog box ?

My dialog box ..

Code: [Select]
Test: dialog {
    label = "Block Insertion ";
    :popup_list
    { label = "Blocks"; key = "blks"; width = 40.0; }
    :boxed_row {
    : button
    { key = "accept"; label = "&OK"; width = 20.0; is_default = true; is_cancel = true; allow_accept =true; }
    : button
    { key = "cancel"; label = "&Cancel"; width = 20.0; is_cancel = true; allow_accept =true; }
             }
             }

Part of lisp routine which would load the dialog box and add the list of strings to it which they are representing name of blocks , but whatever strings are existed in the current open drawing or not .

So I looking forward to include in my dialog box specif name of blocks only if they are existed in the current open drawing .

Code: [Select]
(setq blklst '("elb 20mm" "elb 25mm" "elb 32mm" "elb 50mm" "elb 62mm" "elb 75mm"))
  (setq dialogshow T)
  (setq dcl_id (load_dialog "Test.dcl"))
  (if (not (new_dialog "Test" dcl_id))
    (setq dialogshow nil)
  )
(if dialogshow
(progn 
(start_list "blks")
  (mapcar 'add_list blklst)
  (end_list)))

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: How to add specific name of blocks to my popup_list
« Reply #1 on: October 11, 2011, 04:40:02 PM »
Maybe something like:

Code: [Select]
(start_list "blks")
(foreach block blklst
    (if (tblsearch "BLOCK" block)
        (add_list block)
    )
)
(end_list)

BTW, the OK & Cancel buttons are a predefined widget and can be created using just:

Code: [Select]
ok_cancel;   

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to add specific name of blocks to my popup_list
« Reply #2 on: October 12, 2011, 04:59:10 AM »
Maybe something like:

Code: [Select]
(start_list "blks")
(foreach block blklst
    (if (tblsearch "BLOCK" block)
        (add_list block)
    )
)
(end_list)
   

Worked perfectly . Thank you so much Lee .

BTW, the OK & Cancel buttons are a predefined widget and can be created using just:

Code: [Select]
ok_cancel;   

Would the OK & Cancel buttons going to be without a action_tile and get_tile functions and so on ..... ?

Maybe with a simple example would be clearer and highly appreciated .  :-)

Tharwat

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: How to add specific name of blocks to my popup_list
« Reply #3 on: October 12, 2011, 08:18:51 AM »
BTW, the OK & Cancel buttons are a predefined widget and can be created using just:

Code: [Select]
ok_cancel;   

Would the OK & Cancel buttons going to be without a action_tile and get_tile functions and so on ..... ?

That would depend upon whether you needed any expressions evaluated before the dialog is closed, (i.e. before a call to done_dialog).

If no expressions need to be evaluated when the user clicks OK or Cancel, these buttons do not require action_tile statements since the done_dialog call is predefined with tiles that use the 'accept' or 'cancel' keys, with a status argument of 1 and 0 respectively.

A quick example:

DCL code (save as example.dcl)
Code: [Select]
example : dialog { label = "Select a Block"; spacer;
    : popup_list { key = "blocks"; }
    spacer; ok_cancel;
}

LISP code:
Code: [Select]
(defun c:test ( / block def id lst )
    (if
        (and
            (progn
                (while (setq def (tblnext "BLOCK" (null def)))
                    (if (zerop (logand 4 (cdr (assoc 70 def))))
                        (setq lst (cons (cdr (assoc 2 def)) lst))
                    )
                )
                (if lst (setq lst (acad_strlsort lst)))
            )
            (< 0 (setq id (load_dialog "example.dcl")))
            (new_dialog "example" id)
        )
        (progn
            (start_list "blocks")
            (foreach block lst (add_list block))
            (end_list)

            (set_tile    "blocks"  (setq block "0"))
            (action_tile "blocks" "(setq block $value)")

            (if (= 1 (start_dialog))
                (alert (strcat "You selected:\n" (nth (atoi block) lst)))
            )
        )
    )
    (if (< 0 id) (unload_dialog id))
    (princ)
)

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: How to add specific name of blocks to my popup_list
« Reply #4 on: October 12, 2011, 08:40:56 AM »
BTW, all of this information can be found in the VLIDE Help Docs:

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to add specific name of blocks to my popup_list
« Reply #5 on: October 12, 2011, 09:11:42 AM »
Thanks a lot .

A very good DCL codes and it's more than enough .

 I haven't worked with DCL codes for a long time now , and I think I have got to keep on coding with DCL to make it stick in mind .  :laugh:

Highly appreciated .

Tharwat


Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: How to add specific name of blocks to my popup_list
« Reply #6 on: October 12, 2011, 09:43:25 AM »
You're welcome.  :-)

If you have any questions about the posted example, feel free to ask.

Lee