stepping up attribute values in many blocks?

Discussion in 'AutoCAD' started by The Real JD, Aug 17, 2004.

  1. The Real JD

    Jim Claypool Guest

    So you want to subtract 97.8 from 120,00 to get 22.2,0 and from 250,0 to get
    152.2,0 etc.?
     
    Jim Claypool, Aug 20, 2004
    #21
  2. The Real JD

    Jeff Mishler Guest

    Jim,
    It appears to me that the comma is being used in lieu of the decimal.
    Something in the back of my mind tells me I've seen this notation used
    before......maybe in European documents?
     
    Jeff Mishler, Aug 20, 2004
    #22
  3. The Real JD

    caca Guest

    Hi jim,

    I need to subtract 97,8 from 120,00 to get 22,20 or 97,8 from 250,00 to get 152,20...
     
    caca, Aug 20, 2004
    #23
  4. The Real JD

    Jim Claypool Guest

    Got it. Solution to follow soon.

    Jeff, It looks like you are correct. Thanks for the input.


    get 152,20...
     
    Jim Claypool, Aug 20, 2004
    #24
  5. The Real JD

    Jim Claypool Guest

    Here you go.
    To use it
    (attchg "elevacao_corte_Esq" "EL." 97.8)
    or to do all blocks
    (attchg "*" "EL." 97.8)

    (defun attchg (blk att amt / cnt ss attlist attval)
    (setq att (strcase att))
    (setq ss (ssget "x" (list (cons 2 blk))))
    (if ss
    (progn
    (setq cnt 0)
    (repeat (sslength ss)
    (setq attlist (getatts (ssname ss cnt)))
    (setq attval (cdr (assoc att attlist)))
    (setq attval (vl-string-subst "." "," attval))
    (setq attval (rtos (- (atof attval) amt) 2 2))
    (setq attval (vl-string-subst "," "." attval))
    (setq attlist (subst (cons att attval) (assoc att attlist) attlist))
    (setatts (ssname ss cnt) attlist)
    (setq cnt (1+ cnt))
    );end repeat
    );end progn
    );end if
    (princ)
    )
    (defun GetAtts (Obj)
    (setq obj (vlax-ename->vla-object obj))
    (mapcar
    '(lambda (Att)
    (cons (vla-get-TagString Att) (vla-get-TextString Att))
    )
    (vlax-invoke Obj "GetAttributes")
    )
    )

    (defun SetAtts (Obj Lst / AttVal)
    (setq obj (vlax-ename->vla-object obj))
    (mapcar
    '(lambda (Att)
    (if (setq AttVal (cdr (assoc (vla-get-TagString Att) Lst)))
    (vla-put-TextString Att AttVal)
    )
    )
    (vlax-invoke Obj "GetAttributes")
    )
    (vla-update Obj)
    (princ)
    )

    get 152,20...
     
    Jim Claypool, Aug 20, 2004
    #25
  6. The Real JD

    caca Guest

    Jim,

    The command gives me the following message:

    ; error: no function definition: VLAX-ENAME->VLA-OBJECT

    Regards,
    Carol
     
    caca, Aug 20, 2004
    #26
  7. The Real JD

    T.Willey Guest

    Add (vl-load-com) at the begining of the routine.

    Tim
     
    T.Willey, Aug 20, 2004
    #27
  8. The Real JD

    caca Guest

    HI Jim,

    Like that?
    (vl-load-com attchg "*" "EL." 97.8)?

    I have tried this way and it gives me "; error: too many arguments"

    Thank you again,
    Carol
     
    caca, Aug 20, 2004
    #28
  9. The Real JD

    T.Willey Guest

    Like this
    (defun attchg (blk att amt / cnt ss attlist attval)
    (vl-load-com); <- on it's own line, because it is it's own function
    (setq att (strcase att))

    Sorry didn't explain better the first time.

    Tim
     
    T.Willey, Aug 20, 2004
    #29
  10. The Real JD

    caca Guest

    Jim,

    Sorry, I´ve included the (vl-load-com) right after the line defun and it worked perfectly!

    Thank you very much for you attention!!!!

    Regards,
    Carol
     
    caca, Aug 20, 2004
    #30
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.