Go Back   Cadalyst Discussion Forums > Forums > Hot Tip Harry: AutoCAD Customization
FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Notices

Hot Tip Harry: AutoCAD Customization Cadalyst's popular Hot Tip Harry and his entourage are here to assist you with AutoCAD customization. Request help with a programming problem, locate a needed routine, or just keep up with Harry's latest activities. You'll find Harry's archive of AutoLISP and VBA code and hatch patterns at www.cadalyst.com/cadtips. Moderated by R.K. McSwain.

 
 
Thread Tools Display Modes
  #1  
Old 03-30-2009, 01:23 PM
cedwards's Avatar
cedwards cedwards is offline
Member
 
Join Date: Aug 2008
Location: Tennessee
Posts: 46
Question AutoCAD 2010 LISP Error

Greetings everyone...Our office just received AutoCAD 2010 and I'm the ginnie pig right now. Anyway we have a lisp routine that we found/wrote/modified or something that changes all blocks to bylayer(including nested). See below:

Code:
(defun c:nb (/ adoc answer lays lock lay *error* ans0 atype cnt) 
 (defun *error* (msg)(princ msg)
   (if lock (foreach x lock (vla-put-lock x :vlax-true)))(vl-cmdf "_.Redraw")) 
  (vl-load-com)(setq cnt 0) 
  (setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
  (setq lays (vla-get-layers adoc)) 
  (vla-startundomark adoc) 
  (initget "LType LWeight Color All _ T W C A") 
  (if (null (setq answer 
      (getkword "\nChange Blocks [LType/LWeight/Color/All] <All> : ")))
    (setq answer "A")) ;_ end of if
  (setq atype "byLayer")
  (setq ans0 "No")
  (vlax-for item (vla-get-blocks adoc) 
    (if   (not (wcmatch (strcase (vla-get-name item) t) "*_space*"))
      (progn
      (setq cnt (1+ cnt))
      (grtext -1 (strcat "Modyfied " (vla-get-name item)))
   (vlax-for   sub_item (vla-item (vla-get-blocks adoc) (vla-get-name item)) 
   (setq lay (vla-item lays (vla-get-layer sub_item))) 
   (if (= (vla-get-lock lay) :vlax-true) 
   (progn (vla-put-lock lay :vlax-false)(setq lock (cons lay lock))))  
   (if (= ans0 "Yes")(vla-put-Layer sub_item "0"))
   (cond 
     ((= answer "W") 
      (vla-put-LineWeight sub_item (if (= atype "byLayer") acLnWtByLayer aclnwtbyblock))
      ) 
     ((= answer "T") 
      (vla-put-linetype sub_item (if (= atype "byLayer") "ByLayer" "ByBlock"))
      ) 
     ((= answer "C") 
      (vla-put-color sub_item (if (= atype "byLayer") acByLayer acByBlock))
      ) 
     (t 
      (vla-put-LineWeight sub_item (if (= atype "byLayer") acLnWtByLayer aclnwtbyblock))
      (vla-put-linetype sub_item (if (= atype "byLayer") "ByLayer" "ByBlock"))      
      (vla-put-color sub_item (if (= atype "byLayer") acByLayer acByBlock))
      ) 
     ) ;_ end of cond 
   ) ;_ end of vlax-for
   )
      ) ;_ end of if 
    ) ;_ end of vlax-for 
  (if lock (foreach x lock (vla-put-lock x :vlax-true))) 
  (vla-regen adoc acallviewports) 
  (vla-endundomark adoc)(vl-cmdf "_.Redraw")
  (princ (strcat  "\nModyfied " (itoa cnt) " blocks"))
  (princ) 
  ) ;_ end of defun
Anyways it has worked in previous versions but now when we run it, it seems to lock out with this part of the code "(vl-cmdf "_.Redraw"))"

The exact error that CAD gives me is "Automation Error. Invalid database_.Redraw.

Any help would be greatly appreciated.
  #2  
Old 09-23-2009, 07:21 AM
rkmcswain rkmcswain is offline
Moderator
 
Join Date: May 2007
Location: Houston
Posts: 352
Send a message via Yahoo to rkmcswain
Default

It works fine for me here using 2010.
__________________
R.K. McSwain
CAD Panacea | Hot Tip Harry | Cadalyst Cadtips
  #3  
Old 09-23-2009, 12:49 PM
Cap'n Mac's Avatar
Cap'n Mac Cap'n Mac is offline
Senior Member
 
Join Date: May 2002
Location: Bryan, Texas
Posts: 2,195
Default

Try changing "._Redraw" to ".-Redraw" and see what happens.

Oh, and you might want to hit F1 gor to Redrew and double check it wants no other inputs in your specific install/version.
  #4  
Old 09-23-2009, 04:31 PM
alanjt's Avatar
alanjt alanjt is offline
Senior Member
 
Join Date: Nov 2007
Posts: 307
Default

Quote:
Originally Posted by Cap'n Mac
Try changing "._Redraw" to ".-Redraw" and see what happens.

Oh, and you might want to hit F1 gor to Redrew and double check it wants no other inputs in your specific install/version.
or even (redraw)
  #5  
Old 09-23-2009, 05:09 PM
Walt Bedinger Walt Bedinger is offline
Senior Member
 
Join Date: Oct 2007
Location: Greeley, Colorado
Posts: 274
Default

I ran the code you posted without a problem. I am using 2010 with the update that was released a few weeks ago.
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:22 AM.





Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.