guitarguy1685 Posted March 24, 2010 Posted March 24, 2010 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 (vl-cmdf "-insert" WBIns P1 "1" "1" pause) If the block does not exist the lisp does this 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? Quote
JohnM Posted March 24, 2010 Posted March 24, 2010 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 Quote
guitarguy1685 Posted March 25, 2010 Author Posted March 25, 2010 nice nice. wow findfile I didn't know it existed thanks alot Quote
alanjt Posted March 25, 2010 Posted March 25, 2010 Try this... (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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.