Jump to content

Recommended Posts

Posted

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?

Posted

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

Posted

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

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...