Offset Feature Line Lisp Help

Offset Feature Line Lisp Help

ArchD
Collaborator Collaborator
1,956 Views
8 Replies
Message 1 of 9

Offset Feature Line Lisp Help

ArchD
Collaborator
Collaborator

This requires Civil 3D in its current state. I originally posted this in Civil 3D Customization forums, but I never get the feedback I do as when I post here. Please forgive me for those of you who do not have access to Civil 3D.

 

I have a lisp routine that I created that basically offsets a feature line multiple times to create a curb in plan view. It first ask what type of curb then offsets the edge of pavement to the flow line, front of curb and back of curb by the distance and offsets for the curb chosen. It also puts the flow line, front of curb and back of curb on their own layers. 

 

At least this is the goal. It is hit or miss on whether it works or not due to my limited coding abilities. I'm wondering if someone with the proper knowledge would be able to take a look at the code and maybe give me some feedback on how to make this work every time. 

 

I've attached it so you can shame me on how poor my coding ability is.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes
1,957 Views
8 Replies
Replies (8)
Message 2 of 9

devitg
Advisor
Advisor

Please upload the dwg, at least a part to work on it. Save has plain acad. 

Whit  a before and after  

0 Likes
Message 3 of 9

ВeekeeCZ
Consultant
Consultant

I would prefer c3d dwg where it fails. And some description of the failures. Did you try vlide-trace where it fails? Or it is completely random?

 

Turn OFF the osnaps in your code!

 

0 Likes
Message 4 of 9

Kent1Cooper
Consultant
Consultant

@ArchD wrote:

.... 

I've attached it so you can shame me on how poor my coding ability is.


I don't know about the failure [don't have C3D], but since you asked, I'll point out two significant improvements you can make.

 

This is the perfect situation for using a (cond) function instead of a series of (if) functions.  As you have it, the routine has to check the *ans* value against every  possible option individually, no matter which one was chosen, and even after  it has already found and processed the right one.  With (cond), it checks only until  it finds the satisfied condition, then does what's asked for about that, and doesn't bother looking at any of the others, but jumps right to the end of the (cond).  It also eliminates  all those (progn) functions that are needed within an (if) function to wrap multiple operations into a single 'then' expression.

 

And, a single (command) function can contain any number  of command operations, so you don't need to wrap each one up and then start a new (command) function for the next one.

 

An excerpt [untested]:

 

;;; Execute offsets based on user selection
  (cond
    ((= *ans* "type-A")
; if this returns T, do the following and skip all other conditions;
; if it returns nil, move to the next conditional test
(command "OFFSETFEATURE" "0.583333" UserSel OSSide "0" "" "-layer" "M" "P-CURB-FL" "C" "151" "" "PS" "1 - Fine" "" "" "chprop" "L" "" "LA" "P-CURB-FL" "" "OFFSETFEATURE" "0.593333" UserSel OSSide "0.166667" "" "-layer" "M" "P-CURB-FOC-TYPE A" "C" "7" "" "PS" "1 - Fine" "" "" "chprop" "L" "" "LA" "P-CURB-FOC-TYPE A" "" "OFFSETFEATURE" "1.33333" UserSel OSSide "0.4166667" "" "-layer" "M" "P-CURB-BOC" "C" "3" "" "PS" "1 - Fine" "" "" "chprop" "L" "" "LA" "P-CURB-BOC" "" ); end command (setvar "CLAYER" CURLay) ); end type-A condition ((= *ans* "type-B") (command "OFFSETFEATURE" "0.01" UserSel OSSide "0.1666667" "" .... .... "chprop" "L" "" "LA" "P-CURB-BOC" "" ); end command (setvar "CLAYER" CURLay) ); end Shoulder condition ((= *ans* "Valley") (command "OFFSETFEATURE" "1.16667" UserSel OSSide "-0.104167" "" "-layer" "M" "P-CURB-FL-VALLEY" "C" "151" "" "PS" "1 - Fine" "" "" "chprop" "L" "" "LA" "P-CURB-FL-VALLEY" "" "OFFSETFEATURE" "3" UserSel OSSide "0" "" "-layer" "M" "P-CURB-EOP" "C" "2" "" "PS" "2 - Very Thin" "" "" "chprop" "L" "" "LA" "P-CURB-EOP" "" ); end command (setvar "CLAYER" CURLay) ); end Valley condition ); end cond (princ) )
Kent Cooper, AIA
Message 5 of 9

ArchD
Collaborator
Collaborator

Okay, I think I fixed it. I had two versions floating around, one with bad information that broke it. Thanks for the help anyway, it's always appreciated.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes
Message 6 of 9

ArchD
Collaborator
Collaborator

This is great information! I'll definitely use it all. Thanks so much.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes
Message 7 of 9

ВeekeeCZ
Consultant
Consultant

You should try to make your code more readable, copy-paste method is not always the best. Focus on key things - don't mess the code with plenty of useless parameters of layer... prop change... main code can look like this:

 

  (cond ((wcmatch *ans* "type-A,-A")
         (:of2layer 0.583333 UserSel OSSide 0 "P-CURB-FL")
         (:of2layer 0.593333 UserSel OSSide 0.166667 "P-CURB-FOC-TYPE A")
         (:of2layer 1.33333 UserSel OSSide 0.4166667 "P-CURB-BOC")
         )
        ((wcmatch *ans* "type-B,-B")
         (:of2layer 0.583333 UserSel OSSide 0 "P-CURB-FL")
         (:of2layer 0.593333 UserSel OSSide 0.166667 "P-CURB-FOC-TYPE B")
         (:of2layer 1.33333 UserSel OSSide 0.4166667 "P-CURB-BOC")
         )

...all the rest can do some sub...

 

Just suggestions... untested.

0 Likes
Message 8 of 9

greg_battin
Advocate
Advocate

Can you share the fixed version please?

0 Likes
Message 9 of 9

ArchD
Collaborator
Collaborator

Sure thing. I took many of the suggestions from here on the forums and added them to it. I'm not the greatest at AutoLisp, so the more difficult functions I couldn't add such as checking for two conditions, like asking what type of curb and whether it's a spill type or normal.

 

 

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes