Jump to content

Retrieving the block name once in block editor


Recommended Posts

Posted

I'm making a lisp to use inside the blockeditor. I have not figured out how to get the block name without having to type it in.. How do I go about achieving this?

Posted

Seems that there is no system variable to store that (for REFEDIT command you have REFEDITNAME).

One solution will be to try to redefine the BEDIT command to get control over user's selection.

 

Regards,

Mircea

Posted

I guess it would depend how you invoke the BEDIT command:

 

(defun c:BedName ()
(setq bn (ssget "_:S:E:L" '((0 . "INSERT"))))
(setq bnm (cdr (assoc 2 (entget (ssname bn 0)))))      
(sssetfirst nil bn)
(command "_bedit")
)
(defun otherFun (b)
     (princ (strcat "\nCurrent Blockname " b":"))
     (setq pt (getpoint "\nPick point:")))

 

(otherfun bnm);

  • 2 weeks later...
Posted

I don't like it, but it works

 

 
(defun c:test ( / l1 p l2 r )
 (vl-load-com)
 (if (eq 1 (getvar 'blockeditor))
   (progn
     (vlax-for x 
       (vla-get-blocks 
         (setq *acdoc*
           (cond  ( *acdoc* )
             ( (vlax-get (vlax-get-acad-object)
                 'ActiveDocument)
             ) 
           )
         )
       )(setq l1 (cons (cons (vla-get-count x) x) l1))
     )
     (setq p
       (entmakex
         (list (cons 0 "point")
           (cons 10 '(0. 0. 0.))
         )
       )
     ) (vl-cmdf "_.bsave")(entdel p)
     (vlax-for x (vla-get-blocks *acdoc*)
       (if
         (not
           (or 
             (vl-position 
               (cons (vla-get-count x) x) 
               l1
             )
             (eq "*MODEL_SPACE"
               (vla-get-name x)
             )
           )
         )(setq l2 (cons x l2))
       )
     ) (alert (vla-get-name (car l2)))
     (vl-cmdf "_.bsave")
   ) (prompt "\nCommand only allowed in block editor!!")
 ) (princ)
)

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