Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
tommcgtx
Posts: 66
Registered: ‎01-22-2010
Message 1 of 9 (299 Views)
Accepted Solution

Change stationing text incrementally

299 Views, 8 Replies
04-28-2011 02:31 PM

Is ther a way to change sttioning text incrementally? For example, I have text (0+00) spaced every 100 ft. along the bottom of a profile grid. I want to be able to pick the first, have it change to 1+00, then the second, have it changed to 2+00, etc. I have looked for a lisp routine online, but have not found one. I am not very good at creating them myself, so can anyone help?

paste then type Next_Station in command line

 

 

(defun C:Next_Station (/ num cent)
(vl-load-com)
(setq num (atoi (substr (vla-get-textstring (vlax-ename->vla-object (car (entsel "\nSelect Beginning Station: ")))) 1 1)))
(prompt "\nSelect Next Station: ")
(while (setq cent (vlax-ename->vla-object (car (entsel))))
  (setq num (1+ num))
  (vla-put-textstring cent (strcat (itoa num) (substr (vla-get-textstring cent) 2)))
);while
(princ)
);defun

(defun C:Next (/ Start TxtObject strt Next)
(vl-load-com)
(cond ((and
(setq Start (car (entsel "\nSelect Beginning Station: ")))
(eq (vla-get-ObjectName (setq TxtObject (vlax-ename->vla-object Start))) "AcDbText")
(setq num (vla-get-textstring TxtObject))
(setq strt (itoa (+ (atoi (vl-string-subst "" "+" num)) 100)))
(not (prompt "\nSelect Next Station: "))
(while (setq Next (car (entsel)))
(and
(eq (vla-get-ObjectName (setq TxtObject (vlax-ename->vla-object Next))) "AcDbText")
(not (vla-put-textstring TxtObject
(strcat
(substr strt 1 (- (strlen strt) 2))
"+"
(substr strt (1+ (- (strlen strt) 2))))))
(setq strt (itoa (+ (atoi strt) 100)))
)
)
)
)
)(princ)
)

 

 

Lee Mac has many, many wonderful lisp

 

http://lee-mac.com/numinc.html

*Expert Elite*
Patchy
Posts: 6,322
Registered: ‎09-16-2009
Message 2 of 9 (296 Views)

Re: Change stationing text incrementally

04-28-2011 02:57 PM in reply to: tommcgtx

Why not move them 100'  ?

Valued Contributor
tommcgtx
Posts: 66
Registered: ‎01-22-2010
Message 3 of 9 (293 Views)

Re: Change stationing text incrementally

04-28-2011 03:23 PM in reply to: tommcgtx

I am not sure I understand what you mean. I want to to pick text (0+00) already placed so that when I am finished, they read as follows:

0+00   1+00   2+00   3+00  ..... and so on, along the bottom of my profile grid. I have some routines that will increment changes, but they only produce the same result for each text (1+00  1+00 1+00), when I want the second and third and so on picks to change by 100 more then the last.

Valued Mentor
Shneuph
Posts: 356
Registered: ‎11-26-2007
Message 4 of 9 (288 Views)

Re: Change stationing text incrementally

04-28-2011 04:35 PM in reply to: tommcgtx

paste then type Next_Station in command line

 

 

(defun C:Next_Station (/ num cent)
(vl-load-com)
(setq num (atoi (substr (vla-get-textstring (vlax-ename->vla-object (car (entsel "\nSelect Beginning Station: ")))) 1 1)))
(prompt "\nSelect Next Station: ")
(while (setq cent (vlax-ename->vla-object (car (entsel))))
  (setq num (1+ num))
  (vla-put-textstring cent (strcat (itoa num) (substr (vla-get-textstring cent) 2)))
);while
(princ)
);defun

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
*Expert Elite*
Patchy
Posts: 6,322
Registered: ‎09-16-2009
Message 5 of 9 (274 Views)

Re: Change stationing text incrementally

04-28-2011 07:06 PM in reply to: tommcgtx

It was a joke (If you moved the text 100' that's where it is)

Civil is my bread and butter :smileyvery-happy:

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 6 of 9 (268 Views)

Re: Change stationing text incrementally

04-28-2011 09:36 PM in reply to: Patchy
(defun C:Next (/ Start TxtObject strt Next)
  	(vl-load-com)
(cond ((and
(setq Start (car (entsel "\nSelect Beginning Station: ")))
(eq (vla-get-ObjectName (setq TxtObject (vlax-ename->vla-object Start))) "AcDbText")
(setq num (vla-get-textstring TxtObject))
(setq strt (itoa (+ (atoi (vl-string-subst  "" "+" num)) 100)))
(not (prompt "\nSelect Next Station: "))
(while (setq Next (car (entsel)))
	(and
         (eq (vla-get-ObjectName (setq TxtObject (vlax-ename->vla-object Next))) "AcDbText")
	 (not (vla-put-textstring TxtObject
		  (strcat
		    (substr strt 1 (- (strlen strt) 2))
		    "+"
		    (substr strt (1+ (- (strlen strt) 2))))))
                 (setq strt (itoa (+ (atoi strt) 100)))
			)
		)
	)
)
)(princ)
)

 

 

*Expert Elite*
Patchy
Posts: 6,322
Registered: ‎09-16-2009
Message 7 of 9 (266 Views)

Re: Change stationing text incrementally

04-28-2011 09:43 PM in reply to: pbejse

Lee Mac has many, many wonderful lisp

 

http://lee-mac.com/numinc.html

Valued Contributor
tommcgtx
Posts: 66
Registered: ‎01-22-2010
Message 8 of 9 (251 Views)

Re: Change stationing text incrementally

04-29-2011 07:08 AM in reply to: tommcgtx

Thank you, Sheneuph and Pbejse, the routines you both posted work great!

Valued Contributor
tommcgtx
Posts: 66
Registered: ‎01-22-2010
Message 9 of 9 (246 Views)

Re: Change stationing text incrementally

04-29-2011 07:15 AM in reply to: Patchy

Wow! Thanks, Patchy! That program is really something. I would not even begin to know how to do something like that.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.