Lisp routines for faster grading with polyline contours

Lisp routines for faster grading with polyline contours

Palanlan
Contributor Contributor
229 Views
7 Replies
Message 1 of 8

Lisp routines for faster grading with polyline contours

Palanlan
Contributor
Contributor

Hi all,

 

I'd like to develop two LISP routines for making grading complex sites (Civil 3D) using polyline contours much faster.  I know Civil 3D has grading and feature line objects but they are limited for complex sites and subdivisions and I have always found it easier to design mass grading using a mix of corridors, feature lines and polyline contours.

 

What would greatly speed me up are two lisp routines:

 

1) A command that fillets two user-selected contours at different elevations, assigning the elevation of the first selected contour to the second.  I would love it if the lisp routine prompted the user for a fillet radius, but used the default FILLETRAD system default if no radius was input, so that once a radius was set, the user wouldn't have to enter a new one every time.

 

2) A command to offset a polyline by a user specified horizontal distance and vertical distance (elevation change).  Again, it would be helpful if the command could "remember" what these user input settings were the first time and default to them for quick offsetting when designing slopes at a given Rise:run.

 

Again, I know there are similar tools for feature lines and I am well-versed in their use, but I like using lwpolylines as they are by default all at one elevation and easily manipulated with command line edits.  I've tried writing this code using AI help but, alas, we aren't quite there yet and I don't know nearly enough about lisp to know where I'm going wrong.

 

Thanks in advance for the help!

Running AutoCAD Civil 3D
0 Likes
230 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor

@Palanlan hi,

 

Attached cont3d.lsp my version to these 2 commands.

 

1. Command FFPL (Fillet Floating plines)

selected plines must be open. if you selected close pline it will be rejected without any warning

user input is saved and offered in next prompt as your request. these defaults is valid only in the current session.

command work in a loop. to stop it, just press enter at the next "Pick source pline" or ESC

 

2. Command OFPL (Offset Floating plines)

again, selected plines must be open.

user input is saved and offered in next prompt as your request.

you can select multiple plines for offset them together.

 

enjoy

Moshe

0 Likes
Message 3 of 8

Moshe-A
Mentor
Mentor

@Palanlan ,

 

did some fine tunning

0 Likes
Message 4 of 8

Sea-Haven
Mentor
Mentor

@Moshe-A you did not put your name in the code.

 

A suggestion I use LDATA to store variable values, rather than USERR1 & 2. 

Other suggestion is use multi getvals.lsp you can set the displayed value to say the ldata value or default for NIL.

 

SeaHaven_0-1756621055337.png

 

(setq ans (AH:getvalsm (list "Enter values " "Offset" 5 4 (rtos (vlax-ldata-get "Horver" "Height") 2 2) "Vertical rise" 5 4 (rtos (vlax-ldata-get "Horver" "Offs") 2 2)))

 You use -ve values for go left in the offset. 

0 Likes
Message 5 of 8

Moshe-A
Mentor
Mentor

@Sea-Haven ,

 

please explain (with some examples) what is the advantages in using (vlax-ldata-put), (vlax-ldata-get) consider we do not use vlx private namespace.

 

Moshe

 

 

0 Likes
Message 6 of 8

Sea-Haven
Mentor
Mentor

I try not to use the USERRx, USERIx and USERSx as other software may write to those internal storage, by using LDATA you can control the name of the data holder and then key names. Hopefully that makes sense.  The "User" variables I think was introduced way back in Acad as a method of saving values in a dwg, LDATA was obviously added with the introduction of VL. I used "User" way back in the 80's.

 

(vlax-ldata-put "AlanH" "ht" ht)
(vlax-ldata-put "AlanH" "wid" wid)
(vlax-ldata-put "AlanH" "xpt" xpt)
(vlax-ldata-put "AlanH" "xwid" xwid)
(vlax-ldata-put "AlanH" "yht" yht)
0 Likes
Message 7 of 8

Moshe-A
Mentor
Mentor

@Sea-Haven ,

 

The question was "what is the advantages"?!

 

Where AutoCAD holds this data storage? is it on dictionary? then it is another way to access dictionaries?

same as (dictadd) (dictnext) (dictsearch)?

i thought (vlax-ldata...) has the advantage of storing data as vlx private (or shared) namespace.

say i wrap data (variables and functions) in vlx file. is it possible to see it's data from all opened documents - how?

do i need to load it on each open document or only on first and it can be use from all?

 

Moshe

 

 

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

I do not know the technicality of how a Ldata is saved but it is only in a single dwg so the same data name and key can be different in two different dwg's. Same with the USERRx, USERIx & USERSx they are kept soley in a dwg. If you wanted to cross use values from one dwg to another then maybe OBDX could be used. Otherwise write a file. maybe with dwg names and values etc. Project number comes to mind where you have multiple dwgs.

0 Likes