Jump to content

Alert needed while opening CAD file


dreams

Recommended Posts

Can someone help me to fix this issue?

 

Is it possible to set an alert (with using particular text in inside the CAD file) while opening CAD files each time?

 

Example: The alert will be “You have used IBM in this drawing”, if we have a text noted as “IBM” inside the CAD file.

Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • dreams

    12

  • Tharwat

    7

  • MSasu

    3

  • fixo

    1

Top Posters In This Topic

One example for text/mtext entities in active tab - should be placed in a start-up resource (i.e. acaddoc.lsp):

(setq ssText (ssget "_X" '((0 . "*TEXT"))))
(while ssText
(if (wcmatch (cdr (assoc 1 (entget (setq entTemp (ssname ssText 0))))) "*IBM*")
 (setq ssText (alert "You have used IBM in this drawing!"))
)
(setq ssText (ssdel ssText entTemp))
)

This may be extended to verify all tabs, support other entities or check for a list of words.

Link to comment
Share on other sites

Hi MSasu/Tharwat..Thanks...

 

I have added in that lisp file (acaddoc.lsp)...but its not working...I am not familiar in lisp settings..Please help me...

Link to comment
Share on other sites

Please check the tutorial from my previous post to create an user auto-loader. Isn't a good practice to use the system one (acaddoc20##.lsp) since may be overwriten, so may want to avoid this.

Also, you will need to add only one solution there to don't get two warnings in a row; I suggest to use Tharwat's one since is faster.

Link to comment
Share on other sites

  • 8 months later...

Hi Tharwat,

 

I need your help again. Is it possible to add a list of different texts for Alert while opening CAD file? Please refer my sample notes..

 

1.The text is IBM - Alert should shown as "You have used IBM in this drawing"

 

2.The texts are Coupler/Thread/Threading/Threaded/Threading – Alert should shown as “You have used COUPLER/THREADED BARS in this drawing

 

3.The texts are Form savers/End preparation - Alert should shown as “FORM SAVERS are used"

 

The code is below,

 

(setq ssText (ssget "_X" '((0 . "*TEXT"))))
(if (ssget "_X" '((0 . "*TEXT")(1 . "IBM")))
  (alert "You have used IBM in this drawing")
)

Link to comment
Share on other sites

 

FYI, I will have to add more text alert in future...

 

Show me the way you are feeding your strings and functions , to allow me and the other users to know how to make it work for you and try to give you the best solution .

Link to comment
Share on other sites

I am not familiar with lisp codes..

 

Here is the below code details which i tried...

 

((setq ssText (ssget "_X" '((0 . "*TEXT"))))
(if (ssget "_X" '((0 . "*TEXT")(1 . "IBM"))) 
(alert "You have used IBM in this drawing")
)
(if (ssget "_X" '((0 . "*TEXT")(1 . "COUPLER")))
  (alert "You have used COUPLER/THREADED BARS in this drawing")
)
(if (ssget "_X" '((0 . "*TEXT")(1 . "Form savers")))
  (alert "FORM SAVERS are used")
)
(if (ssget "_X" '((0 . "*TEXT")(1 . "coupler")))
  (alert "You have used Coupler in this drawing which we have to provide separate material list")
)
(if (ssget "_X" '((0 . "*TEXT")(1 . "THREAD")))
  (alert "You have used COUPLER/THREADED BARS in this drawing")
)
(if (ssget "_X" '((0 . "*TEXT")(1 . "THREADING")))
  (alert "You have used COUPLER/THREADED BARS in this drawing")
)
)

Link to comment
Share on other sites

Try this .

 

(if (setq ss
          (ssget "_X"
                 '((0 . "*TEXT")
                   (1 . "IBM,COUPLER,Form savers,coupler,THREAD,THREADING")
                  )
          )
   )
 (progn
   (repeat (setq i (sslength ss))
     (setq st (cdr (assoc 1 (entget (ssname ss (setq i (1- i)))))))
     (if (not (member st lst))
       (setq lst (cons st lst))
     )
   )
   (if lst
     (progn
       (setq l (vl-remove-if-not
                 '(lambda (u) (member u lst))
                 '("IBM" "COUPLER" "Form savers" "coupler" "THREAD"
                   "THREADING"
                  )
               )
       )
       (alert
         (strcat
           "You have used < "
           (substr (setq s (apply 'strcat
                                  (mapcar '(lambda (x) (strcat x ",")) l)
                           )
                   )
                   1
                   (1- (strlen s))
           )
           " > in this drawing"
         )
       )
     )
   )
 )
 (alert
   "Couldn't find any of these strings < IBM,COUPLER,Form savers,coupler,THREAD,THREADING > in drawing "
 )
)

Link to comment
Share on other sites

Hi Tharwat, i have an issue while using this lisp, It's not finding the text in the combined sentences. Example: Male Coupler at one End

 

 

FYI, It's finding only separate text only.

 

have you got my point?

 

Do you have any suggestion on this??

Link to comment
Share on other sites

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