See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Lisp routine doesn't work

  1. #1
    Active Member
    Join Date
    2012-02
    Posts
    82
    Login to Give a bone
    0

    Default Lisp routine doesn't work

    I am trying to delete a variety of blocks from a large number of drawings. The DELBLK lisp routine is the only one I have found. The problem is that the DELBLK routine doesn't work. I get an error message or "0 blocks deleted".
    Does anyone have any experience with this lisp routine or have another which does work?
    Thank you

  2. #2
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Lisp routine doesn't work

    I just threw this one together.

    It will delete all blocks in a drawing (including inside other blocks) and purge the drawing of the block definition.

    P=

    ... I made a couple modifications and uploaded the revised file ...

    Code:
    ;___________________________________________________________________________________________________________ 
    ;
    ; Function for deleting blocks from a drawing.
    ; Syntax: (blockdelete "detailbub*")
    ; Written By: Peter Jamtgaard 2014 copyright 2014 all rights reserved
    ;___________________________________________________________________________________________________________
    
    
    (defun C:BlockDelete ()
     (blockdelete (getstring "\nEnter Block Name: "))
    )
    
    
    (defun BlockDelete (strWCBlockName / objBlock lstBlockDefinitions lstBlockInstances)
     (command "layer" "u" "*" "")
     (setq strWCBlockName (strcase strWCBlockName))
     (vlax-for objBlock (vla-get-blocks
                         (vla-get-activedocument
                          (vlax-get-acad-object)))
    
      (if (wcmatch (strcase (vla-get-name objBlock)) strWCBlockName)
       (setq lstBlockDefinitions (cons objBlock lstBlockDefintions))
       (vlax-for objItem objBlock
        (and 
         (wcmatch (vla-get-objectname objItem) "AcDbBlockReference,AcdbMInsertBlock")     
         (wcmatch (strcase (vla-get-name objItem)) strWCBlockName)
         (setq lstBlockInstances (cons objItem lstBlockInstances)) 
        )
       ) 
      )
     )
     (apply 'and
      lstBlockObjects
      (apply 'and (mapcar 'ObjectDelete lstBlockInstances))
      (regen)
      lstBlockDefinitions
      (apply 'and (mapcar 'ObjectDelete lstBlockDefinitions))
     )
    )
    
    
    (defun ObjectDelete (objItem)
     (errortrap (quote (vla-delete objItem)))
    )
    
    (defun Regen ()
     (errortrap (quote (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 0)))
    )
    
    
    ; Standardized Error Trap
    (defun ErrorTrap (symFunction / objError result)
     (if (vl-catch-all-error-p
          (setq objError (vl-catch-all-apply
                         '(lambda (X123)(set X123 (eval symFunction)))
                          (list 'result))))
      nil
      (if result result 'T)
     )
    )
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2015-01-10 at 07:39 AM.
    AutomateCAD

  3. #3
    Active Member
    Join Date
    2012-02
    Posts
    82
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    As they say out on the east coast "beauty, eh". Thanks for the help

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    Quote Originally Posted by boyerd492098 View Post
    As they say out on the east coast "beauty, eh". Thanks for the help
    I thought that was a Canadian thing?
    #Bob&DougMckenzie


  5. #5
    Active Member
    Join Date
    2012-02
    Posts
    82
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    It most certainly is! Nothing like partying with a 2-4 of beer!
    Peter,
    Do you mind if I pass your lisp routine on to others?

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,103
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    Instead of passing it on to others, why not pass them a link to the code?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    2

    Default Re: Lisp routine doesn't work

    Quote Originally Posted by Opie View Post
    Instead of passing it on to others, why not pass them a link to the code?
    +1 Save the complete file and add the link http://forums.augi.com/showthread.ph...doesn-t-work#2 to the comments section.
    That way if you have a problem with the code or would like an added feature later on you know where to ask for it. Knowing where to get code would be more useful to them than just one routine.

    Passing a link is easier than passing a file anyway.

  8. #8
    Active Member
    Join Date
    2012-02
    Posts
    82
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    Good morning Peter,
    I have set up blocks for the Engineers Seal, the companys Permit to Practice and an Issued for Construction stamp. I named them ifc_stamp, permit_stamp, rbh_stamp, jk_stamp. You will notice that they have "_stamp" in common. I tried using a wild card "*_stamp" and it does remove all the visible blocks in the file. But if I open the Insert Block dialogue box I see that not all the blocks have been deleted/purged from the file. Is there some way to enhance your lisp routine to pressure wash all references from the file?
    Thank you

  9. #9
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    I revised the program once, did you try the second version?

    Try the one posted above and see if it does it better.

    That is why I revised it. I noticed that the part where it purges the block definition only deleted one of the definitions.

    The new version should delete all of them

    P=
    AutomateCAD

  10. #10
    Active Member
    Join Date
    2012-02
    Posts
    82
    Login to Give a bone
    0

    Default Re: Lisp routine doesn't work

    Posted above? Where above? I dun't see it.
    Don

Page 1 of 2 12 LastLast

Similar Threads

  1. Getting my lisp routine to work in C3D 2015
    By dmackey.143011 in forum AutoLISP
    Replies: 5
    Last Post: 2015-04-06, 07:22 AM
  2. why doesn't this lisp work in a macro?
    By chuh in forum AutoLISP
    Replies: 12
    Last Post: 2014-09-09, 05:56 PM
  3. LISP to Explode Dynamic Blocks Doesn't Work
    By stusic in forum AutoLISP
    Replies: 35
    Last Post: 2013-06-26, 05:20 PM
  4. Copy LISP doesn't work when zoomed out!
    By brekkja in forum AutoLISP
    Replies: 2
    Last Post: 2013-04-02, 11:23 AM
  5. lisp worked in 07 doesn't work in 09?
    By Hammer.John.J in forum AutoLISP
    Replies: 9
    Last Post: 2009-08-07, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •