TheSwamp

CAD Forums => CAD General => Topic started by: ELOQUINTET on October 04, 2004, 10:33:07 AM

Title: cut lines
Post by: ELOQUINTET on October 04, 2004, 10:33:07 AM
i was just wondering if anybody has a routine for inserting cutlines. i'm looking for something that will insert 2 cutlines allowing the user to pick the distance between them then allowing the user to trim out the objects between. anyone have something like that?
Title: cut lines
Post by: hyposmurf on October 04, 2004, 02:32:49 PM
I think i know where your going with this one.Are you hoping to use the cut lines to cut a piece of pipework so that it no longer looks like it inetersects with another?
http://theswamp.org/phpBB2/viewtopic.php?t=1270&highlight=pipework
Title: cut lines
Post by: ELOQUINTET on October 04, 2004, 02:37:38 PM
no not at all i'm in metal fabrication and just want an easy cutline routine instead of having to place one then place another then trim. i would like to be able to place them both then have those two lines be selected as trim lines and just selected the lines i'd like to trim all in one routine. wala done...
Title: cut lines
Post by: CAB on October 04, 2004, 03:01:26 PM
dan
How would you place them, the cut lines?
How do you do it now, exactly that is?
Do you pick an existing line to offset?
Do you draw two lines?
If so how do you determine where to draw them?Do you have a centerline object?
If you want a routine to do a specific task, you must define the task specifically. 8)
Title: cut lines
Post by: Mark on October 04, 2004, 03:30:29 PM
Just a follow up to CAB's post,

ya know what they say about pictures......... :D
Title: cut lines
Post by: ELOQUINTET on October 04, 2004, 04:51:33 PM
ok here's my littl drawing for ya hope this helps explain


[/url]http://theswamp.org/lilly_pond/dan/CUTLINE.PNG?nossi=1http://
Title: cut lines
Post by: ELOQUINTET on October 04, 2004, 04:52:21 PM
URRRRRR

[/url]http://theswamp.org/lilly_pond/dan/CUTLINE.PNG?nossi=1[url]
Title: cut lines
Post by: ELOQUINTET on October 04, 2004, 04:52:45 PM
AH SCREW IT IT'S HERE ^
Title: cut lines
Post by: Mark on October 04, 2004, 05:18:01 PM
Quote from: eloquintet
URRRRRR

how about this ......... BTW you don't need to use [url] on complete URL's
http://theswamp.org/lilly_pond/dan/CUTLINE.PNG?nossi=1
Title: cut lines
Post by: hyposmurf on October 04, 2004, 05:44:32 PM
Your trying to do a similar thing to the thread I posted,never worked how to do it though.Your trying to add two lines and have them trim whats inside them.Im trying to do that but then have the two lines deleted,once theyve trimed.Curently have to create two lines,trim inside them and then delete them,bit like a triming template,its annoyingly slow when you have 100's of pipe intersections.
Title: cut lines
Post by: CAB on October 04, 2004, 09:13:29 PM
dan
Here is one I use. I just updated the single break symbol code and the other
option is disabled for now.
Code: [Select]
;;; Lisp to draw Single or Double "Z" Break Lines
;;;                 © A.Henderson 2002
;;;
;;;  Modified By Charles Alan Butler  10/02/2004
;;;  To allow any angle and to trim lines that
;;;  do not run through both break symbols
;;;  Disabled Double Brk Sym until I fix that
;;;

