asking for a little lisp file to insert a block

asking for a little lisp file to insert a block

Hans_Knol
Advocate Advocate
259 Views
2 Replies
Message 1 of 3

asking for a little lisp file to insert a block

Hans_Knol
Advocate
Advocate

Hi all,

 

I’m looking for a small tool that looks in the drawing if there a block (invisible) is with a specific name, lets say that the name of the block is “BlockM”, if the block exist there is nothing to do, also not a message, but if it not in the drawing it must be inserted on point 0,0. The block is available in a library what is in the search path of AutoCAD.

 

Hope someone can help me wit a little lisp file like this?

Hans Knol
0 Likes
Accepted solutions (1)
260 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

Something like this?  In simplest terms, it checks whether there is are any insertions of the Block already [not just whether the Block definition exists in the drawing], and if not, puts it in.  Untested:

 

(if (not (ssget "_X" '((0 . "INSERT") (2 . "BlockM"))))

  (command "_.insert" "BlockM" "0,0" "" "" "")

)

Kent Cooper, AIA
0 Likes
Message 3 of 3

paullimapa
Mentor
Mentor

If you meant that the BLOCK may be already in the drawing but not necessarily "Inserted" anywhere yet then you can check for the BLOCK in the drawing database this way:

(if (not (tblsearch "BLOCK" "BlockM"))

 (command "_.Insert" "BlockM" "0,0" "" "" "")

)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes