Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change poly topo elevations incrementally

17 REPLIES 17
Reply
Message 1 of 18
ArchD
3123 Views, 17 Replies

Change poly topo elevations incrementally

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
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
17 REPLIES 17
Message 2 of 18
tom_brabant
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)
)
)
Message 3 of 18
bob.at
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.
Message 4 of 18
ArchD
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
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 5 of 18
bob.at
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.
Message 6 of 18
ArchD
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
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 7 of 18
bob.at
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
Message 8 of 18
ArchD
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
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 9 of 18
bob.at
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.
Message 10 of 18
ArchD
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
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 11 of 18
bob.at
in reply to: ArchD

I've tried the first thing, its not too hard. The new layer has the same
properties (color, linetyp) as the old one.

The second I did not understand what you exactly want. Maybe you can give an
example, how the command line options should look like.

(defun C:setelev ( / laypref inc hi olddir dir eln oldlay newlay)
(vl-load-com)
(setq laypref (getstring "\nLayer prefix: ")
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 newlay (strcat laypref (setq oldlay (vlax-get-property
(vlax-ename->vla-object eln) 'Layer))))
(entmake (subst (cons 2 newlay) (assoc 2 (entget (tblobjname "layer"
oldlay))) (entget (tblobjname "layer" oldlay))))
(vlax-put-property (vlax-ename->vla-object eln) 'Layer newlay)
(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:6013583@discussion.autodesk.com...
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.
Message 12 of 18
ArchD
in reply to: ArchD

I'm sorry, I'm having a hard time trying to explain. By the way, where do I send donations bob.at? Here it goes at my attempt to show you what it would look like in the command box:

Command: setelev

Increment (+): 0.2

*Polylines increments set at 0.2*

Select Reference Polyline:

*I pick a polyline with an elevation of 0.2 using pickbox*

Select Polyline for elev=0.4000 [Increase/Decrease]<*I*>:

*I pick the line next to it using pickbox changing it to 0.4*

Select Reference Polyline:

*I pick the poly just changed to 0.4*

Select Polyline for elev=0.6000 [Increase/Decrease]<*I*>: D

*I choose option D*

Select Polyline for elev=0.4000 [Increase/Decrease]<*D*>:

*I choose the next polyline"

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 13 of 18
bob.at
in reply to: ArchD

Are you sure? Than you have every time to click on two polylines.
Maybe a good idea is to combine the Select Polyline with the options for I
and D as you suggest. Than you also can press three times D to come down
form 1.2 to 0.6 for example.

An other posibility is, to change the eXit option, so that it does not exit
the program but it goes back a step to a new selection of the referenc line.

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

PS: Please send all donations for all my work here (if you like it) to
wikipedia (http://wikimediafoundation.org/wiki/Fundraising)


schrieb im Newsbeitrag news:6013725@discussion.autodesk.com...
I'm sorry, I'm having a hard time trying to explain. By the way, where do I
send donations bob.at? Here it goes at my attempt to show you what it would
look like in the command box:

Command: setelev

Increment (+): 0.2

*Polylines increments set at 0.2*

Select Reference Polyline:

*I pick a polyline with an elevation of 0.2 using pickbox*

Select Polyline for elev=0.4000 [Increase/Decrease]<*I*>:

*I pick the line next to it using pickbox changing it to 0.4*

Select Reference Polyline:

*I pick the poly just changed to 0.4*

Select Polyline for elev=0.6000 [Increase/Decrease]<*I*>: D

*I choose option D*

Select Polyline for elev=0.4000 [Increase/Decrease]<*D*>:

*I choose the next polyline"

Message 14 of 18
ArchD
in reply to: ArchD

Yes, if you could change the eXit option to Reference or something, to back it up to choose a new reference poly that would work great. That would be much better than what I had in mind. That way it would still be as fast as you have it now, but with the option to back up a step and choose a new reference. Great idea.
Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 15 of 18
bob.at
in reply to: ArchD

Try it:

(defun C:setelev ( / laypref inc hi olddir refpoly dir workpoly eln oldlay
newlay)
(vl-load-com)
(setq laypref (getstring "\nLayer prefix: ")
inc (getreal "\nIncrement (+): ")
olddir "Increase")
(if (setq refpoly (entsel "\nSelect reference. polyline: "))
(setq hi (vlax-get-property (vlax-ename->vla-object (car refpoly))
'Elevation))
(setq hi nil)
)
(while hi
(princ hi)
(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)))
(while (not (= dir "eXit"))
(if (setq workpoly (strcat "\nPolyline for elev=" (rtos hi) ": "))
(setq eln (car (entsel workpoly)))
(setq eln nil)
)
(if (and eln (= (cdr (assoc 0 (entget eln))) "LWPOLYLINE"))
(progn
(vlax-put-property (vlax-ename->vla-object eln) 'Elevation hi)
(setq newlay (strcat laypref (setq oldlay (vlax-get-property
(vlax-ename->vla-object eln) 'Layer))))
(entmake (subst (cons 2 newlay) (assoc 2 (entget (tblobjname
"layer" oldlay))) (entget (tblobjname "layer" oldlay))))
(vlax-put-property (vlax-ename->vla-object eln) 'Layer newlay)
(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")
)
)
(if (setq refpoly (entsel "\nSelect reference. polyline: "))
(setq hi (vlax-get-property (vlax-ename->vla-object (car refpoly))
'Elevation))
(setq hi nil)
)
)
(princ)
)




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


schrieb im Newsbeitrag news:6013842@discussion.autodesk.com...
Yes, if you could change the eXit option to Reference or something, to back
it up to choose a new reference poly that would work great. That would be
much better than what I had in mind. That way it would still be as fast as
you have it now, but with the option to back up a step and choose a new
reference. Great idea.
Message 16 of 18
ArchD
in reply to: ArchD

That is exactly what I needed. I cant thank you enough. Do you have a site for lisps that you collect donations for? This is a huge help for me and those I work with.
Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Message 17 of 18
bob.at
in reply to: ArchD

As i mentioned four posts above:

PS: Please send all donations for all my work here (if you like it) to
wikipedia (http://wikimediafoundation.org/wiki/Fundraising)


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


schrieb im Newsbeitrag news:6013858@discussion.autodesk.com...
That is exactly what I needed. I cant thank you enough. Do you have a site
for lisps that you collect donations for? This is a huge help for me and
those I work with.
Message 18 of 18
ArchD
in reply to: ArchD

Sorry, didn't see the link before. Donation sent.
Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost