Trim pipe intersection

Trim pipe intersection

SlaydenP&H
Observer Observer
1,148 Views
3 Replies
Message 1 of 4

Trim pipe intersection

SlaydenP&H
Observer
Observer

I am trying to make a lisp routine that will automate the task of trimming pipes (represented as single lines) so that one pipe appears to run over the other.

 

I would like the routine to prompt to select the intersection, draw a circle around the intersection, trim one of the pipes as selected by the user, and finally delete the circle.

 

Here is the code I have been working with:

 

(defun c:pcut ( / cr sn pt circle tp )

(setq sn (getvar "osmode"))
(command "osmode" "544" )

(prompt "\nSelect point to cut:")
(setq pt (getpoint))

(prompt "\nSelect cut radius:")
(setq cr (getdist))

(prompt "\nSelect pipe to trim")
(setq tp (getpoint))

(command "circle" pt cr)

(setq circle (entlast))
(command "trim" circle " " tp " " )
(entdel circle)

(command "osmode" sn )
)

 

When I run this routine, I get the following error:

 

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle
; error: Function cancelled

 

Any help would be greatly appreciated.

 

0 Likes
Accepted solutions (1)
1,149 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

Enter is represented by two double-quotes together, not with a space in between [i.e. an empty  text string, not a text string consisting of a single space].  Try changing this:

 

(command "trim" circle " " tp " " )

 

to this:

 

(command "trim" circle "" tp "" )

Kent Cooper, AIA
0 Likes
Message 3 of 4

SlaydenP&H
Observer
Observer

Works like a charm now. Thank you!

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

By the way....  Good for you for working out a routine, but there are a lot of things out there to do what you're after.  >This< is just one example.  Some let you do multiple intersections at once, most have options for gap size at the breaks [including no gap], and there are other variant approaches you might want to look into, if only to see the different ways people approach it.

Kent Cooper, AIA