Jump to content

Recommended Posts

Posted

Hi,
I'm adding a 'check selection' loop into a lsp, but while one works another does not!
Here's a video, where the first alert works as expected in that when you select 'OK' the alert box closes allowing the user to correct their mistake.
But the second alert, when the user selects 'OK' it closes bothe the alert & the main dialog, and I can't seem to find why?

any thoughts on where I'm going wrong?
https://www.dropbox.com/s/ieqkq2p1btczutr/Alert Message close issue.avi?dl=0

extract from lsp file attached.
 

nest-fittings.zip

Posted

I haven't looked at this properly but you have 2 check selections functions, what happens if you use the one that works for everything? Narrowing down where the problem might be. 

Posted
6 hours ago, Steven P said:

I haven't looked at this properly but you have 2 check selections functions, what happens if you use the one that works for everything? Narrowing down where the problem might be. 

Hi steve,

 

I changed the second check to:

	(cond 
		(
;		(and 
;			(/= ftg NIL)
			(/= fred4 NIL)
;			);end of AND
			(setq sch fred4)
			(done_dialog)
		)
		(t (alert "OOPS! *new dialog* SELECT SCHEDULE - TRY AGAIN!")) 	
	);end of cond

 

taking out the 'ftg' check.

No change, in that if none of the radio buttons associated with 'fred4' are selected, the alert is diaplayed, when you select 'OK' on the alert box ALL dialogs are closed.

  • Like 1
Posted

Think I have it... might be wrong.... 

 

In your video you check the bends, 90 degree, 45 degree, and a pop up DCL is displayed, and then the alert - this works as it should (Check_Selections_N1 function)

Then you select the size? and it all goes wrong (LISP Check_Selections_F function).. and that is where the problem is - in the conds.

 

Looking at Check_Selection_N1 you set ftg (for now). so a going to ignore your conds (/= ftg nil) in check_selection_f

 

What happens if you try this for Check_Selection_F ? Keeping it simple for working out what is happening

 

 

(defun CHECK_SELECTIONS_F ()
  (cond ;Cond statement
    ((and (/= fred4 NIL)(/= SIZE NIL));end of AND
            (done_dialog)
            (princ fred4)(princ "-")(princ SIZE)
    )
    (t (alert "OOPS! *new dialog* SELECT A FITTING SIZE - TRY AGAIN!"))
  );end of cond
) ;end CHECK_SELECTIONS

 

 

Posted

FWIW

;; This 
(and (/= fred4 nil) (/= size nil))
;; Is the same as this
(and fred4 size)

 

  • Like 1
Posted
11 hours ago, Steven P said:

Think I have it... might be wrong.... 

 

In your video you check the bends, 90 degree, 45 degree, and a pop up DCL is displayed, and then the alert - this works as it should (Check_Selections_N1 function)

Then you select the size? and it all goes wrong (LISP Check_Selections_F function).. and that is where the problem is - in the conds.

 

Looking at Check_Selection_N1 you set ftg (for now). so a going to ignore your conds (/= ftg nil) in check_selection_f

 

What happens if you try this for Check_Selection_F ? Keeping it simple for working out what is happening

 

 

(defun CHECK_SELECTIONS_F ()
  (cond ;Cond statement
    ((and (/= fred4 NIL)(/= SIZE NIL));end of AND
            (done_dialog)
            (princ fred4)(princ "-")(princ SIZE)
    )
    (t (alert "OOPS! *new dialog* SELECT A FITTING SIZE - TRY AGAIN!"))
  );end of cond
) ;end CHECK_SELECTIONS

 

 

Steve,

That works, if I complete each selection correctly I get to insert the chosen fitting.

If I select 'OK' without selecting a size, I get the alert, but retun to the dialog to select the missing size.

The same for Schedule.

Also Fred4 & size are listed on the command line matching the relevant selections.

 

10 hours ago, ronjonp said:

FWIW

;; This 
(and (/= fred4 nil) (/= size nil))
;; Is the same as this
(and fred4 size)

Thanks ronjonp

I would never have  got that on my own.

 

Posted

Excellent, so the last cond works, put them back in one at a time and see which one causes the problem?

 

Note that ftg is set with the first check, the degree dialogue, so will always be something - not sure if that causes a problem - perhaps do the second check first and see (CHECK_SELECTIONS_F). It might be that the conds are missing something?

Posted

Something in the back of my head, remembered the code now:

You might try this:

 

(mode_tile "Button_Key" 1)

 

to 'grey out' the OK button until all the criteria are met rather than having alerts

 

(https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-23ACCF72-9C6F-45C0-A889-9307CC1210C2)

Posted (edited)

I think I've got there 🙂

 

Each cond statement worked individually, but as soon as I had 2, one after the other I was back to the same problem.

So had a coffee & small light bulb moment, keep them independant, and make passing the first test call the second test....

 

While in may not be compact it works:

(defun CHECK_SELECTIONS_FE ()
	(cond
		((/= fred3 NIL)
		(setq john fred3)
		(CHECK_SELECTIONS_F)
		)
		((/= ftg NIL)
		(setq john ftg)
		(CHECK_SELECTIONS_F)
		)
	)
) ;end CHECK_SELECTIONS_FE
;
(defun CHECK_SELECTIONS_F ()
  (cond 				;Cond statement
    ((/= fred4 NIL)
            (CHECK_SELECTIONS_FSC)
            (princ fred4)
    )
    (t (alert "OOPS! *new dialog* SELECT A FITTING SCHEDULE - TRY AGAIN!"))
  );end of cond
) ;end CHECK_SELECTIONS_F
;
(defun CHECK_SELECTIONS_FSC ()  
   (cond 				;Cond statement
    ((/= size NIL)
            (done_dialog)
            (princ size)
    )
    (t (alert "OOPS! *new dialog* SELECT A FITTING SIZE - TRY AGAIN!"))
  );end of cond 
) ;end CHECK_SELECTIONS_FSC

 

I can now tidy up a little, replace FRED and his clones 2, 3, 4 etc

 

Thanks for your help 👍

Edited by sln8458
spellllling
  • Like 1

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...