• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Distinguished Contributor
    Posts: 157
    Registered: ‎08-08-2006
    Accepted Solution

    Attribute height is changing each time routine is run with an Annotative block

    111 Views, 3 Replies
    04-30-2012 01:22 PM

    I need some help updating a routine I wrote several years ago. I only do programming when absolutely needed so it usually only happens every couple years. I wrote this routine to count nested blocks inside of dynamic blocks to count parking spaces. The routine worked fine but was relying on the ltscale to scale a block containing an attribute for the total number of spaces. I want to update the routine to use an annotative block so the scale doesn't have to be set. I changed my block containing the attribute but now when I run my routine, the attribute height gets changed each time the routine is run. The text just gets larger and larger. Here is the portion of the routine where the attribute info is gathered and updated with the new value for that attribute. If you need the entire routine, I can post it with a slight modification so it will work outside our network.

     

    (defun updateattrib ()
    (setq CNT 0) ; sets count to 0
           (while (< CNT (sslength ss)) ; starts loop while CNT is less than the number of objects in the group
              (setq ele (ssname ss cnt)) ; gets the object name
              (setq blst (entget ele))  ; creates a list of objects inside the block         
              (setq ename (entnext (cdr (assoc -1 blst))))
              (setq edata (entget ename)) ; creates a list of that specific entity name
              (setq SORT (cdr (assoc 0 edata))) ; sets SORT to the entity type
              (if (= (cdr (assoc 0 edata)) "ATTRIB")
                      (progn
                      (setq edata (subst (cons 1 (itoa pcnt))(assoc 1 edata) edata))
                      (entmod edata)
               )
                    )
              (setq CNT (+ CNT 1))
           ) ;first while
    );defun updateattrib

     

    I am running this in Civil 3D 2010 but will want it to work in 2013 so if the solution will only work in 2013, that is fine with me.

     

     

    Tom Berning
    Woolpert, Inc.
    Civil 3D 2013
    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    Re: Attribute height is changing each time routine is run with an Annotative blo

    04-30-2012 08:39 PM in reply to: Tom_Berning

    entmod doesnt work well with Annotative text style

    (defun updateattrib ()
    (vl-load-com) 
    (setq CNT 0) ; sets count to 0
           (while (< CNT (sslength ss)) ; starts loop while CNT is less than the number of objects in the group
              (setq ele (ssname ss cnt)) ; gets the object name
              (setq blst (entget ele))  ; creates a list of objects inside the block        
              (setq ename (entnext (cdr (assoc -1 blst))))
              (setq edata (entget ename)) ; creates a list of that specific entity name
              (setq SORT (cdr (assoc 0 edata))) ; sets SORT to the entity type
              (if (= (cdr (assoc 0 edata)) "ATTRIB")
                (vla-put-textstring   (vlax-ename->vla-object ename)  (itoa pcnt))
    ;;;                  (progn
    ;;;                  (setq edata (subst (cons 1 (itoa pcnt))(assoc 1 edata) edata))
    ;;;                  (entmod edata)
    ;;;           )
                    )
              (setq CNT (+ CNT 1))
           ) ;first while
    )

     

    HTH 

    Please use plain text.
    Distinguished Contributor
    Posts: 157
    Registered: ‎08-08-2006

    Re: Attribute height is changing each time routine is run with an Annotative blo

    05-01-2012 05:37 AM in reply to: pbejse

    Thanks for the help. Since I only get to do programming about once a year, it takes a while to remember everything and when I only want to do a little tweak, it seems to take even longer.

    Tom Berning
    Woolpert, Inc.
    Civil 3D 2013
    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    Re: Attribute height is changing each time routine is run with an Annotative blo

    05-01-2012 09:58 PM in reply to: Tom_Berning

    Tom_Berning wrote:

    Thanks for the help. Since I only get to do programming about once a year, it takes a while to remember everything and when I only want to do a little tweak, it seems to take even longer.


    I know the feeling Tom.

     

    Glad i could help


     

    Please use plain text.