View Full Version : adding one
prose
2008-11-17, 10:10 PM
Is there a lisp routine out there that can add "1" to the selected numbers you choose?
ccowgill
2008-11-17, 10:57 PM
you can search for text increment (http://forums.augi.com/showthread.php?t=83231) in the augi forums, that may do what you need
prose
2008-11-17, 11:08 PM
Thank you. I already have something similar to that.
My real question is, once you have 62 numbers on the drawing, if you missed a device address between 4 and 5, can you add one to numbers 5-62 to make it 6-63 since I missed a number which happens to be number 5 in this example.
Wow, I hope that made sense.
BoKirra
2008-11-18, 03:45 AM
Thank you. I already have something similar to that.
My real question is, once you have 62 numbers on the drawing, if you missed a device address between 4 and 5, can you add one to numbers 5-62 to make it 6-63 since I missed a number which happens to be number 5 in this example.
Wow, I hope that made sense.
Are they attributes, mtext or text?
prose
2008-11-18, 06:17 AM
Are they attributes, mtext or text?
Just regular text.
rkmcswain
2008-11-18, 02:10 PM
The lisp function (1+) will do it.
;;;Example
(setq k 5)
(1+ k)
;;; returns 6
;;; Notice that there is no space between 1 and +
;;;
;;;
;;; You could also use this
(+ 1 k)
prose
2008-11-18, 04:29 PM
Okay, I have tried many ways, and still no luck.
Here is one of the many ways I have tried.
(defun c:add1 ()
(setq ns (ssget))
(+ 1 ns)
)
Any ideas as what I am doing wrong.
prose
2008-11-18, 04:56 PM
I have tried this as well
(defun c:add ()
(setq nb (getint "Enter Number to add:"))
(setq ns (ssget '((-4 . "<OR")
(0 . "MTEXT")
(0 . "TEXT")
(-4 . "OR>")
)
)
)
(+ ns nb)
)
but I keep getting an error like this
Select objects:
; error: bad argument type: numberp: <Selection set: 1586a>
rkmcswain
2008-11-18, 07:06 PM
Read the HELP files for these functions.
(ssget) returns a selection set, and (+) and (1+) expect a number.
To do what you are trying to do, you need to extract the *value* of each item in the selection set, and then convert that to a number, and then add the value that you want to add, and then update each item with this new value.
There is a version of what you are trying to do in this ZIP file.
http://www.sybex.de/download/Aec.zip
prose
2008-11-18, 07:08 PM
Read the HELP files for these functions.
(ssget) returns a selection set, and (+) and (1+) expect a number.
To do what you are trying to do, you need to extract the *value* of each item in the selection set, and then convert that to a number, and then add the value that you want to add, and then update each item with this new value.
There is a version of what you are trying to do in this ZIP file.
http://www.sybex.de/download/Aec.zip
I will do that, thanks.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.