+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    79

    Default Need help combing two Lee Mac LISPS

    Registered forum members do not see this ad.

    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!

  2. #2
    Super Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2014
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    1,232

    Default

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

    Code:
    (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)
    )

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  3. #3
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    79

    Default

    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!
    Last edited by eyeofnewt555; 25th Jan 2017 at 12:25 am.

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,365

    Default

    Try the following:
    Code:
    (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)
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    79

    Default

    Registered forum members do not see this ad.

    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!

Similar Threads

  1. PDF LISPs
    By nicolas in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 23rd Sep 2011, 04:13 pm
  2. Help combing two macro's
    By AndyC in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 10
    Last Post: 11th Nov 2010, 07:36 pm
  3. What do these lisps do?
    By chelsea1307 in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 30th Dec 2008, 07:28 pm
  4. Lisps
    By DJM001 in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 28th Apr 2006, 09:53 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts