Jump to content

add/subtract to a number in an attribute


cestel

Recommended Posts

Hello,

 

I am a newbie to lisp and have a question for all you exprerienced lisp coders. I have a block for elevations, which have to attributes (for concrete and finish elevation).

I want to add a specific number to this attributes. The format is "+7.05" or "-7.00", i found some lisps but they all change the format(if the sum is an integer) to "7" or "-7".:?

 

Does any one used a script adding/subtructing a specific number without deleting the numbers after coma and plus sign? we do not have to select a specific attribute, i can copy to a new file and add/subtract from all att. in that file.

 

i found an older script which is written by ASMI;

http://www.cadtutor.net/forum/showthread.php?21726-Numerical-Global-Block-Attribute&

and a simple one

 


(defun AddNumAtt (add tag / e ei et txt)
(setq e (entnext)
tag (strcase tag))
(while (setq e (entnext e))
(setq ei (entget e)
et (cdr (assoc 0 ei)))
(and (= "ATTRIB" et)
(wcmatch (cdr (assoc 2 ei)) tag)
(setq txt (cdr (assoc 1 ei)))
(numberp (setq num (read txt)))
(entmod
(subst (cons 1 (rtos (+ add num) 2 2)) (assoc 1 ei) ei))  ; ) 2 2)  change second 2 for precision.
(entupd e)))
(princ))

;(AddNumAtt 10 "*") ;  (AddNumatt value to +/-  tagname)


Thanks for your help.

Link to comment
Share on other sites

I want to add a specific number to this attributes. The format is "+7.05" or "-7.00", i found some lisps but they all change the format(if the sum is an integer) to "7" or "-7".:?

 

Without seeing the offending code... The RTOS function *should* be able to fix that. :wink:

Link to comment
Share on other sites

Actually, i really dont know where to add the RTOS functon :cry:

 

No worries, we'll try to help.

 

Is the LISP code above the code you're wanting to use? If not, please post the desired code so we can take a look.

Link to comment
Share on other sites

Hello again,

 

With some help i've find the solution with RTOS.

 

but it adds a + sign before - so user have to find and replace the "+-" to"-".

and precision should be 0.00. :)

 

Thanks a lot.

 

 

(defun AddNumAtt (add tag / e ei et txt)

`

(setq e (entnext)

tag (strcase tag))

(while (setq e (entnext e))

(setq ei (entget e)

et (cdr (assoc 0 ei)))

(and (= "ATTRIB" et)

(wcmatch (cdr (assoc 2 ei)) tag)

(setq txt (cdr (assoc 1 ei)))

(numberp (setq num (read txt)))

(entmod

(subst (cons 1 (strcat "+" (rtos (+ add num) 2 2))) (assoc 1 ei) ei))

(entupd e)))

(princ))

(alert "Çizimdeki tüm attributler değiştirilecek!!!")

(setq addreal (getreal "\nEklenecek sayıyı giriniz: "))

(if (= addreal nil) (setq addreal -6))

(AddNumAtt addreal "*")

;(AddNumAtt 1.00 "*")

(alert "find penceresi açıldığında \"+-\" leri arattırın ve\"-\" ile değiştirtin!!!")

(command "find") ;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...