(defun c:dz (/ oldlay oldotho oldosmode ztype dist p1 p2 p3 p4 p5 p6 e1 e2
             evl1 evl2 ang1 ang2 x lst)
  ;; return vertex list by MP
  (defun cdrs (key lst / pair rtn)
    (while (setq pair (assoc key lst))
      (setq rtn (cons (cdr pair) rtn)
            lst (cdr (member pair lst))
      )
    )
    (reverse rtn)
  )
 
  ;;  set osnaps ON/OFF
(defun SetOsnaps (value) ; value = "ON" or default to "OFF"
  (if value (setq value (strcase value)))
  (cond
    ((OR (AND(= value "ON") (>= (getvar "osmode") 16383))
         (AND(/= value "ON") (<= (getvar "osmode") 16383))
      )
      (setvar "osmode" (boole 6 (getvar "osmode") 16384))
    )
  )
)

  ;;   Start of routine  ==================================
  ;;  Save settings
  (setq oldlay    (getvar "clayer")
        oldortho  (getvar "orthomode")
        oldosmode (getvar "osmode")
  ) ;_ end of setq
  ;;  I use current layer - CAB
  ;;(command ".layer" "make" "Z-Line" "Colour" "41" "" "")


 ;(initget "S D")
 ;(setq ztype (getkword "\n Single or Double -^v-^v- ? (S or D) <S>"))
  (setq ztype "S")
  (SetOsnaps "ON") ; force on
  ;;===========================================
  (if (and (setq p1 (getpoint "Starting point of break line : "))
           (setq p6 (getpoint p1 "End point of break line : "))
      )

    ;;===========================================
    (cond
      ((/= ztype "D") ; default to single
       (setq dist (distance p1 p6)
             ang  (angle p1 p6)
             p2   (polar p1 ang (* 0.4167 dist))
             p5   (polar p1 ang (* 0.5833 dist))
             p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
             p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
       ) ;_ end of setq
       (setvar "plinewid" 0)
       (SetOsnaps "OFF") ; force off
       (command "pline" p1 p2 p3 p4 p5 p6 "") ; Draw the Z-Line
       (setq e1 (entlast))
       (setvar "osmode" oldosmode) ; return to original state        
       (command ".pedit" e1 "L" "ON" "")
       (command ".copy" e1 "" p6 pause)
       (setq e2 (entlast))
       (setq evl1 (cdrs 10 (entget e1)) ; ent vertex list
             evl2 (cdrs 10 (entget e2))
             ang1 (angle p1 (car evl2))
             ang2 (angle (car evl2) p1)
       )

       (initget "Y N")
       (setq ztype (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))

       (if (= ztype "Y")
         (progn
           (setq lst '())
           (foreach x evl1
             (setq lst (cons (polar x ang1 1) lst))
           )
           (foreach x (reverse evl2)
             (setq lst (cons (polar x ang2 1) lst))
           )
           (SetOsnaps "OFF") ; force off
           (command ".trim" e1 e2 "" "F")
           (apply 'command lst)
           (command "" "")
         )
       ) ;_ end of if
      ) ;_ end of if

      ;;===========================================
      ((= ztype "D")
       (setq dista  (distance pt1 pt2)
             dist1  (* 0.26 dista)
             dist2  (* 0.34 dista)
             dist3  (* 0.37 dista)
             dist4  (* 0.64 dista)
             dist5  (* 0.71 dista)
             dist6  (* 0.74 dista)
             zangle 1.396263402
             ang1   1.117010721
             ang2   1.588249619
             ang3   1.256637061
             ang4   1.483529864
             z1     (polar pt1 zangle dist1)
             z2     (polar pt1 ang1 dist2)
             z3     (polar pt1 ang2 dist2)
             z4     (polar pt1 zangle dist3)
             za     (polar pt1 zangle dist4)
             zb     (polar pt1 ang3 dist5)
             zc     (polar pt1 ang4 dist5)
             zd     (polar pt1 zangle dist6)
             zx     (polar pt1 zangle dista)
       ) ;_ end of setq

       (command ".pline" pt1 z1 z2 z3 z4 za zb zc zd zx "") ; Draw the Z-Line
       (setq z2line (entlast))
       (setvar "orthomode" 1)
       (command ".pedit" z2line "L" "ON" "")
       (command ".copy" z2line "" zx pause)
       (setvar "orthomode" 0)
       (setq pt2b (getvar "lastpoint")) ; ? error check CAB compare to pt1
       (setq trimdist2 (/ (distance zx pt2b) 2)
             td2x      (car zx)
             td2y      (cadr zx)
             x2point   (+ td2x trimdist2)
             trp1      (list x2point td2y)
             trp2      (list (+ (car zd) trimdist2) (cadr zd))
             trp3      (list (+ (car zc) trimdist2) (cadr zc))
             trp4      (list (+ (car zb) trimdist2) (cadr zb))
             trp5      (list (+ (car za) trimdist2) (cadr za))
             trp6      (list (+ (car z4) trimdist2) (cadr z4))
             trp7      (list (+ (car z3) trimdist2) (cadr z3))
             trp8      (list (+ (car z2) trimdist2) (cadr z2))
             trp9      (list (+ (car z1) trimdist2) (cadr z1))
             trp10     (list (+ (car pt1) trimdist2) (cadr pt1))
       ) ;_ end of setq

       (initget "Y N")
       (setq ztype (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
       (if (= ztype "Y")
         (command ".trim" pt1 pt2b "" "F" trp1 trp2 trp3 trp4 trp5 trp6 trp7 trp8 trp9 trp10 "" "") ;_ end of command
       ) ;_ end of if
      ) ;_ end cond
    ) ; end cond stmt
  ) ; endif
  ;;================
  ;;  Exit sequence
  ;;================\
  ;;  Restore settings
  ;;  I use current layer - CAB
  ;;(command ".layer" "set" oldlay "")
  (setvar "orthomode" oldortho)
  (setvar "osmode" oldosmode)
  (princ)
) ;_ end of defun
(prompt
  "\nDouble Break Symbol Creator loaded.  Type DZ to run it."
)
(princ)
Title: cut lines
Post by: ELOQUINTET on October 04, 2004, 10:24:12 PM
ok cab i'll give it a shot tomorrow thanks so much for your hard work this has been annoying me for quite some time. and thanks smurf for your help too  :wink:
Title: cut lines
Post by: CAB on October 04, 2004, 11:43:58 PM
Quote from: hyposmurf
Your trying to do a similar thing to the thread I posted,never worked how to do it though.Your trying to add two lines and have them trim whats inside them.Im trying to do that but then have the two lines deleted,once theyve trimed.Curently have to create two lines,trim inside them and then delete them,bit like a triming template,its annoyingly slow when you have 100's of pipe intersections.


Sorry I don't remember the thread, can you point me to it?
Or discribe exactly what you are trying to do?
Title: cut lines
Post by: hendie on October 05, 2004, 03:20:47 AM
Quote from: CAB
dan
Here is one I use. I just updated the single break symbol code and the other
option is disabled for now.


heh.. CAB, I was thinking of reposting that yesterday when I saw the thread but the original was so lame and I wrote it so long ago I was a bit embarrassed about it.
I have been meaning to revisit it for so long to accommodate using any angle for input but .. y'know how it goes... just never got around to it.

(it's always embarrassing when your "early" lisps come back to haunt you !).. but hopefully you've prompted me to revisit it again in the near future.
Title: cut lines
Post by: CAB on October 05, 2004, 08:02:02 AM
Quote from: hendie
heh.. CAB, I was thinking of reposting that yesterday when I saw the thread but the original was so lame and I wrote it so long ago I was a bit embarrassed about it.
I have been meaning to revisit it for so long to accommodate using any angle for input but .. y'know how it goes... just never got around to it.

(it's always embarrassing when your "early" lisps come back to haunt you !).. but hopefully you've prompted me to revisit it again in the near future.

Yes, we learned a lot in the last two years.
I to have many lisp that when I look at them again I wonder why I did it that way.
But at least you got the job done & I have been using this lisp for a year, so thanks
for that. I wrote a single break line routine some time back that could be drawn at
any angle and I was going to update yours to include that feature but as you say
I never got around to it. :)
Title: cut lines
Post by: ELOQUINTET on October 05, 2004, 08:04:36 AM
hey cab tried it out and it does what i want sometimes. it seems to only trim the stuff out if the cutline extends far past the object. if not the trim gets all screwed up. is this what you meant about fixing the trim part? anyhow works pretty nice so far good job.
Title: cut lines
Post by: ELOQUINTET on October 05, 2004, 11:28:41 AM
so what's up with this routine should i begin modifying small stuff in it or are you still refining it cab. i would like to have ortho turned on and have my osnaps reset upon exiting but don't want to modify it if you are going to update it???
Title: cut lines
Post by: hendie on October 05, 2004, 11:44:19 AM
Dan, what's wrong with you updating it ?
Title: cut lines
Post by: CAB on October 05, 2004, 11:59:32 AM
Quote from: eloquintet
hey cab tried it out and it does what i want sometimes. it seems to only trim the stuff out if the cutline extends far past the object. if not the trim gets all screwed up. is this what you meant about fixing the trim part? anyhow works pretty nice so far good job.

Can you post a drawing example of when it fails to trim.
I can not recreate the error.
Title: cut lines
Post by: CAB on October 05, 2004, 01:35:45 PM
Quote from: eloquintet
so what's up with this routine should i begin modifying small stuff in it or are you still refining it cab. i would like to have ortho turned on and have my osnaps reset upon exiting but don't want to modify it if you are going to update it???

I updated the code posted above with changes to osnaps.
Yes, more to come.
Still can not recreate your error.
CAB
Title: cut lines
Post by: ELOQUINTET on October 05, 2004, 02:49:59 PM
i can update the simple things hendie but solving the entire riddle is kind of beyond my knowledge at this point. besides i didn't want to do work i was sure cab was already doing to improve the routine. cab i'll post a picture shortly ok.
Title: cut lines
Post by: CAB on October 05, 2004, 08:54:21 PM
OK,here is the updated code.
Still has an issue with lines to be trimmed that run through the Z part
of the pline. If the line to be trimmed runs through 3 times some of the
line may not be trimmed. There also an issue with lines that just protrude
into the trim space but are closer that the trim distance. i set the trim
distance at (break line length / 70) which works out to be 36/70= 0.51
That is 1/2 inch on a 36 inch break line.
If this is not close enough I'll change it.
Code: [Select]
;;; Lisp to draw Single or Double "Z" Break Lines
;;;                 © A.Henderson 2002
;;;
;;;  Modified By Charles Alan Butler  10/02/2004
;;;  To allow any angle and to trim lines that
;;;  do not run through both break symbols
;;;

(defun c:dz (/ oldlay oldotho oldosmode ztype dist ang
             e1 e2 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10)
  ;; return vertex list by MP
  (defun cdrs (key lst / pair rtn)
    (while (setq pair (assoc key lst))
      (setq rtn (cons (cdr pair) rtn)
            lst (cdr (member pair lst))
      )
    )
    (reverse rtn)
  ) ; defun

  ;;  set osnaps ON/OFF
  (defun setosnaps (value) ; value = "ON" or default to "OFF"
    (if value
      (setq value (strcase value))
    )
    (cond
      ((or (and (= value "ON") (>= (getvar "osmode") 16383))
           (and (/= value "ON") (<= (getvar "osmode") 16383))
       )
       (setvar "osmode" (boole 6 (getvar "osmode") 16384))
      )
    )
  ); defun

  ;;   Start of routine  ==================================
  ;;  Save settings
  (setq oldlay    (getvar "clayer")
        oldortho  (getvar "orthomode")
        oldosmode (getvar "osmode")
  ) ;_ end of setq
  ;;  I use current layer - CAB
  ;;(command ".layer" "make" "Z-Line" "Colour" "41" "" "")

  (initget "S D")
  (setq ztype (getkword "\n Single or Double -^v-^v- ? (S or D) <S>"))
  (setosnaps "ON") ; force on
  ;;===========================================
  (if (and (setq p1 (getpoint "Starting point of break line : "))
           (setq p6 (getpoint p1 "End point of break line : "))
      )
    (progn;===========================================
      (setvar "plinewid" 0)
      (cond
        ((/= ztype "D") ; default to single
         (setq dist (distance p1 p6)
               ang  (angle p1 p6)
               p2   (polar p1 ang (* 0.4167 dist))
               p5   (polar p1 ang (* 0.5833 dist))
               p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
               p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
         ) ;_ end of setq
         (setosnaps "OFF") ; force off
         (command "pline" p1 p2 p3 p4 p5 p6 "") ; Draw the Z-Line
        ) ;_ end cond "S"

        ;;===========================================
        ((= ztype "D")
         (setq p10  p6
               dist (/ (distance p1 p6) 2.0)
               ang  (angle p1 p6)
               p2   (polar p1 ang (* 0.4167 dist))
               p5   (polar p1 ang (* 0.5833 dist))
               p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
               p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
               p6   (polar p5 ang (* 0.8334 dist))
               p9   (polar p6 ang (* 0.1661 dist))
               p7   (polar p6 (+ 1.25664 ang) (* 0.1667 dist))
               p8   (polar p9 (+ 4.39824 ang) (* 0.1667 dist))
         ) ;_ end of setq
         (setosnaps "OFF") ; force off
         (command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 "") ; Draw the Z-Line
        ) ;_ end cond
      ) ; end cond stmt

      ;;  Position the second break line
      (setq e1 (entlast))
      (command ".pedit" e1 "L" "ON" "")
      (command ".copy" e1 "" (getvar "lastpoint") pause)
      (setq e2 (entlast))

      ;;  trim function
      (initget "Y N")
      (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if (= ans "Y")
        (progn
          (setq evl1 (cdrs 10 (entget e1)) ; ent vertex list
                evl2 (cdrs 10 (entget e2))
                ang1 (angle p1 (car evl2))
                ang2 (angle (car evl2) p1)
          )
          (setq lst  '()
                dist (/ dist 70.0)
          )
          (foreach x evl1
            (setq lst (cons (polar x ang1 1) lst))
          )
          (foreach x (reverse evl2)
            (setq lst (cons (polar x ang2 1) lst))
          )
          (setosnaps "OFF") ; force off
          (command ".trim" e1 e2 "" "F")
          (apply 'command lst)
          (command "" "")
        ) ; progn
      ) ;_ endif


    ) ; progn
  ) ; endif
  ;;================
  ;;  Exit sequence
  ;;================\
  ;;  Restore settings
  ;;  I use current layer - CAB
  ;;(command ".layer" "set" oldlay "")
  (setvar "orthomode" oldortho)
  (setvar "osmode" oldosmode)
  (princ)
) ;_ end of defun
(prompt
  "\nDouble Break Symbol Creator loaded.  Type DZ to run it."
)
(princ)
Title: cut lines
Post by: ELOQUINTET on October 06, 2004, 08:11:37 AM
ok cab i haven't tried the newest version, didn't know it was up but here's my screenshot from this morning. i'll try the new one and see how it goes. the width of my obect in the drawing is 1/2"

http://theswamp.org/lilly_pond/dan/CUTLINE%202.JPG?nossi=1
Title: cut lines
Post by: PDJ on October 06, 2004, 12:37:45 PM
Hey HypoSmurf, I have one I wrote a while back that does what you need.  Check this out and let me know:

[code](defun c:TR2 (/ p1 p2 e1 e2 d1)
  (setvar "cmdecho" 0)
  (prompt "\nIndicate TRIM planes: ")
  (setq p1 (getpoint))
  (setq p2 (getpoint p1))
  (command nil nil nil "point" "@")
  (setq e1 (entlast))
  (entdel e1)
  (command "line" p1 p2 "")
  (setq e2 (entnext e1))
  (prompt "\nIndicate 2nd TRIM plane: ")
  (setq p3 (getpoint))
  (setq p4 (getpoint p3))
  (command nil nil nil "point" "@")
  (setq e3 (entlast))
  (entdel e3)
  (command "line" p3 p4 "")
  (setq e4 (entnext e3))
   (while
    (setq d1 (entsel "\nSelect object(s) to TRIM: "))
    (command "TRIM" e2 e4 "" d1 "")
   );while
  (entdel e2)
  (entdel e4)
(setvar "cmdecho" 1)
 (princ)
)
[code][/code]
Title: cut lines
Post by: CAB on October 06, 2004, 02:51:20 PM
Dan,
Here is the latest code.
Reduced the trim distance to catch any close lines.
Had the routine trim twice to get any lines that the first
may have missed. Revised the method to get a fence as the old
method had a gotcha in it.

Code: [Select]
;;; Lisp to draw Single or Double "Z" Break Lines
;;;                 © A.Henderson 2002
;;;
;;;  Modified By Charles Alan Butler  10/06/2004
;;;  To allow any angle and to trim lines that
;;;  do not run through both break symbols
;;;

(defun c:dz (/ oldlay oldotho oldosmode ztype dist ang
             e1 e2 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10)
  ;; return vertex list by MP
  (defun cdrs (key lst / pair rtn)
    (while (setq pair (assoc key lst))
      (setq rtn (cons (cdr pair) rtn)
            lst (cdr (member pair lst))
      )
    )
    (reverse rtn)
  ) ; defun

  ;;  set osnaps ON/OFF
  (defun setosnaps (value) ; value = "ON" or default to "OFF"
    (if value
      (setq value (strcase value))
    )
    (cond
      ((or (and (= value "ON") (>= (getvar "osmode") 16383))
           (and (/= value "ON") (<= (getvar "osmode") 16383))
       )
       (setvar "osmode" (boole 6 (getvar "osmode") 16384))
      )
    )
  ); defun

  ;;   Start of routine  ==================================
  ;;  Save settings
  (setq oldlay    (getvar "clayer")
        oldortho  (getvar "orthomode")
        oldosmode (getvar "osmode")
  ) ;_ end of setq
  ;;  I use current layer - CAB
  ;;(command ".layer" "make" "Z-Line" "Colour" "41" "" "")

  (initget "S D")
  (setq ztype (getkword "\n Single or Double -^v-^v- ? (S or D) <S>"))
  (setosnaps "ON") ; force on
  ;;===========================================
  (if (and (setq p1 (getpoint "Starting point of break line : "))
           (setq p6 (getpoint p1 "End point of break line : "))
      )
    (progn;===========================================
      (setvar "plinewid" 0)
      (command "._undo" "_begin")
      (cond
        ((/= ztype "D") ; default to single
         (setq dist (distance p1 p6)
               ang  (angle p1 p6)
               p2   (polar p1 ang (* 0.4167 dist))
               p5   (polar p1 ang (* 0.5833 dist))
               p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
               p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
         ) ;_ end of setq
         (setosnaps "OFF") ; force off
         (command "pline" p1 p2 p3 p4 p5 p6 "") ; Draw the Z-Line
        ) ;_ end cond "S"

        ;;===========================================
        ((= ztype "D")
         (setq p10  p6
               dist (/ (distance p1 p6) 2.0)
               ang  (angle p1 p6)
               p2   (polar p1 ang (* 0.4167 dist))
               p5   (polar p1 ang (* 0.5833 dist))
               p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
               p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
               p6   (polar p5 ang (* 0.8334 dist))
               p9   (polar p6 ang (* 0.1661 dist))
               p7   (polar p6 (+ 1.25664 ang) (* 0.1667 dist))
               p8   (polar p9 (+ 4.39824 ang) (* 0.1667 dist))
         ) ;_ end of setq
         (setosnaps "OFF") ; force off
         (command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 "") ; Draw the Z-Line
        ) ;_ end cond
      ) ; end cond stmt

      ;;  Position the second break line
      (setq e1 (entlast))
      (command ".pedit" e1 "L" "ON" "")
      (command ".copy" e1 "" (getvar "lastpoint") pause)
      (setq e2 (entlast))
      (setq plast (getvar "lastpoint"))

      ;;  trim function
      (initget "Y N")
      (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if (= ans "Y")
        (progn
          (setq lst  '()
                dist (/ dist 140.0) ; trim distance
          )
          ;;  create trim lines
          (command "._offset" dist e1 plast "")
          (setq evl1 (cdrs 10 (entget (entlast)))) ; ent vertex list
          (entdel (entlast))
          (command "._offset" dist e2 p1 "")
          (setq evl2 (cdrs 10 (entget (entlast))))
          (entdel (entlast))        
          (setq lst (append evl1 (reverse evl2)))
          (setosnaps "OFF") ; force off
          (command ".trim" e1 e2 "" "F")
          (apply 'command lst)
          (command "" "")
          (command ".trim" e1 e2 "" "F")
          (apply 'command lst)
          (command "" "")
        ) ; progn
      ) ;_ endif
      (command "._undo" "_end")

    ) ; progn
  ) ; endif
  ;;================
  ;;  Exit sequence
  ;;================\
  ;;  Restore settings
  ;;  I use current layer - CAB
  ;;(command ".layer" "set" oldlay "")
  (setvar "orthomode" oldortho)
  (setvar "osmode" oldosmode)
  (princ)
) ;_ end of defun
(prompt
  "\nDouble Break Symbol Creator loaded.  Type DZ to run it."
)
(princ)
Title: cut lines
Post by: ELOQUINTET on October 07, 2004, 08:24:51 AM
ok i'll give it a try later today thanks man
Title: cut lines
Post by: M-dub on October 07, 2004, 08:44:29 AM
That's pretty sweet.  I like it.  :)
Title: cut lines
Post by: ELOQUINTET on October 07, 2004, 11:08:23 AM
cab works great now. i changed a couple things though. i removed the single or double prompt at the beginning as i only use single and kept picking instead. and of course i changed the layer. one question though if i wanted it to trim automatically instead of having to say yes how would i modify it. i tried just taking this section  out of the trim function but get an error



Code: [Select]
     (initget "Y N")
      (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if (= ans "Y")
Title: cut lines
Post by: CAB on October 07, 2004, 11:27:35 AM
Code: [Select]
       ) ; progn
      ) ;_ endif         <--------------<<<  Remove this line
      (command "._undo" "_end")
Title: cut lines
Post by: ELOQUINTET on October 07, 2004, 11:40:29 AM
hmmm when i took it out i got malformed list
Title: cut lines
Post by: CAB on October 07, 2004, 12:34:40 PM
Change as follows from this
Code: [Select]
     (initget "Y N")
      (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if (= ans "Y")

to this
Code: [Select]
     ;;(initget "Y N")
      ;;(setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if T

Or remove all these lines
Code: [Select]
     (initget "Y N")
      (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if (= ans "Y")
        (progn

       <keep lines here>

        ) ; progn
      ) ;_ endif
Title: cut lines
Post by: ELOQUINTET on October 07, 2004, 01:36:33 PM
bingo that's it thanks you very much for your help cab i really appreciate it
Title: cut lines
Post by: hyposmurf on October 08, 2004, 06:27:03 PM
Quote
Hey HypoSmurf, I have one I wrote a while back that does what you need. Check this out and let me know:

Thanks PDJ it does work but I have a slight probelm with it.When Im asked to indicate trim planes I have to guess the location of my trim planes,either side of the line.Both trim planes will be the same offset distance from the the line theyre parallel to.Its like I have two intersecting lines and I need to cut for example 50mm off each side of one of the lines at the point of intersection.

Code:
;;; Lisp to draw Single or Double "Z" Break Lines
;;;                 © A.Henderson 2002
;;;
;;;  Modified By Charles Alan Butler  10/02/2004
;;;  To allow any angle and to trim lines that
;;;  do not run through both break symbols
;;;

(defun c:dz (/ oldlay oldotho oldosmode ztype dist ang
             e1 e2 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10)
  ;; return vertex list by MP
  (defun cdrs (key lst / pair rtn)
    (while (setq pair (assoc key lst))
      (setq rtn (cons (cdr pair) rtn)
            lst (cdr (member pair lst))
      )
    )
    (reverse rtn)
  ) ; defun

  ;;  set osnaps ON/OFF
  (defun setosnaps (value) ; value = "ON" or default to "OFF"
    (if value
      (setq value (strcase value))
    )
    (cond
      ((or (and (= value "ON") (>= (getvar "osmode") 16383))
           (and (/= value "ON") (<= (getvar "osmode") 16383))
       )
       (setvar "osmode" (boole 6 (getvar "osmode") 16384))
      )
    )
  ); defun

  ;;   Start of routine  ==================================
  ;;  Save settings
  (setq oldlay    (getvar "clayer")
        oldortho  (getvar "orthomode")
        oldosmode (getvar "osmode")
  ) ;_ end of setq
  ;;  I use current layer - CAB
  ;;(command ".layer" "make" "Z-Line" "Colour" "41" "" "")

  (initget "S D")
  (setq ztype (getkword "\n Single or Double -^v-^v- ? (S or D) <S>"))
  (setosnaps "ON") ; force on
  ;;===========================================
  (if (and (setq p1 (getpoint "Starting point of break line : "))
           (setq p6 (getpoint p1 "End point of break line : "))
      )
    (progn;===========================================
      (setvar "plinewid" 0)
      (cond
        ((/= ztype "D") ; default to single
         (setq dist (distance p1 p6)
               ang  (angle p1 p6)
               p2   (polar p1 ang (* 0.4167 dist))
               p5   (polar p1 ang (* 0.5833 dist))
               p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
               p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
         ) ;_ end of setq
         (setosnaps "OFF") ; force off
         (command "pline" p1 p2 p3 p4 p5 p6 "") ; Draw the Z-Line
        ) ;_ end cond "S"

        ;;===========================================
        ((= ztype "D")
         (setq p10  p6
               dist (/ (distance p1 p6) 2.0)
               ang  (angle p1 p6)
               p2   (polar p1 ang (* 0.4167 dist))
               p5   (polar p1 ang (* 0.5833 dist))
               p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
               p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
               p6   (polar p5 ang (* 0.8334 dist))
               p9   (polar p6 ang (* 0.1661 dist))
               p7   (polar p6 (+ 1.25664 ang) (* 0.1667 dist))
               p8   (polar p9 (+ 4.39824 ang) (* 0.1667 dist))
         ) ;_ end of setq
         (setosnaps "OFF") ; force off
         (command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 "") ; Draw the Z-Line
        ) ;_ end cond
      ) ; end cond stmt

      ;;  Position the second break line
      (setq e1 (entlast))
      (command ".pedit" e1 "L" "ON" "")
      (command ".copy" e1 "" (getvar "lastpoint") pause)
      (setq e2 (entlast))

      ;;  trim function
      (initget "Y N")
      (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
      (if (= ans "Y")
        (progn
          (setq evl1 (cdrs 10 (entget e1)) ; ent vertex list
                evl2 (cdrs 10 (entget e2))
                ang1 (angle p1 (car evl2))
                ang2 (angle (car evl2) p1)
          )
          (setq lst  '()
                dist (/ dist 70.0)
          )
          (foreach x evl1
            (setq lst (cons (polar x ang1 1) lst))
          )
          (foreach x (reverse evl2)
            (setq lst (cons (polar x ang2 1) lst))
          )
          (setosnaps "OFF") ; force off
          (command ".trim" e1 e2 "" "F")
          (apply 'command lst)
          (command "" "")
        ) ; progn
      ) ;_ endif


    ) ; progn
  ) ; endif
  ;;================
  ;;  Exit sequence
  ;;================\
  ;;  Restore settings
  ;;  I use current layer - CAB
  ;;(command ".layer" "set" oldlay "")
  (setvar "orthomode" oldortho)
  (setvar "osmode" oldosmode)
  (princ)
) ;_ end of defun
(prompt
  "\nDouble Break Symbol Creator loaded.  Type DZ to run it."
)
(princ)
Thanks to Hendy to.
Title: cut lines
Post by: CAB on October 08, 2004, 07:08:58 PM
hyposmurf
I modified this routine to trim 50 units eather side of a picked line.
If you upload a DWG file of the before trim and after trim, perhaps we can get colser to what you want.
Code: [Select]
;;  Trims at an offset distance from line or lwpline
;;  Select th line, enter an amount say 5
;;  Trims all crossing lines within 5 units of eather side
;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(vl-load-com)

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun c:trimoff (/ en1 ed1 obj1 ssstpt enpt etype lst)
 ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun 2dvararray->list (a / l lst c)
  (setq c 0)
  (setq l (vlax-safearray->list (vlax-variant-value a)))
  (setq len (length l))
  (while (< c (- len 1))
    (setq lst (append lst (list (list (nth c l) (nth (+ c 1) l)))))
    (setq c (+ 2 c))
  )
  lst
)
 ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

 (while (= etype nil)
    (setq en1
  (car
    (entsel "\nSelect line or polyline to remain continuous: ")
  )
    )
    (setq ed1 (entget en1))
    (setq etype (cdr (assoc 0 ed1)))
    (if (and (/= etype "LINE") (/= etype "LWPOLYLINE"))
      (progn
(princ "\n*** You must select a Line or LWPolyline ***")
(setq etype nil)
      )
    )
  )
  ;;======================================================
  ;; This section changed, remove comments to allow choice of gap
  ;;(setq thru_gap (cond (thru_gap) (50))); default gap
  ;;(setq ans (getdist (strcat "\nGap spacing" " <" (rtos thru_gap) ">: ")))
  ;;(setq thru_gap (cond ((> ans 0) ans) (thru_gap))); set gap
  (setq thru_gap 50.0) ; Hyposmurf chose this value, delete this line
  ;;======================================================
  (setq obj1 (vlax-ename->vla-object en1))
  (setq sa1 (vla-offset obj1 thru_gap))
  (setq sa2 (vla-offset obj1 (* thru_gap -1)))
  (setq obj2 (vlax-safearray-get-element (vlax-variant-value sa1) 0))
  (setq obj3 (vlax-safearray-get-element (vlax-variant-value sa2) 0))
  (cond
    ((= etype "LINE")
     (setq stpt (vlax-safearray->list
 (vlax-variant-value
   (vla-get-startpoint obj1)
 )
)
     )
     (setq enpt (vlax-safearray->list
 (vlax-variant-value
   (vla-get-endpoint obj1)
 )
)
     )
     (setq lst (list stpt enpt))
    )
    ((= etype "LWPOLYLINE")
     (setq coords (vla-get-coordinates obj1))
     (setq lst (2dvararray->list coords))
    )
  )
  (setq ss (ssadd))
  (ssadd (vlax-vla-object->ename obj2) ss)
  (ssadd (vlax-vla-object->ename obj3) ss)
  (setvar "cmdecho" 0)
  (command "trim" ss "")
  (command "f")
  (apply 'command lst)
  (command "" "")
  (setvar "cmdecho" 1)
  (vla-delete obj2)
  (vla-delete obj3)
  (princ)
)
Title: cut lines
Post by: hyposmurf on October 09, 2004, 11:43:30 AM
No need to upload a drawing I think youve hit the nail on the head CAB.Cheers :dood: What is the top section for (2dvararray->list ) ?Just another way of skinny that cat?Cant get it to work,firstly it brings up my units dialogue box and then when I add 2DVARARRAY->LIST to the command line it doesnt recognise it.Thanks anyway I have what I need,but Im just curious.
Title: cut lines
Post by: CAB on October 09, 2004, 12:02:09 PM
It is a subroutine for the main function, should have been localized.
See the code above, I moved it.
Title: cut lines
Post by: CAB on October 09, 2004, 12:15:53 PM
See here    
   
Code: [Select]
(setq coords (vla-get-coordinates obj1))
     (setq lst (2dvararray->list coords))

the vla-get-coordinates returns the coordinates in a list but the trim command
needs the list to be a point list. The 2dvararray->list converts this
Code: [Select]
(-145.23 163.22 -93.8048 202.378 -54.624 179.128 6.59602 203.601 34.7572 183.411)
to this
Code: [Select]
((-145.23 163.22)(-93.8048 202.378)(-54.624 179.128)(6.59602 203.601)(34.7572 183.411))
Title: cut lines
Post by: hyposmurf on June 12, 2005, 05:23:30 AM
Just got back to this one! :roll: Ive managed to run through the lisp and modify it to do what I want.

Code: [Select]
;;  Trims at an offset distance from line or lwpline
;;  Select the line, enter an amount say 5
;;  Trims all crossing lines within 5 units of eather side
;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(vl-load-com)

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun c:trimoff (/ en1 ed1 obj1 ssstpt enpt etype lst)
 ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun 2dvararray->list   (a / l lst c)
  (setq c 0)
  (setq l (vlax-safearray->list (vlax-variant-value a)))
  (setq len (length l))
  (while (< c (- len 1))
    (setq lst (append lst (list (list (nth c l) (nth (+ c 1) l)))))
    (setq c (+ 2 c))
  )
  lst
)
 ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

 (while (= etype nil)
    (setq en1
      (car
        (entsel "\nSelect line or polyline to remain continuous: ")
      )
    )
    (setq ed1 (entget en1))
    (setq etype (cdr (assoc 0 ed1)))
    (if   (and (/= etype "LINE") (/= etype "LWPOLYLINE"))
      (progn
   (princ "\n*** You must select a Line or LWPolyline ***")
   (setq etype nil)
      )
    )
  )
  (setq thru_gap (cond (thru_gap) (10))); default gap user can modify
  (setq ans (getdist (strcat "\nGap spacing" " <" (rtos thru_gap) ">: ")))
  (setq thru_gap (cond ((> ans 0) ans) (thru_gap))); set gap
  ;;======================================================
  (setq obj1 (vlax-ename->vla-object en1))
  (setq sa1 (vla-offset obj1 thru_gap))
  (setq sa2 (vla-offset obj1 (* thru_gap -1)))
  (setq obj2 (vlax-safearray-get-element (vlax-variant-value sa1) 0))
  (setq obj3 (vlax-safearray-get-element (vlax-variant-value sa2) 0))
  (cond
    ((= etype "LINE")
     (setq stpt   (vlax-safearray->list
        (vlax-variant-value
          (vla-get-startpoint obj1)
        )
      )
     )
     (setq enpt   (vlax-safearray->list
        (vlax-variant-value
          (vla-get-endpoint obj1)
        )
      )
     )
     (setq lst (list stpt enpt))
    )
    ((= etype "LWPOLYLINE")
     (setq coords (vla-get-coordinates obj1))
     (setq lst (2dvararray->list coords))
    )
  )
  (setq ss (ssadd))
  (ssadd (vlax-vla-object->ename obj2) ss)
  (ssadd (vlax-vla-object->ename obj3) ss)
  (setvar "cmdecho" 0)
  (command "trim" ss "")
  (command "f")
  (apply 'command lst)
  (command "" "")
  (setvar "cmdecho" 1)
  (vla-delete obj2)
  (vla-delete obj3)
  (princ)
)
)


Ive removed the comments as CAB noted in his additional comments so I can choose the offset distance.Ive chosen 10 units in this case.
As simple as that modification is thought Id add it so any other dumb arses like myself arent scratching their head for a while trying to work it out.
Title: cut lines
Post by: CAB on June 12, 2005, 09:30:02 AM
With the new talk about vlax-curve- I changed the code to use it.

Code: [Select]
;;  Trims at an offset distance from line or lwpline
;;  Select the line, enter an amount say 5
;;  Trims all crossing lines within 5 units of eather side
;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(vl-load-com)

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun c:trimoff (/ en1 ed1 obj1 ssstpt enpt etype lst)
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  (defun 2dvararray->list (a / l lst c)
    (setq l   (vlax-safearray->list (vlax-variant-value a))
          len (length l)
          c   0
    )
    (while (< c (- len 1))
      (setq lst (append lst (list (list (nth c l) (nth (+ c 1) l)))))
      (setq c (+ 2 c))
    )
    lst
  )
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  (while (= etype nil)
    (setq en1 (entsel "\nSelect line or polyline to remain continuous: "))
    (if (or (null en1)
            (and (setq ed1 (entget (setq en1 (car en1))))
                 (setq etype (cdr (assoc 0 ed1)))
                 (/= etype "LINE")
                 (/= etype "LWPOLYLINE")
            )
        )
      (progn
        (princ "\n*** You must select a Line or LWPolyline ***")
        (setq etype nil)
      )
    )
  )
  (setq thru_gap (cond (thru_gap)
                       (10)
                 )
  ) ; default gap user can modify
  (setq ans (getdist (strcat "\nGap spacing" " <" (rtos thru_gap) ">: ")))
  (setq thru_gap (cond ((> ans 0) ans)
                       (thru_gap)
                 )
  ) ; set gap

  ;;======================================================
  ;;  Offset the object
  (setq obj1 (vlax-ename->vla-object en1))
  (setq sa1 (vla-offset obj1 thru_gap))
  (setq sa2 (vla-offset obj1 (* thru_gap -1)))
  ;;  get the new objects
  (setq obj2 (vlax-safearray-get-element (vlax-variant-value sa1) 0))
  (setq obj3 (vlax-safearray-get-element (vlax-variant-value sa2) 0))
  ;;  get the end points
  (cond
    ((= etype "LINE")
     (setq lst (list (vlax-curve-getstartpoint obj1)
                     (vlax-curve-getendpoint obj1)
               )
     )
    )
    ((= etype "LWPOLYLINE")
     (setq coords (vla-get-coordinates obj1))
     (setq lst (2dvararray->list coords))
    )
  )
  ;;  Make ss the boundaries, lst will be the fence
  (setq ss (ssadd))
  (ssadd (vlax-vla-object->ename obj2) ss)
  (ssadd (vlax-vla-object->ename obj3) ss)
  (setvar "cmdecho" 0)
  (command "trim" ss "")
  (command "f")
  (apply 'command lst)
  (command "" "")
  (setvar "cmdecho" 1)
  (vla-delete obj2)
  (vla-delete obj3)
  (princ)
)


edit: fixed a bug I introuduced.
Title: Re: cut lines
Post by: hyposmurf on September 30, 2005, 05:45:17 PM
Although I really rate this lisp,one problem I do encounter is that when its implemented on a line/polyline it will carry out a trim either side of this line on objects out of the screen along the entire length of the line/polyline.Problem with that is when you have a busy drawing its not always to see what has been cut when your zoomed into a area.Is there a way to just isolate the lisp to focus on one are or say just two crossing lines?
Title: Re: cut lines
Post by: Andrea on October 05, 2005, 12:58:22 PM
Hi,...

I have created this routine for endpipe..
but you can use-it and change the end block as you wish.