Author Topic: Alert message ?  (Read 1205 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Alert message ?
« on: July 18, 2023, 11:56:11 AM »
I haven't used a lot of alert messages but now find myself in need of what would be a complex alert message for me.

I have separate drawing conversion routine that all users are required to run on non-converted drawings prior to running this piece of code which sits inside a large piece of code.

The block STA_ATT_CTL won't exist if the user hasn't run the user required conversion code. I want to alert the user that the drawing must be converted first before the code below will work and if STA_ATT_CTL exists I don't want the alert to fire so the code continues on.

My attempt works in that it shows the alert and doesn't proceed if STA_ATT_CTL exists, but if STA_ATT_CTL exists the alert still pops up yet the routine proceeds.

How do I stop the alert from popping if STA_ATT_CTL exists?

Code - Auto/Visual Lisp: [Select]
  1.  
  2. ;;alert message here. Something like...
  3.   (if (not (tblsearch "block" "STA_ATT_CTL"))
  4.    (alert "The drawing must be converted first.")
  5.  
  6. (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  7.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  8.   (cond
  9.     ((wcmatch (strcase attvalue)
  10.               "LAYOUT,EQUIPMENT PLAN,INTERIOR ELEVATIONS,MC LAYOUT,MC ELEVATIONS"
  11.      )
  12.      (command "-rename" "DIMSTYLE" "DIMEN" "FRACTION")
  13.      ;;) ;;wcmatch
  14.     ) ;;end cond
  15.  
  16.     ((wcmatch (strcase attvalue)
  17.               "MECHANICAL DETAILS"
  18.      )
  19.      (command "-rename" "DIMSTYLE" "DETAIL" "DECIMAL")
  20.     ) ;;wcmatch
  21.   ) ;;end cond
  22.    
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

steve.carson

  • Newt
  • Posts: 108
Re: Alert message ?
« Reply #1 on: July 18, 2023, 12:14:18 PM »
I don't see a closing parenthesis for your if statement, and all the stuff you want to run should be in a progn.

So something like:

Code - Auto/Visual Lisp: [Select]
  1. ;;alert message here. Something like...
  2.   (if (not (tblsearch "block" "STA_ATT_CTL"))
  3.    (alert "The drawing must be converted first.")
  4.  
  5.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  6.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  7.   (cond
  8.     ((wcmatch (strcase attvalue)
  9.               "LAYOUT,EQUIPMENT PLAN,INTERIOR ELEVATIONS,MC LAYOUT,MC ELEVATIONS"
  10.      )
  11.      (command "-rename" "DIMSTYLE" "DIMEN" "FRACTION")
  12.      ;;) ;;wcmatch
  13.     ) ;;end cond
  14.  
  15.     ((wcmatch (strcase attvalue)
  16.               "MECHANICAL DETAILS"
  17.      )
  18.      (command "-rename" "DIMSTYLE" "DETAIL" "DECIMAL")
  19.     ) ;;wcmatch
  20.   ) ;;end cond
  21. ) ;;end progn
  22. ) ;;end if
  23.  
  24.  

I didn't look real close at the rest of your code, but if it worked before (without a closing parenthesis for if), you may have an extra parenthesis in there.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Alert message ?
« Reply #2 on: July 18, 2023, 01:56:29 PM »
Thanks for the reply. I'll give it a shot.

I slapped that alert in there real quick and wasn't too worried about the missing paren.


I don't see a closing parenthesis for your if statement, and all the stuff you want to run should be in a progn.

So something like:

Code - Auto/Visual Lisp: [Select]
  1. ;;alert message here. Something like...
  2.   (if (not (tblsearch "block" "STA_ATT_CTL"))
  3.    (alert "The drawing must be converted first.")
  4.  
  5.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  6.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  7.   (cond
  8.     ((wcmatch (strcase attvalue)
  9.               "LAYOUT,EQUIPMENT PLAN,INTERIOR ELEVATIONS,MC LAYOUT,MC ELEVATIONS"
  10.      )
  11.      (command "-rename" "DIMSTYLE" "DIMEN" "FRACTION")
  12.      ;;) ;;wcmatch
  13.     ) ;;end cond
  14.  
  15.     ((wcmatch (strcase attvalue)
  16.               "MECHANICAL DETAILS"
  17.      )
  18.      (command "-rename" "DIMSTYLE" "DETAIL" "DECIMAL")
  19.     ) ;;wcmatch
  20.   ) ;;end cond
  21. ) ;;end progn
  22. ) ;;end if
  23.  
  24.  

I didn't look real close at the rest of your code, but if it worked before (without a closing parenthesis for if), you may have an extra parenthesis in there.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

BIGAL

  • Swamp Rat
  • Posts: 1425
  • 40 + years of using Autocad
Re: Alert message ?
« Reply #3 on: July 18, 2023, 08:26:49 PM »
My $0.05 the alert can be multi line so a more comprehensive message.

Code: [Select]
(alert "The drawing must be converted first.\n \nWill now exit \nFix then rerun")
You can also display a slide, Vslide,  that can have a lot more detail and images etc, the slide sits there till you press enter.

Another I have is for prompts it displays a message that has a timer so it closes without user input. "Please pick the sq objects"
A man who never made a mistake never made anything

jlogan02

  • Bull Frog
  • Posts: 327
Re: Alert message ?
« Reply #4 on: July 25, 2023, 02:18:14 PM »
The alert pops up and the routine runs all the way through no matter if STA_ATT_CTL exists or doesn't.

I see in my original post I worded things poorly. Simply put, I want the alert to appear if STA_ATT_CTL doesn't exist and for the routine to stop running. If it does exist, don't show the alert, just complete the routine.


Thanks for the reply. I'll give it a shot.

I slapped that alert in there real quick and wasn't too worried about the missing paren.


I don't see a closing parenthesis for your if statement, and all the stuff you want to run should be in a progn.

So something like:

Code - Auto/Visual Lisp: [Select]
  1. ;;alert message here. Something like...
  2.   (if (not (tblsearch "block" "STA_ATT_CTL"))
  3.    (alert "The drawing must be converted first.")
  4.  
  5.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  6.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  7.   (cond
  8.     ((wcmatch (strcase attvalue)
  9.               "LAYOUT,EQUIPMENT PLAN,INTERIOR ELEVATIONS,MC LAYOUT,MC ELEVATIONS"
  10.      )
  11.      (command "-rename" "DIMSTYLE" "DIMEN" "FRACTION")
  12.      ;;) ;;wcmatch
  13.     ) ;;end cond
  14.  
  15.     ((wcmatch (strcase attvalue)
  16.               "MECHANICAL DETAILS"
  17.      )
  18.      (command "-rename" "DIMSTYLE" "DETAIL" "DECIMAL")
  19.     ) ;;wcmatch
  20.   ) ;;end cond
  21. ) ;;end progn
  22. ) ;;end if
  23.  
  24.  

I didn't look real close at the rest of your code, but if it worked before (without a closing parenthesis for if), you may have an extra parenthesis in there.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

steve.carson

  • Newt
  • Posts: 108
Re: Alert message ?
« Reply #5 on: July 25, 2023, 02:22:56 PM »
I'm assuming that the alert pops up because you have the block defined in the drawing, even though there aren't any references. Your code is checking the block table record instead of looking for block references. Purge the drawing and see if the alert still pops up.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Alert message ?
« Reply #6 on: July 25, 2023, 05:24:21 PM »
You are correct. I updated the routine to look for the block in the drawing rather than the block table.

Thanks for the nudge...

Code - Auto/Visual Lisp: [Select]
  1.  ;|lm:getattributevalue courtesy of Lee Mac|;
  2.  
  3.   (defun lm:getattributevalue (blk tag / val enx)
  4.     (while
  5.       (and (null val)
  6.            (= "ATTRIB"
  7.               (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))
  8.            )
  9.       )
  10.       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  11.         (setq val (cdr (assoc 1 enx)))
  12.       )
  13.     )
  14.   )
  15.  
  16.     (if ( not (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1)))))
  17.               (alert "\nThe drawing must be converted first.\n \nRun the Attribute title block conversion and try again.")
  18.     )
  19.     (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  20.     (cond
  21.       ((wcmatch (strcase attvalue)
  22.                 "LAYOUT,EQUIPMENT PLAN,INTERIOR ELEVATIONS,MC LAYOUT,MC ELEVATIONS"
  23.        )
  24.        (command "-rename" "DIMSTYLE" "DIMEN" "FRACTION")
  25.       ) ;;end wcmatch
  26.  
  27.       ((wcmatch (strcase attvalue)
  28.                 "MECHANICAL DETAILS"
  29.        )
  30.        (command "-rename" "DIMSTYLE" "DETAIL" "DECIMAL")
  31.       ) ;;end wcmatch
  32.     ) ;;end cond
  33.    ) ;;end progn
  34.  
  35. ;|-------------------------------------------------------------|;

I'm assuming that the alert pops up because you have the block defined in the drawing, even though there aren't any references. Your code is checking the block table record instead of looking for block references. Purge the drawing and see if the alert still pops up.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

steve.carson

  • Newt
  • Posts: 108
Re: Alert message ?
« Reply #7 on: July 25, 2023, 05:27:23 PM »
Cool, glad it worked.