Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
tom_berning
333 Views, 3 Replies

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

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 2020
3 REPLIES 3
Message 2 of 4
pbejse
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 

Message 3 of 4
tom_berning
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 2020
Message 4 of 4
pbejse
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


 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost