Jump to content

Recommended Posts

Posted

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.

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • dreams

    12

  • Tharwat

    7

  • MSasu

    3

  • fixo

    1

Top Posters In This Topic

Posted

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.

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

Posted

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

Posted

acad2007doc.lsp

 

Here is the file which i edited one...I was added in the last line..

 

Please correct this file if i am wrong..

Posted

You haven't use acadxxxx.lsp use instead acadoc.lsp or acad.lsp

Posted

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.

Posted

Hi MSasu/Tharwat..Its working fine..thanks for the help..

 

It would be very helpful to my work...Thanks

  • 8 months later...
Posted

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")
)

Posted

I guess it depends on how you feed the filter for the ssget function so you can have the same string in your alert function . ;)

Posted

Hi Tharwat, Thanks for the reply. .. I tried already but its not working.

 

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

Posted

 

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 .

Posted

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")
)
)

Posted

Also it's not finding same text in other cases (Upper, lower & Title case)...

Posted

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 "
 )
)

Posted

Hi Tharwat...It’s working awesome & super..This is what i expected..

 

Thanks again

Posted

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

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