Lisp and DCL Locks Up When Selecting Objects

Lisp and DCL Locks Up When Selecting Objects

Anonymous
Not applicable
1,082 Views
4 Replies
Message 1 of 5

Lisp and DCL Locks Up When Selecting Objects

Anonymous
Not applicable

I have a lisp and dcl that i am trying to create that will allow users to pick a button from the dcl and load the function associated with the button. The lisp will run is i run it without the dcl, but when i run it with the dcl the lisp locks up on selecting the objects. i need to to select the butoon and continue with the lisp function. Below is my sample code for the dcl and the lisp.

 

DCL...

CSASTATUS : dialog {
 label = "Udate CSA Ojects Per Status Colors";

   label = "CSA Status Updates";
    : button {
        key = "but1";
        label = "&Prelim";
        is_default = false;
        alignment = centered;
        fixed_width = false;
      }
    : button {
        key = "but2";
        label = "&Engineering";
        is_default = false;
        alignment = centered;
        fixed_width = false;
      }
    : button {
        key = "but3";
        label = "&IFC";
        is_default = false;
        alignment = centered;
        fixed_width = false;
      }
    : button {
        key = "cancel";
        label = "&Close";
        alignment = centered;
        is_default = true;
        is_cancel = true;
        fixed_width = true;
      }
      } //end : dialog

 

Lisp...

(prompt "\nType CCC to run...")
(defun *error* (msg) (princ "error: ") (princ msg) (princ))
(defun c:ccc ();define the function
(setq dcl_id (load_dialog "CSASTATUS.dcl"));load the DCL file
 (if (not (new_dialog "CSASTATUS" dcl_id));load the dialogue box
 (exit );if not loaded exit
)
(action_tile "but1" "(doButton 1)");action_tile
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(princ)
);defun
(princ)

(defun doButton(a)
   (cond
 ((= a 1) (Prelim))
 ((= a 2) (Eng))
   )
)

(defun c:Prelim (/ PICKS SS1)
(vl-load-com)
 (setq PICKS (getvar "pickstyle"))
 (setvar "pickstyle" 0)
 (command "-layer" "s" "0" "f" "CL" "")
 (princ "\nSelect objects to change color: ")
 (setq SS1 (ssget))
 (command "_.CHANGE" SS1 "" "_properties" "_LAYER" "COL" "")
 (command "-layer" "s" "0" "t" "CL" "")
 (setvar "pickstyle" 1)
 )

0 Likes
Accepted solutions (1)
1,083 Views
4 Replies
Replies (4)
Message 2 of 5

rkmcswain
Mentor
Mentor
Accepted solution

Quick and dirty edits.... but it works for me....

 

(prompt "\nType CCC to run...")
(defun *error* (msg) (princ "error: ") (princ msg) (princ))
(defun c:ccc ();define the function
(setq dcl_id (load_dialog "CSASTATUS.dcl"));load the DCL file
 (if (not (new_dialog "CSASTATUS" dcl_id));load the dialogue box
 (exit );if not loaded exit
)
(action_tile "but1" "(setq dobutton 1)(done_dialog)");action_tile
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(if (eq dobutton 1)
  (prelim)
)
);defun

;;;(defun doButton(a)
;;;   (cond
;;; ((= a 1) (Prelim))
;;; ((= a 2) (Eng))
;;;   )
;;;)
(defun prelim (/ PICKS SS1)
(vl-load-com)
 (setq PICKS (getvar "pickstyle"))
 (setvar "pickstyle" 0)
 (command "-layer" "s" "0" "f" "CL" "")
 (princ "\nSelect objects to change color: ")
 (setq SS1 (ssget))
 (command "_.CHANGE" SS1 "" "_properties" "_LAYER" "COL" "")
 (command "-layer" "s" "0" "t" "CL" "")
 (setvar "pickstyle" 1)
 )

 Your code was not crashing 2016 for me, but I was getting an unhandled exception. I called (done_dialog) before calling the (prelim) function, which includes the (command) function. I suspect this was a large part of the issue.

 

 

 

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 5

Anonymous
Not applicable

I just noticed that the cancel or close button still envokes that commands. Why?

0 Likes
Message 4 of 5

rkmcswain
Mentor
Mentor
Because I was at lunch and didn't take the time to inspect everything 🙂

Probably because we didn't declare the variable "dobutton" local, so it's stays = 1 while you're in that drawing.
R.K. McSwain     | CADpanacea | on twitter
Message 5 of 5

scot-65
Advisor
Advisor

Let's take a closer look at your code and properly structure it.

 

I see no errors in the DCL part. All looks good to me.

 

First, let's take advantage of the done_dialog return of an integer to start_dialog:

(action_tile "but1" "(done_dialog 1)")

(action_tile "but2" "(done_dialog 2)")

(action_tile "but3" "(done_dialog 3)")

etc.

(action_tile "cancel" "(done_dialog 0)")

 

Now, let's assign a variable to the start_dialog thingey:

(setq sd (start_dialog))

 

And finally, to enter into the *main* program:

(if (and sd (> sd 0))

 (cond

  ((= sd 1) ...)

  ((= sd 2) ...)

  etc.

 );cond

);if

 

The objective here is to first gather User input. Do not pass Go. Do not collect $200.

Once the user input is gathered, close the dialog and proceed to the main program.

 

[commands are not allowed when a dialog is open - which is how your program is currently structured]

 

As a helpful hint, avoid placing the call to done_dialog away from action_tile line.

This will help better read the code. For instance, I wish to take a "snapshot" of the

current state of each tile. I would do something like this:

(action_tile "accept" "(User_GET)(done_dialog 1)")

Where User_GET is a subroutine where I will gather [get_tile] all the tile values - as a LIST.

 

Another hint is to place subroutines or functions above the main program.

By doing so, and canceling out the first line "(defun c:CCC..." and the last line ");end CCC",

loading the program directly will not require a command to start the routine (the load

will start the routine).

 

I do have templates uploaded here on this site that may help.

 

Hope this helps.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.