+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2009
    Posts
    171

    Default Failed block insert

    Registered forum members do not see this ad.

    I have a lisp that will insert blocks. However if a block does not exist autocad opens that command window and diplays all the paths that it searched.

    In my lisp I just use a command line to insert. so it looks like this
    Code:
     
    (vl-cmdf "-insert" WBIns P1 "1" "1" pause)
    If the block does not exist the lisp does this

    Code:
     
    Command: _TEST
    Enter block name. <test> test2
    Specify insertion point
    Specify rotation:
    "B0101.dwg": Can't find file in search path:
      C:\Program Files\Autodesk\Acadm 2007\support\
      C:\Program Files\Autodesk\Acadm 2007\fonts\
      C:\Program Files\Autodesk\Acadm 2007\help\
      C:\Program Files\Autodesk\Acadm 2007\express\
      C:\Program Files\Autodesk\Acadm 2007\support\color\
      C:\Program Files\Autodesk\Acadm 2007\drv\
      C:\Program Files\Autodesk\Acadm 2007\
    *Invalid*
    Unknown command "1".  Press F1 for help.
    Unknown command "1".  Press F1 for help.
    the "1"'s are the x/y scale factors. after that the lisp is still pausing. What I want is to make the lisp cancel if the block does not exist. How would I go about doing this?

  2. #2
    Senior Member
    Computer Details
    JohnM's Computer Details
    Operating System:
    xp pro
    Using
    AutoCAD 2006
    Join Date
    Feb 2009
    Location
    houston, texas
    Posts
    380

    Default

    If the block is an external block (WBLOCK) just use the findfile function and if it returns nil ,just exit the program.
    If the block is an internal block (a block in the drawing template) use the tblsearch function and exit if it returns nil

  3. #3
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2009
    Posts
    171

    Default

    nice nice. wow findfile I didn't know it existed thanks alot

  4. #4
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,007

    Default

    Registered forum members do not see this ad.

    Try this...

    Code:
    (and (or (tblsearch "block" BLOCKNAME)
             (findfile BLOCKNAME.DWG))
         (vl-cmdf "_.-insert"....
    This will only insert if it either finds the block definition in the drawing or finds the block file in a support path.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

Similar Threads

  1. Insert Block with VB.NET
    By -KarL- in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 28th Feb 2013, 03:00 am
  2. how to delete a block from the Insert block list
    By Brantis in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 26th Jul 2012, 09:16 am
  3. Block insert
    By Rhayes in forum AutoCAD Drawing Management & Output
    Replies: 10
    Last Post: 8th May 2008, 02:29 am
  4. Block Insertion Failed
    By Cad64 in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 7th Mar 2008, 06:25 pm
  5. Insert A Block
    By raj banerjee in forum AutoCAD General
    Replies: 1
    Last Post: 10th Oct 2007, 12:21 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