Using variables with entmod

Discussion in 'AutoCAD' started by Jerry Griffin, Mar 10, 2005.

  1. Hello all. I've put together a little routine to add CLR under dimensions.
    My only limitation now is that it changes the dimension text to be associate
    even if the user has overridden the text <>. I'd like to switch that so if
    there is already a text override then it simply adds \X CLR to the override
    instead of completely replacing it with <>\X CLR. I just can't seem to get
    a variable into a list and successfully use it with entmod.

    Here is my working code:

    ;add CLR under dims
    (defun c:clr ( / b1 b2 ck edatalist nfound)
    (setq edatalist (ssget))
    (setq nfound (- (sslength edatalist) 1 ))

    (while (> nfound -1)
    (progn
    (setq tempname(ssname edatalist nfound))
    (setq b1 (entget tempname))
    (if
    (= (cdr (assoc 0 b1)) "DIMENSION")
    (progn
    (setq b2 (list '(1 . "<>\\X CLR")))
    (setq b1 (subst (assoc 1 b2) (assoc 1 b1) b1))
    (entmod b1)
    )
    )
    (setq tempname nil)
    (setq nfound (- nfound 1))
    )
    )
    (princ)
    )


    I was trying somthing like this:

    (setq user_text (cdr (assoc 1 b1)))
    (if (/= nil user_text)
    (setq user_text (strcat user_text "\\X CLR"))
    )

    ...

    (setq b2 (list (1 user_text)))
    (setq b1 (subst (assoc 1 b2) (assoc 1 b1) b1))
    (entmod b1)




    Any pointers are greatly appreciated!



    /Jerry
     
    Jerry Griffin, Mar 10, 2005
    #1
  2. Thanks Jason!

    I need to put more effort into learning vlisp. It always seems so much
    easier to accomplish anything.
     
    Jerry Griffin, Mar 10, 2005
    #2
  3. You're welcome, Jerry.
     
    Jason Piercey, Mar 10, 2005
    #3
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.