Jump to content

Recommended Posts

Posted

Hey guys!

 

So the amazing Lee Mac wrote two different versions of a LISP based on a request I posted. Workflow demands have changed and now I need to modify the lisp to be somewhere in between the two versions.

 

Version 1 & Version 2.

 

For the combo lisp, I need:

 

  1. The block multileader to populate from the block's description, rather than name (like it does in Version 1).

    If there is no description, then the contents should default on block name (not from either version, but it would be helpful. I'm not sure how tricky it would be to code)


  2. The block multileader to automatically start at the block's insertion point (like it does in Version 2).
  3. The hatch multileader component is perfect in both versions (pulling the name and prompting for first click as insertion point)

 

I tried fiddling around with it, but am too much of a noob to really make heads or tails of what's going on between the two versions (to my amateur eyes, the methods used between the two are too different for me to reconcile).

 

Thanks for any help!

Posted

If I understood correctly... (So simple - you could certainly figured this out...)

 

(defun c:hbml ( / blk ent enx sel str )
 (vl-load-com)
 (setq blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
 (if (setq sel (ssget "_+.:E:S" '((0 . "INSERT,HATCH"))))
   (progn
     (command "_.mleader")
     (if (= "INSERT" (cdr (assoc 0 (setq enx (entget (setq ent (ssname sel 0)))))))
       (command "_non" (trans (cdr (assoc 10 enx)) (cdr (assoc -1 enx)) 1))
       (command "\\")
     )
     (if (= "INSERT" (cdr (assoc 0 enx)))
       (if (/= "" (setq str (vla-get-comments (vla-item blk (vla-get-name (vlax-ename->vla-object ent))))))
         (command "\\" str)
         (command "\\" (cdr (assoc 2 enx)))
       )
       (command "\\" (cdr (assoc 2 enx)))
     )
   )
 )
 (princ)
)

Posted (edited)

Thanks, Marko for writing this. Unfortunately, it looks like it's pulling the block's name, not the description. I'd like it to default on pulling the description and then fall back on using the name only if there is no description.

 

Edit: My bad, I was implementing the wrong thing. Yours actually seems to work just fine, thanks!

Edited by eyeofnewt555
Posted

Try the following:

(defun c:hbml ( / blk com ent enx )
   (while
       (not
           (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block or hatch <exit>: ")))
               (cond
                   (   (= 7 (getvar 'errno))
                       (prompt "\nMissed, try again.")
                   )
                   (   (null ent))
                   (   (= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
                       (setq blk (LM:name->effectivename (cdr (assoc 2 enx)))
                             str (cdr (assoc 4 (tblsearch "block" blk)))
                             com (list "_non" (trans (cdr (assoc 10 enx)) ent 1) "\\" (if (and str (/= "" str)) str blk))
                       )
                   )
                   (   (= "HATCH" (cdr (assoc 0 enx)))
                       (setq com (list "\\" "\\" (cdr (assoc 2 enx))))
                   )
                   (   (prompt "\nInvalid object selected."))
               )
           )
       )
   )
   (if com (apply 'vl-cmdf (cons "_.mleader" com)))
   (princ)
)

;; Block Name -> Effective Block Name  -  Lee Mac
;; blk - [str] Block name

(defun LM:name->effectivename ( blk / rep )
   (if
       (and (wcmatch blk "`**")
           (setq rep
               (cdadr
                   (assoc -3
                       (entget
                           (cdr (assoc 330 (entget (tblobjname "block" blk))))
                          '("AcDbBlockRepBTag")
                       )
                   )
               )
           )
           (setq rep (handent (cdr (assoc 1005 rep))))
       )
       (cdr (assoc 2 (entget rep)))
       blk
   )
)

(princ)

Posted

Lee Mac, thanks for responding to the Bat Signal. You rock! And I was wrong, it looks like Marko's works as well. But ain't gonna lie, I stick with Lee Mac code when that's an option.

 

Thanks again!

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