wimal Posted July 30, 2019 Share Posted July 30, 2019 (vl-load-com) (setq lst nil);wimal (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (vlax-for i (vla-get-blocks adoc) (setq lst (cons (cons (vla-get-name i) i) lst))) (setq blocklist(vl-sort (mapcar (function car) lst) '<)) (setq flag(member "QkDotOnBar" blocklist)) (command "donut""0""1"(list 0 0)""); create donut (setq blk (entlast)) (command "_block""QkDotOnBar"(list 0 0)blk"");create a block I am going to create a block named QkDotOnBar by lisp.above code is warning that same named block is already there. But if there is a block name Qkdotonbar it does not identity the block. But when I try to create a block name QkDotOnBar it does not run and create a error.How can I solve this problem. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted July 30, 2019 Share Posted July 30, 2019 Block Names are not case sensitive therefore to Autocad "qwerty" is the same as "QWERTY" or "QwErTy" 1 Quote Link to comment Share on other sites More sharing options...
wimal Posted July 30, 2019 Author Share Posted July 30, 2019 4 minutes ago, dlanorh said: Block Names are not case sensitive therefore to Autocad "qwerty" is the same as "QWERTY" or "QwErTy" Yes My Title is incorrect. But there is a problem creating blocks by lisp. Quote Link to comment Share on other sites More sharing options...
rlx Posted July 30, 2019 Share Posted July 30, 2019 (edited) just a guess : -block v.s. _block ps, and you may want to check in the block dialog your 'retain objects' settings. Else block is created , but you still have to insert it afterwards and code could be shorter and you can also use (If (not (tblsearch "block" "QkDotOnBar")).... (defun tmp (/ lst i blk) (vl-load-com) (vlax-for i (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (setq lst (cons (strcase (vla-get-name i)) lst))) (if (not (member (strcase "QkDotOnBar") lst)) (progn (command "donut" "0" "1" (list 0 0) "") ; create donut (setq blk (entlast)) (command "-block" "QkDotOnBar" (list 0 0) blk "") ) ) ) (defun tmp2 ( / bn) (if (not (tblsearch "block" (setq bn "QkDotOnBar"))) (progn (command "donut" "0" "1" (list 0 0) "")(command "-block" bn (list 0 0) (entlast) "")))) Edited July 30, 2019 by rlx Quote Link to comment Share on other sites More sharing options...
dlanorh Posted July 30, 2019 Share Posted July 30, 2019 The block name may be case insensitive but the checks ARE Convert everthing to uppercase (setq lst (cons (cons (strcase (vla-get-name i)) i) lst))) (setq flag (member (strcase "QkDotOnBar") blocklist)) 1 Quote Link to comment Share on other sites More sharing options...
wimal Posted July 30, 2019 Author Share Posted July 30, 2019 1 hour ago, dlanorh said: (setq lst (cons (cons (strcase (vla-get-name i)) i) lst))) Grate You gave me a real solution . Thanks a lot. Quote Link to comment Share on other sites More sharing options...
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.