Author Topic: Drawing cylindrical break line ?  (Read 9131 times)

0 Members and 1 Guest are viewing this topic.

liuhaixin88

  • Guest
Drawing cylindrical break line ?
« on: April 22, 2014, 08:31:24 PM »
Pick up three points, Drawing cylindrical break line , Forum has this code ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Drawing cylindrical break line ?
« Reply #1 on: April 22, 2014, 09:57:01 PM »
Welcome to the Swamp.

Not one exactly like that.
http://www.theswamp.org/index.php?topic=37531
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

liuhaixin88

  • Guest
Re: Drawing cylindrical break line ?
« Reply #2 on: April 22, 2014, 10:34:49 PM »
Thank you very much !CAB,  great! I have been used. It's just draw a symbol, Not automatically break line.
I prefer your another program. Can you modify it for me ?

Code - Auto/Visual Lisp: [Select]
  1. ;;; Lisp to draw Single or Double "Z" Break Lines
  2. ;;;                 ? A.Henderson 2002
  3. ;;;
  4. ;;;  Modified By Charles Alan Butler  10/06/2004
  5. ;;;  To allow any angle and to trim lines that
  6. ;;;  do not run through both break symbols
  7. ;;;
  8.  
  9. (defun c:dz (/ oldlay oldotho oldosmode ztype dist ang
  10.              e1 e2 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10)
  11.   ;; return vertex list by MP
  12.   (defun cdrs (key lst / pair rtn)
  13.     (while (setq pair (assoc key lst))
  14.       (setq rtn (cons (cdr pair) rtn)
  15.             lst (cdr (member pair lst))
  16.       )
  17.     )
  18.     (reverse rtn)
  19.   ) ; defun
  20.  
  21.   ;;  set osnaps ON/OFF
  22.   (defun setosnaps (value) ; value = "ON" or default to "OFF"
  23.     (if value
  24.       (setq value (strcase value))
  25.     )
  26.     (cond
  27.       ((or (and (= value "ON") (>= (getvar "osmode") 16383))
  28.            (and (/= value "ON") (<= (getvar "osmode") 16383))
  29.        )
  30.        (setvar "osmode" (boole 6 (getvar "osmode") 16384))
  31.       )
  32.     )
  33.   ); defun
  34.  
  35.   ;;   Start of routine  ==================================
  36.   ;;  Save settings
  37.   (setq oldlay    (getvar "clayer")
  38.         oldortho  (getvar "orthomode")
  39.         oldosmode (getvar "osmode")
  40.   ) ;_ end of setq
  41.   ;;  I use current layer - CAB
  42.   ;;(command ".layer" "make" "Z-Line" "Colour" "41" "" "")
  43.  
  44.   (initget "S D")
  45.   (setq ztype (getkword "\n Single or Double -^v-^v- ? (S or D) <S>"))
  46.   (setosnaps "ON") ; force on
  47.   ;;===========================================
  48.   (if (and (setq p1 (getpoint "Starting point of break line : "))
  49.            (setq p6 (getpoint p1 "End point of break line : "))
  50.       )
  51.     (progn;===========================================
  52.       (setvar "plinewid" 0)
  53.       (command "._undo" "_begin")
  54.       (cond
  55.         ((/= ztype "D") ; default to single
  56.          (setq dist (distance p1 p6)
  57.                ang  (angle p1 p6)
  58.                p2   (polar p1 ang (* 0.4167 dist))
  59.                p5   (polar p1 ang (* 0.5833 dist))
  60.                p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
  61.                p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
  62.          ) ;_ end of setq
  63.          (setosnaps "OFF") ; force off
  64.          (command "pline" p1 p2 p3 p4 p5 p6 "") ; Draw the Z-Line
  65.         ) ;_ end cond "S"
  66.  
  67.         ;;===========================================
  68.         ((= ztype "D")
  69.          (setq p10  p6
  70.                dist (/ (distance p1 p6) 2.0)
  71.                ang  (angle p1 p6)
  72.                p2   (polar p1 ang (* 0.4167 dist))
  73.                p5   (polar p1 ang (* 0.5833 dist))
  74.                p3   (polar p2 (+ 1.25664 ang) (* 0.1667 dist))
  75.                p4   (polar p5 (+ 4.39824 ang) (* 0.1667 dist))
  76.                p6   (polar p5 ang (* 0.8334 dist))
  77.                p9   (polar p6 ang (* 0.1661 dist))
  78.                p7   (polar p6 (+ 1.25664 ang) (* 0.1667 dist))
  79.                p8   (polar p9 (+ 4.39824 ang) (* 0.1667 dist))
  80.          ) ;_ end of setq
  81.          (setosnaps "OFF") ; force off
  82.          (command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 "") ; Draw the Z-Line
  83.         ) ;_ end cond
  84.       ) ; end cond stmt
  85.  
  86.       ;;  Position the second break line
  87.       (setq e1 (entlast))
  88.       (command ".pedit" e1 "L" "ON" "")
  89.       (command ".copy" e1 "" (getvar "lastpoint") pause)
  90.       (setq e2 (entlast))
  91.       (setq plast (getvar "lastpoint"))
  92.  
  93.       ;;  trim function
  94.       (initget "Y N")
  95.       (setq ans (getkword "\n Do you wish to trim the lines now ? (Y or N) <N>"))
  96.       (if (= ans "Y")
  97.         (progn
  98.           (setq lst  '()
  99.                 dist (/ dist 140.0) ; trim distance
  100.           )
  101.           ;;  create trim lines
  102.           (command "._offset" dist e1 plast "")
  103.           (setq evl1 (cdrs 10 (entget (entlast)))) ; ent vertex list
  104.           (entdel (entlast))
  105.           (command "._offset" dist e2 p1 "")
  106.           (setq evl2 (cdrs 10 (entget (entlast))))
  107.           (entdel (entlast))        
  108.           (setq lst (append evl1 (reverse evl2)))
  109.           (setosnaps "OFF") ; force off
  110.           (command ".trim" e1 e2 "" "F")
  111.           (apply 'command lst)
  112.           (command "" "")
  113.           (command ".trim" e1 e2 "" "F")
  114.           (apply 'command lst)
  115.           (command "" "")
  116.         ) ; progn
  117.       ) ;_ endif
  118.       (command "._undo" "_end")
  119.  
  120.     ) ; progn
  121.   ) ; endif
  122.   ;;================
  123.   ;;  Exit sequence
  124.   ;;================\
  125.   ;;  Restore settings
  126.   ;;  I use current layer - CAB
  127.   ;;(command ".layer" "set" oldlay "")
  128.   (setvar "orthomode" oldortho)
  129.   (setvar "osmode" oldosmode)
  130.   (princ)
  131. ) ;_ end of defun
  132.   "\nDouble Break Symbol Creator loaded.  Type DZ to run it."
  133. )

andrew_nao

  • Guest
Re: Drawing cylindrical break line ?
« Reply #3 on: April 23, 2014, 01:33:08 PM »
try this

Code: [Select]
(defun c:pb ()
(setvar"ORTHOMODE"(BOOLE(getvar"ORTHOMODE")1))
(setq peacc (getvar "peditaccept"))
(setvar "peditaccept" 0)
(SETVAR "OSMODE" 512)
(setq pt1 (getpoint "\nFirst Point: "))
(SETVAR "OSMODE" 128)
(setq pt2 (getpoint pt1 "\nSecond Point: "))
(SETVAR "OSMODE" 0)
(setq d1 (distance pt1 pt2))
(setq a1 (angle pt1 pt2))
(setq d2 (/ d1 9.0))
(setq pt3 (polar pt1 a1 (/ d1 4)))
(setq pt4 (polar pt3 (+ a1 (/ pi 2)) d2))
(setq pt5 (polar pt1 a1 (/ d1 2)))
(setq pt6 (polar pt5 a1 (/ d1 4)))
(setq pt7 (polar pt6 (- a1 (/ pi 2)) d2))
(setq pt8 (polar pt6 (+ a1 (/ pi 2)) d2))
(command "arc" pt1 pt4 pt5)
(setq e1 (entlast))
(command "arc" pt5 pt7 pt2)
(setq e2 (entlast))
(command "arc" pt2 pt8 pt5)
(setq e3 (entlast))
(command "pedit" e1 "y" "j" e2 e3 "" "")
(setvar "peditaccept" peacc)
(setvar"ORTHOMODE"(BOOLE(getvar"ORTHOMODE")0))
(princ)
)

liuhaixin88

  • Guest
Re: Drawing cylindrical break line ?
« Reply #4 on: April 23, 2014, 08:42:55 PM »
Thanks for your reply, andrew, but your code only draw a break line , my OP neet draw two break line and break .

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Drawing cylindrical break line ?
« Reply #5 on: April 24, 2014, 06:42:47 AM »
Try this .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ pick p1 s1 p2 s2 p3 s3 p4 s4)
  2.   ;;    Tharwat 24. Apr. 2014           ;;
  3.   (defun pick (p / s)
  4.     (if (not (setq s (ssget p '((0 . "LINE,LWPOLYLINE")))))
  5.       (progn (princ "\n Should pick a point on Line or Polyline !") nil)
  6.       t
  7.     )
  8.     s
  9.   )
  10.   (if (and (setq p1 (getpoint "\n Specify first point on [Line,Polyline] :"))
  11.            (setq s1 (pick p1))
  12.            (setq p2 (getpoint "\n Specify opposite point :" p1))
  13.            (setq s2 (pick p2))
  14.            (setq p3 (getpoint "\n Specify parallel point to first point :"))
  15.            (if (and (setq p4 (polar p3 (angle p2 p1) (distance p2 p1)))
  16.                     (setq s4 (pick p4))
  17.                     (equal (cdr (assoc -1 (entget (ssname s1 0)))) (cdr (assoc -1 (entget (ssname s4 0)))))
  18.                )
  19.              t
  20.              (progn (princ "\n No line found in Point number Four !") nil)
  21.            )
  22.            (if (and (setq s3 (pick p3))
  23.                     (equal (cdr (assoc -1 (entget (ssname s2 0)))) (cdr (assoc -1 (entget (ssname s3 0)))))
  24.                )
  25.              t
  26.              (progn (princ "\n Second and third point must be picked on the same Line or Polyline !") nil)
  27.            )
  28.       )
  29.     (progn (defun Breakline (p1 p2 / a d f g h j k i p3)
  30.              (setq d (distance p1 p2)
  31.                    a (angle p1 p2)
  32.                    f (polar p1 (+ pi a) (* 0.5 d))
  33.                    g (polar p1 a (- (* 0.5 d) (* 0.25 d)))
  34.                    h (polar g (- a (* pi 0.5)) (* 0.25 d))
  35.                    k (polar p2 a (* 0.5 d))
  36.                    j (polar p2 (+ pi a) (* 0.25 d))
  37.                    i (polar j (- a (* 1.5 pi)) (* 0.25 d))
  38.              )
  39.              (entmake (list '(0 . "LWPOLYLINE")
  40.                             '(100 . "AcDbEntity")
  41.                             '(100 . "AcDbPolyline")
  42.                             '(90 . 4)
  43.                             '(70 . 0)
  44.                             '(43 . 0.0)
  45.                             (cons 10 (list (car p1) (cadr p1)))
  46.                             '(40 . 0.0)
  47.                             '(41 . 0.0)
  48.                             '(42 . -0.414214)
  49.                             (setq p3 (cons 10 (mapcar '(lambda (x y) (/ (+ x y) 2.)) p1 p2)))
  50.                             '(40 . 0.0)
  51.                             '(41 . 0.0)
  52.                             '(42 . 0.498582)
  53.                             (cons 10 (list (car p2) (cadr p2)))
  54.                             '(40 . 0.0)
  55.                             '(41 . 0.0)
  56.                             '(42 . 0.498582)
  57.                             p3
  58.                             '(40 . 0.0)
  59.                             '(41 . 0.0)
  60.                             '(42 . -0.498582)
  61.                       )
  62.              )
  63.            )
  64.            (if (and (Breakline p1 p2) (Breakline p3 p4))
  65.              (foreach x (list (list s1 p1 p4) (list s2 p2 p3))
  66.                (vl-cmdf "_.break" (car x) "_F" "_non" (cadr x) "_non" (caddr x))
  67.              )
  68.            )
  69.     )
  70.   )
  71.   (princ)
  72. )
  73.  
  74.  
« Last Edit: April 24, 2014, 07:56:48 AM by Tharwat »

liuhaixin88

  • Guest
Re: Drawing cylindrical break line ?
« Reply #6 on: April 24, 2014, 06:51:29 AM »
Try this .



Tharwat, Thank you very much! I'm very glad to meet you here, You are my god!

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Drawing cylindrical break line ?
« Reply #7 on: April 24, 2014, 06:56:19 AM »
Tharwat, Thank you very much! I'm very glad to meet you here

You're welcome , try the routine and let me know  :-)

You are my god!

Excuse me , I don't like this expression .

liuhaixin88

  • Guest
Re: Drawing cylindrical break line ?
« Reply #8 on: April 24, 2014, 07:53:14 AM »
You're welcome , try the routine and let me know  :-)

The routine is good! but have a little defects,



Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Drawing cylindrical break line ?
« Reply #9 on: April 24, 2014, 07:57:50 AM »
The routine is good! but have a little defects,

I did not account for that process , anyway I modified the code for you .

liuhaixin88

  • Guest
Re: Drawing cylindrical break line ?
« Reply #10 on: April 24, 2014, 08:09:52 AM »


I did not account for that process , anyway I modified the code for you .

Okey ! Tharwat, Thank you again!

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Drawing cylindrical break line ?
« Reply #11 on: April 24, 2014, 08:11:17 AM »


I did not account for that process , anyway I modified the code for you .

Okey ! Tharwat, Thank you again!

not a problem .  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Drawing cylindrical break line ?
« Reply #12 on: April 24, 2014, 08:39:27 AM »
I had issues. imperial. two parallel lines
Code: [Select]
Command: pipebreak

 Specify first point on [Line,Polyline] :nea
to
 Specify opposite point :
 Specify parallel point to first point :nea
to
 Should pick a point on Line or Polyline !
 No line found in Point number Four !

No time this morning to look any further.

I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

fixo

  • Guest
Re: Drawing cylindrical break line ?
« Reply #13 on: April 24, 2014, 10:00:31 AM »

The routine is good! but have a little defects,
Here is similar one from my oldies, not tested in A2014,
temporarilly out of work...

Code: [Select]
;; put break pipe symbols and break pipe within
(defun C:SYP(/ ang ang+ ang- cop osm p1 p2 pc pp sset symp)
(alert "Pick two pipe sides to be trimmed at the end")
(setq osm (getvar 'osmode))
(setvar 'osmode 512)
(setq p1 (getpoint "\nFirst Line: "))
(setq sset (ssadd))
(setq pp (ssname (ssget p1) 0))
(ssadd pp sset)
(setvar 'osmode 128)
(setq p2 (getpoint p1 "\nSecond Line: "))
(setq pc (mapcar '* (mapcar '+ p1 p2) (list 0.5 0.5 0.5)))
(setq ang  (angle p1 p2)
      ang- (- ang (/ pi 4))
      ang+ (+ (+ ang pi) (/ pi 4))
      ang- (vl-princ-to-string (/ (* ang- 180) pi))
      ang+ (vl-princ-to-string (/ (* ang+ 180) pi))
)


(command "_PLINE" "_non" p1 "A" "D" ang-
"_non" pc "_non" p2 "D" ang+ "_non"
pc ""
)
(setq symp (entlast))
(ssadd symp sset)
(command "_copy" symp "" "_non" pc "_non" pc)
(command "_rotate" (entlast) "" "_non" pc "180")
(setvar 'osmode 512)
(command "_move"
(entlast)
""
"_non"
p1
"_non"
(getpoint p1 "\nNew Location: ")
)
(setq cop (entlast))
(ssadd cop sset)

(command "_trim" sset "" pause pause "")
(setvar 'osmode osm)
(princ)
  )

ChrisCarlson

  • Guest
Re: Drawing cylindrical break line ?
« Reply #14 on: April 24, 2014, 10:05:45 AM »