Jump to content

Recommended Posts

Posted
(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.

Posted

Block Names are not case sensitive therefore to Autocad "qwerty" is the same as "QWERTY" or "QwErTy"

  • Like 1
Posted
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.

Posted (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 by rlx
Posted

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))

 

  • Thanks 1
Posted
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.

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...