Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
ArchD
Posts: 320
Registered: ‎07-30-2008
Message 1 of 18 (828 Views)

Change poly topo elevations incrementally

828 Views, 17 Replies
08-21-2008 11:07 AM
I have a drawing full of topo lines in 2D Polylines and all of them are at elevation 0.

Is there any lisp routines out there that will let me set an increment then let me choose increase or decrease, so I can just select one right after another. It would be nice if I can set the elevation of one, then use the lisp routine and select that one, it reads the elevation and automatically applies the next elevation to the next one based on the increment I choose.

Any help would be great. Thanks.
Archie Dodge

Civil 3D 2013
Windows 7 64-bit
Xeon E5-1620 v2 @ 3.70 GHz
Nvidia Quadro K4000
32.0 GB RAM
Distinguished Contributor
tom_brabant
Posts: 404
Registered: ‎12-08-2003
Message 2 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 11:28 AM in reply to: ArchD
The following is very bare bones - you'll have to change the code to change the topo interval (even for going down instead of up!). But, it might get you started and it could be enhanced.

(defun c:tt ()
(setq topoint 10.0)
(princ "\nCurrent topo interval hardwired to ")(princ topoint)(princ " feet.")
(princ "\nPick existing topoline")
(setq e (car (entsel)) eg (entget e) elevation (cdr (assoc 38 eg)))
(setq elevation (+ elevation topoint))
(princ "\n next elevation will be ")(princ elevation)
(princ "\n Pick other topo lines ")
(while (setq pl (car (entsel)))
(setq plg (entget pl))
(entmod (subst (cons 38 elevation)(assoc 38 plg) plg))
(setq elevation (+ elevation topoint))
(princ "\n next elevation will be ")(princ elevation)
)
)
Distinguished Contributor
bob.at
Posts: 728
Registered: ‎03-16-2004
Message 3 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 11:32 AM in reply to: ArchD
... or you can give a chance to my first guess:

