Is there any way to edit this to account for 50' incements? i.e. 1+00, 1+50, 2+00, 2+50,...
Also, can it be edited to begin at a number besides 1?
Thank you so much for your lisp. I have seen several posts by you for many of my AutoCAD questions, and you are always very helpful.
Are you looking to do something like the following?
The following does have a quark (Unknown command) when you exit the program. Can't seem to figure it out right now. I'm curious if someone knows why...
(defun c:test (/ cnt p1 p2) (setvar 'cmdecho 0) (setq cnt (getint "\nSpecify start number: ")) (while (setq p1 (getpoint "\nSpecify point: ")) (command "_.text" "bl" "_none" p1 1 0 (strcat (itoa cnt) "+00")) (setq p2 (getpoint "\nSpecify point: ")) (command "_.text" "bl" "_none" p2 1 0 (strcat (itoa cnt) "+50")) (setq cnt (1+ cnt)) ); while (princ) )
smaher12 wrote:The following does have a quark (Unknown command) when you exit the program. Can't seem to figure it out right now. I'm curious if someone knows why...
Hi smaher12,
you should test the existence of correct argument before providing it to the the function.
i.e.
(setq cnt (getint "\nSpecify start number: "))
if the user press the spacebar or the enter, your test function will continue the evaluation and will provide a "nil" cnt to the itoa function inside the text command, and the user should receive an "error: bad argument type: fixnump: nil"
In the while function, the
(setq p1 (getpoint "\nSpecify point: "))
is the only test function, if the user try to exits the test function at the
(setq p2 (getpoint "\nSpecify point: "))
pressing the spacebar or the enter, is going to provide a "nil" p2 to the
(command "_.text" "bl" "_none" p2 1 0 (strcat (itoa cnt) "+50"))
the text command will try to evaluate the arguments, cancels the command and send to the command line the
(strcat (itoa cnt) "+50")
as a command, the return should be a
"Unknown command "##+##". Press F1 for help."
Perhaps something like this do the trick
(defun c:test (/ cnt old_echo p1 p2) (vl-load-com) (setq old_echo (getvar 'CMDECHO)) (setvar 'cmdecho 0) (if (setq cnt (getint "\nSpecify start number <exit>: ")) (while (and (setq p1 (getpoint "\nSpecify point <exit>: ")) (vl-cmdf "_.text" "bl" "_none" p1 1 0 (strcat (itoa cnt) "+00")) (setq p2 (getpoint "\nSpecify point <exit>: ")) (vl-cmdf "_.text" "bl" "_none" p2 1 0 (strcat (itoa cnt) "+50")) );; and (setq cnt (1+ cnt)) ); while );; if (setvar 'cmdecho old_echo) (princ) )
HTH
Henrique
Hi,
You can also try the 'Increment' plug-in available on Autodesk Exchange Apps.
I'ts not a LISP solution, but should do the trick (and many others).
In the dialog, set Value type to Digits, increment to 50 and separator to + to get
1+50 -> 2+00 -> 2+50 -> 3+00 ...
Choose the selection Tab to edit existing texts or attributes.
i have tried this lisp and it works for the most part but i am looking for something that can also self station to the length of the polyline without me having to manually select each point of the station. can you assist?
I could write what you want, but my wife doesn't like my giving away my time to strangers. Why aren't you using Civil 3D? Or can you borrow/steal an old copy of AutoCAD Land Desktop? How do you do profiles and earthwork?
John F. Uhden
Just google for Chainage.lsp many different versions out there will do what you want, John no need to reinvent the wheel.
As ubiquitous as C3D is and as old as this query is; answering it may be a moot point. But even lately I'll hear or read of someone stuck with generic AutoCAD or still on the Civil learning curve. Besides, I owe this forum for all the help aplenty.
See attached. Its more an inquiry and station tagging tool then a stationer.
But with a little code tweaking it could do actual stationing. But there's probably a dozen of them out there already waiting to be uploaded. Maybe when I get some down time.
b