+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default blkredef.lsp/scr not working in Acade 2010/2012

    Registered forum members do not see this ad.

    Hello,
    I found a lisp on the web to update blocks with a lisp en it is running via a script file.
    If the scrip is running, it searches for a new version of that block. If Autocad can`t find the file he going to the next block in the script. As Autocad find that block, he updates the block. Now comes the problem: after updating that block the script should go to the next block in the script but it stops. So if it`s founds nothing, it goes to to the next one, if it founds one and update that block.it stops.
    Has this lisp/script problem with this versions of Acad or is it an system varaible ore something else. Please help.

    Thanks,

    PmxCAD
    Attached Files

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    (command "._-insert" (strcat blkname "=") "_y" nil "_regen") ;<--- cancels the script...

    You noticed when the block is not found, blkredef will not evaluate the line above thus it continues to the next one. Until such time it does find the block then it cancels the script

    Alternative:
    Code:
    (defun BLKREDEF ( blkname / bn blkname cmde)
    (vl-load-com)      
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))      
     (if (and (tblsearch "block" (vl-filename-base blkname))
             (setq bn (findfile blkname)))
     
      (progn
            (vlax-invoke  (vlax-get
                                (vla-get-ActiveLayout adoc)
                                                  'Block)
                                            'InsertBlock
                                            '(0.0 0.0 0.0)
                                            bn ;<---full path name 
                                            1 1 1 0)
            (entdel (entlast))
            (vla-regen aDoc acActiveViewport)
     (princ (strcat "\nBlock " (strcase (vl-filename-base blkname)) " redefined."))
      )
      (princ "Block not found.")
     )
     (prin1)
    )
    Code:
    (load "D:\\lisp\\blkredef.lsp")
    (BlkRedef "D:\\ThisFolder\\Blocks\\TEST.dwg")
    (BlkRedef "D:\\OtherFolder\\Blocks\\ELEMENT.dwg")
    (BlkRedef "D:\\AnotherFolder\\Blocks\\BMELDER.dwg")
    qsave
    UPDATE CODE:
    to include path...
    Note the syntax ... ".dwg" and "\\"
    Last edited by pBe; 8th Feb 2012 at 10:03 am. Reason: Add lisp code

  3. #3
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default

    Works.....super.

    Tanks,

    PmxCAD

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by pmxcad View Post
    Works.....super.

    Tanks,

    PmxCAD
    Good for you, Glad i could help

  5. #5
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default

    Hello again.

    It`s working perfect, but................a`m working with diffrent projects and diffrent blokcs map/directory, same blocks (names) but with other atributes so the first one in the search-pad is not always ok.
    Question, is it also possible to rebild the lisp so i can put the pad to the blocks directory/map, in the script file?

    Thanks

    Pmxcad

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Check UPDATED CODE [post # 2]

    HTH

  7. #7
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default

    Registered forum members do not see this ad.

    Works super....again.

    Thanks,
    PmxCAD

Similar Threads

  1. 2010 CUI to 2012
    By jmerch in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 0
    Last Post: 26th Jan 2012, 05:15 pm
  2. Spread sheet linking not working in Inventor 2012
    By Ted Lepird in forum Autodesk Inventor
    Replies: 1
    Last Post: 6th Dec 2011, 06:29 pm
  3. aeccimportstyles not working in 2012
    By BIGAL in forum AutoCAD General
    Replies: 2
    Last Post: 16th Sep 2011, 04:15 am
  4. Block insertion not working same in ACAD 2012 vs 2011
    By kabcad in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 17th Aug 2011, 01:35 am
  5. express tool commands are not working in 2012 pls help me
    By afrazawan in forum AutoCAD General
    Replies: 13
    Last Post: 17th May 2011, 03:07 pm

Bookmarks

Posting Permissions

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