(defun C:setelev ( / )
(setq hi (getreal "\nHight of 1. polyline: ")
inc (getreal "\nIncrement (+/-): "))
(while (setq eln (car (entsel (strcat "\nPolyline for hight=" (rtos hi) ":
"))))
(if (= (cdr (assoc 0 (entget eln))) "LWPOLYLINE")
(setq res (vlax-put-property (vlax-ename->vla-object eln) 'Elevation
hi) hi (+ hi inc))
(princ "\nno polyline selected")
)
)
)


--
bob.at
CAD & GIS Services, Graz, Austria


schrieb im Newsbeitrag news:6012658@discussion.autodesk.com...
I have a drawing full of topo lines in 2D Polylines and all of them are at
elevation 0.

Is there any lisp routines out there that will let me set an increment then
let me choose increase or decrease, so I can just select one right after
another. It would be nice if I can set the elevation of one, then use the
lisp routine and select that one, it reads the elevation and automatically
applies the next elevation to the next one based on the increment I choose.

Any help would be great. Thanks.
Mentor
ArchD
Posts: 320
Registered: ‎07-30-2008
Message 4 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 11:46 AM in reply to: ArchD
Both of those seem to be great starts. I think the first one mentioned would work great with a bit of polish. Ill see what I can do about adding something to it so that it will automatically see what the elevation of the first line I pick, then do the changes, kinda like the offset command. Im not too great at programming, so any futher help would be appreciated.

Ideally, I think it would be nice if the first thing it asks is the increment value, then once you enter that, it asks you increase or decrease. After you choose that, you can basically pick a line with an elevation, then pick the next, and it updates that second one picked to the new elevation. And before each time you select the first line in that sequence it gives you the option to change wether its increasing or decreasing, and if you dont choose, it retains what was last chosen.

Thats in my perfect little world though. Those 2 suggestions will help me out tremendously as a starting point though. Thanks.
Archie Dodge

Civil 3D 2013
Windows 7 64-bit
Xeon E5-1620 v2 @ 3.70 GHz
Nvidia Quadro K4000
32.0 GB RAM
Distinguished Contributor
bob.at
Posts: 728
Registered: ‎03-16-2004
Message 5 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 12:21 PM in reply to: ArchD
Ok I did some more with these additional conditions of you:

(defun C:setelev ( / inc hi olddir dir eln)
(setq inc (getreal "\nIncrement (+): ")
hi (vlax-get-property (vlax-ename->vla-object (car (entsel "\n1.
polyline: "))) 'Elevation)
olddir "Increase")
(princ hi)
(initget "Increase Decrease eXit")
(setq dir (if (setq dir (getkword (strcat "\n[Increase/Decrease]<" (substr
olddir 1 1) ">: "))) dir olddir)
hi (if (= "Increase" dir) (+ hi inc) (- hi inc)))
(while (not (= dir "eXit"))
(setq eln (car (entsel (strcat "\nPolyline for elev=" (rtos hi) ": "))))
(if (= (cdr (assoc 0 (entget eln))) "LWPOLYLINE")
(progn
(vlax-put-property (vlax-ename->vla-object eln) 'Elevation hi)
(setq olddir dir)
(initget "Increase Decrease eXit")
(setq dir (if (setq dir (getkword (strcat
"\n[Increase/Decrease/eXit]<" (substr olddir 1 1) ">: "))) dir olddir)
hi (if (= "Increase" dir) (+ hi inc) (- hi inc)))
)
(princ "\nno polyline selected")
)
)
(princ)
)

--
bob.at
CAD & GIS Services, Graz, Austria


schrieb im Newsbeitrag news:6012746@discussion.autodesk.com...
Both of those seem to be great starts. I think the first one mentioned would
work great with a bit of polish. Ill see what I can do about adding
something to it so that it will automatically see what the elevation of the
first line I pick, then do the changes, kinda like the offset command. Im
not too great at programming, so any futher help would be appreciated.

Ideally, I think it would be nice if the first thing it asks is the
increment value, then once you enter that, it asks you increase or decrease.
After you choose that, you can basically pick a line with an elevation, then
pick the next, and it updates that second one picked to the new elevation.
And before each time you select the first line in that sequence it gives you
the option to change wether its increasing or decreasing, and if you dont
choose, it retains what was last chosen.

Thats in my perfect little world though. Those 2 suggestions will help me
out tremendously as a starting point though. Thanks.
Mentor
ArchD
Posts: 320
Registered: ‎07-30-2008
Message 6 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 12:24 PM in reply to: ArchD
I get this error:

polyline: error: no function definition: VLAX-ENAME->VLA-OBJECT; error: An
error has occurred inside the *error* functionAutoCAD variable setting
rejected: "PICKBOX" nil

Im using AutoCad 09 if thats any use.


*edit*
I tried it in '07, and it works great!! Thank you so very much, this will get me through my day. I have 4 topos to do this too.

One topo map done, 99 contours in just about 2 or 3 mins!! Thanks again.

Message was edited by: ArchD Message was edited by: ArchD
Archie Dodge

Civil 3D 2013
Windows 7 64-bit
Xeon E5-1620 v2 @ 3.70 GHz
Nvidia Quadro K4000
32.0 GB RAM
Distinguished Contributor
bob.at
Posts: 728
Registered: ‎03-16-2004
Message 7 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 12:43 PM in reply to: ArchD
I've tested it in 2008 - sorry its my fault.

change the beginnig lines, than it should work in different environments

(defun C:setelev ( / inc hi olddir dir eln)
(vl-load-com)

--
bob.at
CAD & GIS Services, Graz, Austria


schrieb im Newsbeitrag news:6012796@discussion.autodesk.com...
I get this error:

polyline: error: no function definition: VLAX-ENAME->VLA-OBJECT; error: An
error has occurred inside the *error* functionAutoCAD variable setting
rejected: "PICKBOX" nil

Im using AutoCad 09 if thats any use.


*edit*
I tried it in '07, and it works great!! Thank you so very much, this will
get me through my day. I have 4 topos to do this too.

One topo map done, 99 contours in just about 2 or 3 mins!! Thanks again.

Message was edited by: ArchD

Message was edited by: ArchD
Mentor
ArchD
Posts: 320
Registered: ‎07-30-2008
Message 8 of 18 (828 Views)

Re: Change poly topo elevations incrementally

08-21-2008 12:49 PM in reply to: ArchD
You have no idea how happy this makes me. I looked everywhere for this and all I found were others looking for it also. I found that LDT has a similar command, but its not all that great. This is super smooth and fast! Your a huge help. Works great in '09.
Archie Dodge

Civil 3D 2013
Windows 7 64-bit
Xeon E5-1620 v2 @ 3.70 GHz
Nvidia Quadro K4000
32.0 GB RAM
Distinguished Contributor
bob.at
Posts: 728
Registered: ‎03-16-2004
Message 9 of 18 (829 Views)

Re: Change poly topo elevations incrementally

08-22-2008 01:21 AM in reply to: ArchD
You're welcome.

--
bob.at
CAD & GIS Services, Graz, Austria


schrieb im Newsbeitrag news:6012836@discussion.autodesk.com...
You have no idea how happy this makes me. I looked everywhere for this and
all I found were others looking for it also. I found that LDT has a similar
command, but its not all that great. This is super smooth and fast! Your a
huge help. Works great in '09.
Mentor
ArchD
Posts: 320
Registered: ‎07-30-2008
Message 10 of 18 (829 Views)

Re: Change poly topo elevations incrementally

08-22-2008 08:23 AM in reply to: ArchD
After working with this lisp for a few hours, I'm lovin it, but was wondering if theres any way to make a few changes with out too much trouble?

One, is there any way for lisp routines to change object layers? I was thinking that once the elevation has been changed on a contour, that it would be a huge help if it could move that contour to a new layer, with the same name, just with NEW or something added to the front of the layer name, and if the layers not there, it automatically adds it. This would help out so I can turn off the new layers and see what still needs to be done.

Also, I found that this code is great for just going from one contour to the next, but when theres little island like contours floating around, you have to exit the command and redo it. Would it be possible without too much trouble to make it start the command, ask the increment value, and ask increase or decrease. After that, for each new contour it asks for a reference, then the new contour to be changed. It would involve picking a reference then new contour each time, making it a bit slower, but easier to move around the topo without having to restart the command, and it giving you the option to pick increase or decrease before picking the new reference contour, and if you select nothing, it just defaults to the last thing you selected and you can go right ahead and pick the reference and just keep going.

If all this is too much trouble, I understand. What I have been given already is a tremendous help.
Archie Dodge

Civil 3D 2013
Windows 7 64-bit
Xeon E5-1620 v2 @ 3.70 GHz
Nvidia Quadro K4000
32.0 GB RAM
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.