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


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
If the block does not exist the lisp does thisCode:(vl-cmdf "-insert" WBIns P1 "1" "1" pause)
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?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.


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


nice nice. wow findfile I didn't know it existed thanks alot
Registered forum members do not see this ad.
Try this...
This will only insert if it either finds the block definition in the drawing or finds the block file in a support path.Code:(and (or (tblsearch "block" BLOCKNAME) (findfile BLOCKNAME.DWG)) (vl-cmdf "_.-insert"....
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...
Bookmarks