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

±0.00 issue

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
439 Views, 7 Replies

±0.00 issue

Hey guys,

 

I'm running a Lisp, which was created by hmsilvia. It creates hightlabels based on the UCS in an elevation. I thought everything would work great, but then i mentioned that ±0.00 label won't work as it should. Everytime I update the height it removes the "±" in front of the 0.00. It works great with the "+" and "-" label, but won't run when there is no elevation.

 

any Ideas how to update the code?

here is the original code from hmsilvia:

 

(defun c:test ( / *error* ATT ENT HND ITM NUM OLD_ZIN PT S1 TXT Y)

  (defun *error* ( msg )
  (if Old_zin (setvar 'DIMZIN Old_zin))
  (if (not (member msg '("Function cancelled" "quit / exit abort")))
    (princ (strcat "\nError: " msg)))
  (princ)
  )

  (if (setq s1 (ssget "_:L" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," "__Hoehenkote")) '(66 . 1) (cons 410 (getvar 'CTAB)))))
    (progn
      (setq Old_zin (getvar 'DIMZIN))
      (setvar 'DIMZIN 0)
      (setq itm 0 num (sslength s1))
      (while (< itm num)
      (setq hnd	(ssname s1 itm))
	(if (eq	(vla-get-effectivename (vlax-ename->vla-object hnd)) "__Hoehenkote")
	  (progn
	    (setq ent (entget hnd)
		  att (entget (entnext hnd))
		  pt  (trans (cdr (assoc 10 ent)) 0 1)
		  y   (/ (cadr pt) 100.0))
	    (cond ((> y 0.0)
		   (setq txt (strcat "+" (rtos y 2 2)))
		  )
		  ((= y 0.0)
		   (setq txt (strcat "±" (rtos y 2 2)))
		  )
		  (T (setq txt (rtos y 2 2)))
	    );; cond
	    (entmod (subst (cons 1 txt) (assoc 1 att) att))
	  );; progn
	);; if
	(setq itm (1+ itm))
	);; while
      (setvar 'DIMZIN Old_zin)
      );; progn
    );; if
  (princ)
  );; test

 thanks for any help,

klingi

7 REPLIES 7
Message 2 of 8
hmsilva
in reply to: Anonymous

Hi klingi,

I'm sure that was not hmsilvia who made the code, it was hmsilva...

The code should work Ok every time...

I don't have AutoCAD here, so untested, but try...

 

(defun c:test ( / *error* ATT ENT HND ITM NUM OLD_ZIN PT S1 TXT Y)

  (defun *error* ( msg )
  (if Old_zin (setvar 'DIMZIN Old_zin))
  (if (not (member msg '("Function cancelled" "quit / exit abort")))
    (princ (strcat "\nError: " msg)))
  (princ)
  )

  (if (setq s1 (ssget "_:L" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," "__Hoehenkote")) '(66 . 1) (cons 410 (getvar 'CTAB)))))
    (progn
      (setq Old_zin (getvar 'DIMZIN))
      (setvar 'DIMZIN 0)
      (setq itm 0 num (sslength s1))
      (while (< itm num)
      (setq hnd	(ssname s1 itm))
	(if (eq	(vla-get-effectivename (vlax-ename->vla-object hnd)) "__Hoehenkote")
	  (progn
	    (setq ent (entget hnd)
		  att (entget (entnext hnd))
		  pt  (trans (cdr (assoc 10 ent)) 0 1)
		  y  (atoi (rtos (/ (cadr pt) 100.0) 2 2)));; change the precision as suits
	    (cond ((> y 0.0)
		   (setq txt (strcat "+" (rtos y 2 2)))
		  )
		  ((= y 0.0)
		   (setq txt (strcat "±" (rtos y 2 2)))
		  )
		  (T (setq txt (rtos y 2 2)))
	    );; cond
	    (entmod (subst (cons 1 txt) (assoc 1 att) att))
	  );; progn
	);; if
	(setq itm (1+ itm))
	);; while
      (setvar 'DIMZIN Old_zin)
      );; progn
    );; if
  (princ)
  );; test

 

Hope that works always as it should

Henrique

EESignature

Message 3 of 8
Anonymous
in reply to: hmsilva

Sorry Henrique for misspelling your name... Smiley Embarassed, I'm glad I linked to your right profile though. 

 

Thanks for your prompt reply. I know we where already discussing this issue once and it worked pretty good, but now that we updated from Acad 2010 to Acad 2014 it didn't work anymore...

 

Your new code did the trick henrique!

many thanks again

Message 4 of 8
hmsilva
in reply to: Anonymous

You're welcome, klingi
Glad I could help

Henrique

EESignature

Message 5 of 8
Anonymous
in reply to: hmsilva

only problem is, that it doesn't show the numbers behind the comma anymore. for example +6.64 is written as +6.00

 

what do I have to change? 

thanks again

Message 6 of 8
hmsilva
in reply to: Anonymous

Sorry, my bad
change "atoi" to "atof"...

Henrique

EESignature

Message 7 of 8
Anonymous
in reply to: hmsilva

great, thanks! Smiley Happy

Message 8 of 8
hmsilva
in reply to: Anonymous

You're welcome, klingi

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost