Changing attribute settings - unit precision

Changing attribute settings - unit precision

yu85.info
Collaborator Collaborator
1,892 Views
6 Replies
Message 1 of 7

Changing attribute settings - unit precision

yu85.info
Collaborator
Collaborator

Hi. I have this block (attched). I want to change the precision of the units in the ELEV attribute from - 0.000 

to - 0.00

Is there a simple way to do this?

Thank you very much

0 Likes
Accepted solutions (1)
1,893 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

Well, the easier way to change it is definitely to rewrite the value in the Properties palette manually.

But.... if you have plenty of those objects... then you would need a routine for that. Eg. this one.

 

(vl-load-com)
(defun c:AttRound ( / s a r i e) (if (and (setq s (ssget "_:L" '((0 . "INSERT")))) (setq a (car (nentsel "\nPick an attribute to round: "))) (setq a (cdr (assoc 2 (entget a)))) (setq r (cond ((getint "\nSpecify number or decimal to round to <2>: ")) (2))) ) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (if (not (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list e a)))) (setpropertyvalue e a (rtos (atof (getpropertyvalue e a )) 2 r))))) (princ) )

Learn HERE how to use a LISP if you need to.

 
0 Likes
Message 3 of 7

yu85.info
Collaborator
Collaborator

@ВeekeeCZ  AMAZING! It helped me a lot. 

sorry for being rude... is there a way that I will be able to type the attribute name insted of picking it?

anyway it is a very nice lisp 

thank you very much

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

Sure.

 

(defun c:AttRound ( / s a r i e)

  (if (and (setq s (ssget "_:L" '((0 . "INSERT"))))
	   (setq a (getstring "\nTag: ")
	   (setq r (cond ((getint "\nSpecify number or decimal to round to <2>: ")) (2)))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (if (not (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list e a))))
	(setpropertyvalue e a (rtos (atof (getpropertyvalue e a )) 2 r)))))
  (princ)
  )

 

0 Likes
Message 5 of 7

yu85.info
Collaborator
Collaborator

@ВeekeeCZ  sorry but I tried to load this one and I am getting this massage:

 

Command: (LOAD "D:/InfraTek/LISP/attRound2.lsp") ; error: malformed list on input

 

thank you again

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Sorry, one parent missing.

 

 

 

 

 

(vl-load-com) 

(defun c:AttRound ( / s a r i e)

  (if (and (setq s (ssget "_:L" '((0 . "INSERT"))))
	   (setq a (getstring "\nTag: "))
	   (setq r (cond ((getint "\nSpecify number or decimal to round to <2>: ")) (2)))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (if (not (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list e a))))
	(setpropertyvalue e a (rtos (atof (getpropertyvalue e a )) 2 r)))))
  (princ)
  )

 

 

 

 

Message 7 of 7

yu85.info
Collaborator
Collaborator
Perfect:)

thx

I appreciate it
0 Likes