Help with Lisp

Help with Lisp

ArchD
Collaborator Collaborator
1,135 Views
4 Replies
Message 1 of 5

Help with Lisp

ArchD
Collaborator
Collaborator

I posted this in the Civil 3D customization forums but no luck. This needs Civil 3D to work.

 

I created a lisp that makes curb offsets using the OFFSETFEATURE command, with elevation difference as the criteria. Everything works fine unless the criteria is set to something else other than difference. So the first thing I need to do is make sure that the criteria in the OFFSETFEATURE is set to elevation difference.

 

On the command line I am able to do this by going through the motions and escaping/canceling just after setting it to Distance. Trying to simulate this in lisp breaks the command. 

 

Is there a way to read what the criteria is set to via a built in C3D variable rather than trying to invoke the command just to cancel it, and if not, is there a way to simulate canceling the command after setting it to "D" even if it is already set to Difference?

 

(defun c:SetToDistance ()

	(setq UserSel (entsel "\n Select line to offset... "))
	(setq OSSide (getpoint "\n Specify side to offset: "))
	(command "OFFSETFEATURE" "1" UserSel OSSide "d")
	(command)
)

Note that this snippet of code only works if the FEATUREOFFSET criteria is set to something other than Elevation Difference. If already set it breaks, but this is the setting I want to to set to every time.

 

Thanks for any help.

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
0 Likes
Accepted solutions (1)
1,136 Views
4 Replies
Replies (4)
Message 2 of 5

john.uhden
Mentor
Mentor

I don't have C3D, but if a feature line has an applicable offset method, then you can make your own offset command including moving the new object in the Z direction (changing its elevation by a difference).

 

To check, select a feature using entsel, convert it into a vla-object, and (vlax-dump-object obj 1).  The dump will report the applicable methods for the object.

John F. Uhden

0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Maybe this could do the trick... 

 

(defun c:SetToDistance ( / usersel osside en lp)
  (setq UserSel (entsel "\n Select line to offset... "))
  (setq OSSide (getpoint "\n Specify side to offset: "))
  (setq en (entlast))
  (command ".OFFSETFEATURE" 1 UserSel OSSide 2)
  (setq lp (getvar 'LASTPROMPT))
  (command UserSel OSSide)
  (if (not (equal en (entlast)))
    (entdel (entlast)))
  (if (not (wcmatch lp "*elevation difference or*"))
    (command "D"))
  (command PAUSE "")
  (princ)
)

 

Message 4 of 5

ArchD
Collaborator
Collaborator

And it does do the trick! Thanks so much! I didn't want to post this here since it was Civil 3D specific but got no response there. This is going to help me out a ton.

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

ВeekeeCZ
Consultant
Consultant

Hoped it does. It's dirty dirty solution... something like a screenshot 🙂

 

PS. Some of us in here has C3D. Still learning this thing.....

0 Likes