• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Member
    Posts: 4
    Registered: ‎02-26-2010

    Block in MLEADER

    319 Views, 3 Replies
    09-27-2010 02:27 PM

    Hello,

    We have a block contain 10 attibs to be seen with 8 differents scales making 80 attribs!  (We use that before Annotative features). When we edit this block, we have a LISP that ask for the 10 avlues, and copy it for all the scale.

    This lisp use the block ename in argument.

     

    We start to use that  block with MLEADER, but we can not edited with our lisp (can not find the ename of the block in the MLEADER definition ).

    Is that a way to find this ename, and to be able to modify (our substitute) all the attributes value.

     

     

     

     

    Stephane

    Stephane A. Aubertin
    Responsable - traitement de l'information (gestion des espaces)
    Service de la planification et des projets immobiliers
    HEC Montréal
    www.hec.ca
    Please use plain text.
    Mentor
    Posts: 2,504
    Registered: ‎02-17-2004

    Re: Block in MLEADER

    09-28-2010 10:11 AM in reply to: stephane.aubertin

    Here is an example of how you can do it.  You supply it an associated list of tag names and new values.  It will search the whole drawing for mleaders, and change the attributes that match, no matter the block name.  So you might want to change it a little, but it will be a good starting point.

     

    (defun UpdateMleaderAttributes ( attList / cnt ss Ent tempList ChangeAtt newEntData )
        ; Will update all mleaders whose attribute's tag matches those in the attList argument.
        ; Call like (UpdateMleaderAttributes '(("DETAIL" . "1")("SHEET" . "S-2.4")))
        
        (setq cnt -1)
        (if (setq ss (ssget "_x" '((0 . "MULTILEADER"))))
            (while (setq Ent (ssname ss (setq cnt (1+ cnt))))
                (foreach i (entget Ent)
                    (if
                        (and
                            (equal (type (cdr i)) 'ENAME)
                            (setq tempList (assoc (cdr (assoc 2 (entget (cdr i)))) attList))
                        )
                        (setq ChangeAtt T)
                    )
                    (setq newEntData
                        (cons
                            (if
                                (and
                                    ChangeAtt
                                    (equal (car i) 302)
                                )
                                (progn
                                    (setq ChangeAtt nil)
                                    (cons 302 (cdr tempList))
                                )
                                i
                            )
                            newEntData
                        )
                    )
                )
                (entmod (reverse newEntData))
                (setq newEntData nil)
            )
        )
        (princ)
    )

    Please use plain text.
    Contributor
    bbarkman
    Posts: 18
    Registered: ‎09-28-2010

    Re: Block in MLEADER

    09-21-2012 07:06 AM in reply to: stephane.aubertin

    What if I want to add a prompt?

     

     I added this line;

    (setq newval (getstring "\nEnter new Revision value:"))

     

    Then tweaked your command like this;

    (UpdateMleaderAttributes '(("REVNUM" . newval)))

     

    I was not able to change the attribute in my multileader.  Any ideas?

     

    Thanks in advance.

    Please use plain text.
    Member
    Posts: 4
    Registered: ‎02-26-2010

    Re: Block in MLEADER

    09-21-2012 07:57 AM in reply to: bbarkman

    It was to complex to use Mleader with Block and rewrite our lisp to control content of the attribs. So we decided to use ordinary Leader and associate them with our Block  in a Unnamed Group.
    This way our old lisp was able to control then content of the block.

     

    I hope this suggestion helps

     

    Stephane

    Stephane A. Aubertin
    Responsable - traitement de l'information (gestion des espaces)
    Service de la planification et des projets immobiliers
    HEC Montréal
    www.hec.ca
    Please use plain text.