Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Drawing a lot of joints (easy way) in a pipeline in AUTOCAD

andriuschar
Participant

Drawing a lot of joints (easy way) in a pipeline in AUTOCAD

andriuschar
Participant
Participant

I am drawing a pipeline and I need to show joints in a pipeline. Joints must be shown as a line perpendicular to pipeline. What I’m currently doing is: firstly COPY joint in the place, then displace, rotate perpendicular to line and doing this all over again. In huge drawing I’m repeating this many times and it’s very exhausting. Another way is doing ARRAYPATH, but in short branches it’s not practical. And also this does not evaluate bends and branches. Is there a smarter way to do this?

Example attached.Draw joints.png

 

0 Me gusta
Responder
Soluciones aceptadas (1)
997 Vistas
6 Respuestas
Respuestas (6)

ВeekeeCZ
Consultant
Consultant

How about to use blocks? You can make a tool on a tool palette, set "Ask for rotation..." It definitely speeds up things..

See  HERE 

RSomppi
Advisor
Advisor

One of the vertical products like AutoCAD MEP is probably very useful with things like this.

0 Me gusta

pendean
Community Legend
Community Legend

Each of your variations (I quickly counted 5 in your image) needs to be a block that you simply INSERT and ROTATE as needed, you can even set up the rotations ahead of time, do it all drag/drop from a ToolPalette

pendean_0-1634819080478.png

 

0 Me gusta

leeminardi
Mentor
Mentor

The following vlisp program will draw the Branch and Bend lines when the user specifies the vertex of the bend or branch followed by a random point on the line that should contain the branch/bend line.  Osnap End and Nearest are active while the command is running to assisit in locating the vertex and a point on the line.

 

In the example below the user uses osnap to first identify the vertex  of the junction (1) and then points on the pipe lines (2,3,...).  The pipes may be at any angle on the XY plane.

image.png

(defun c:j1 (/ osm p1 p2 a b s u12 u12perp p4 p5)
; Draws joint lines.
; The first pick point is the location of the junction vertex.
; The second and following pick points should be on the line that
; in the direction of the pipe.
; The program set osnap to End and Nearest during operation.
; LRM  10/21/2021  
;  
  (setq  osm (getvar 'osmode))
  (setvar 'osmode 513) ; set osnap end and nearest
  (setq
	 
    p1 (getpoint "\nPick line vertex: ")
	p2 (getpoint "\nPick point on line: ")
	a  0.6
	b  0.75
  )
  (while p2
    (setq s	  (distance '(0 0 0) (mapcar '- p2 p1))
	  u12	  (mapcar '/ (mapcar '- p2 p1) (list s s s))
	  p3	  (mapcar '+ p1 (mapcar '* u12 (list a a a)))
	  u12perp (list (cadr u12) (* -1.0 (car u12)) 0.0)
    )
    (setq p4 (mapcar '+ p3 (mapcar '* u12perp (list b b b)))
	  p5 (mapcar '- p3 (mapcar '* u12perp (list b b b)))
    )
    (command "_line" p4 p5 "")
    (setq p2 (getpoint "\nPoint on another line?"))
  )
  (setvar 'osmode osm)
  (princ)
)

 

lee.minardi
0 Me gusta

Tomislav.Golubovic
Advisor
Advisor

Honestly, use Plant3D for this, its what its built for

0 Me gusta

3wood
Advisor
Advisor
Solución aceptada

Please try following codes.

(Credits to Lee Mac for his wonderful intersection finding function.)
You can modify the code yourself and adding more design criteria based on different pipe sizes.

Capture9.JPG

 

AUTOPIPE2.gif

;;; AUTOPIPE.LSP by 3wood, 2021.10.23
;;; Add joint symbols to selected pipelines. Joint design is parameterized and matching different pipe types according to their layer name.

;; Get all vertex of a polyline
(defun AUTOPIPE_PPoints (VLAOBJ / org-L n1 temp-L result)
   (setq org-L (vlax-safearray->list(vlax-variant-value (vla-get-coordinates VLAOBJ)))) 
   (setq n1 0 result (list))
   (repeat (/ (length org-L) 2)
     (setq temp-L (list (nth n1 org-L) (nth (1+ n1) org-L)))
     (setq result (append result (list temp-L)))
     (setq n1 (+ n1 2))
     )
  result
  ) 

;;; Draw Joint Line
(defun AUTOPIPE_DrawJoint (POINT ANGL OFFSET RINGDIA RINGLAYER / pt0 pt1 pt2)
  (setq pt0 (polar POINT ANGL OFFSET)
	pt1 (polar pt0 (+ ANGL (/ pi 2.0)) RINGDIA)
        pt2 (polar pt0 (- ANGL (/ pi 2.0)) RINGDIA)
  )

  (entmake (list (cons 0 "LINE") (cons 10 pt1)(cons 11 pt2) (cons 8 RINGLAYER)))
  )

;; Intersections  -  Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;;     mod - [int] acextendoption enum of intersectwith method
(defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
)

;; Intersections in Set  -  Lee Mac
;; Returns a list of all points of intersection between all objects in a supplied selection set.
;; sel - [sel] Selection Set
(defun LM:intersectionsinset ( sel / id1 id2 ob1 ob2 rtn )
    (repeat (setq id1 (sslength sel))
        (setq ob1 (vlax-ename->vla-object (ssname sel (setq id1 (1- id1)))))
        (repeat (setq id2 id1)
            (setq ob2 (vlax-ename->vla-object (ssname sel (setq id2 (1- id2))))
                  rtn (cons (LM:intersections ob1 ob2 acextendnone) rtn)
            )
        )
    )
    (apply 'append (reverse rtn))
)

(defun C:AUTOPIPE (/ BANDDIST d1 Dc1 Dc2 design dst4 E1 g1 g2 g3 g4 JOINTDIA JOINTSCL JOINTLAY L1 L2 L3 LIBRARY LF1 m0 M1 n1 n2 n3 n4 n5 n6 n7 P1 PIPELENG pt3 S1 S2)
  ;Use pipe layer to match its symbol sizes in the order of PIPELENG, JOINTDIA, BANDDIST, JOINTSCL, JOINTLAY...
  (setq LIBRARY
	 (list
	   (cons "T1T2" (list (list 12.0 0.75 1.0 0.6 "MOVOS")))
	   (cons "T1T2 50_125" (list (list 5.0 0.5 0.6 0.6 "MOVOS"))) ;Change the design to suit
								       ;<-- Add other pipeline design information here
	   )
	)
  
  (setq n1 0)
  (if (setq S1 (ssget '((0 . "LWPOLYLINE"))))
    (repeat (sslength s1)
      (setq P1 (vlax-ename->vla-object (setq E1 (ssname S1 n1))))
      (if (not (setq design (cadr (assoc (cdr (assoc 8 (entget E1))) LIBRARY))))
	(setq design (cadar LIBRARY)) ;Use the first record in the library as the symbol design
	)
      (setq
	PIPELENG (nth 0 design)
	JOINTDIA (nth 1 design)
	BANDDIST (nth 2 design)
	JOINTSCL (nth 3 design)
	JOINTLAY (nth 4 design)
	)
      (setq
	L1 (AUTOPIPE_PPoints P1)
	LF1 (append (AUTOPIPE_PPoints (car (vlax-safearray->list (vlax-variant-value (vla-offset P1 (/ BANDDIST 10.0))))))
		    (reverse (AUTOPIPE_PPoints (car (vlax-safearray->list (vlax-variant-value (vla-offset P1 (/ BANDDIST -10.0))))))))
	S2 (ssget "f" LF1 '((0 . "LWPOLYLINE")))
	L2 (mapcar '(lambda (y1) (list (car y1) (cadr y1))) (LM:intersectionsinset (ssadd E1 S2))) ;List of 'T' junctions
	)
      
      (repeat 2 (entdel (entlast)))
      
      ;Add joints at 'T' junctions
      (foreach n2 L2
	(setq d1 (vlax-curve-getDistAtPoint P1 n2)
	      g1 (angle '(0.0 0.0 0.0)(vlax-curve-getFirstDeriv P1 (vlax-curve-getParamAtPoint P1 n2)))  ;Get angle
	      )
	(cond ;Add joints at 'T' junction
	  ((equal d1 0.0 1e-10)
	   (AUTOPIPE_DrawJoint n2 g1 (* BANDDIST JOINTSCL) JOINTDIA JOINTLAY)) ;Intersection at startpoint
	  ((equal d1 (vlax-curve-getDistAtPoint P1 (vlax-curve-getEndPoint P1)) 1e-10)
	   (AUTOPIPE_DrawJoint n2 (+ g1 pi) (* BANDDIST JOINTSCL) JOINTDIA JOINTLAY)) ;Intersection at endpoint
	  (T
	   (AUTOPIPE_DrawJoint n2 g1 (* BANDDIST JOINTSCL) JOINTDIA JOINTLAY)
	   (AUTOPIPE_DrawJoint n2 (+ g1 pi) (* BANDDIST JOINTSCL) JOINTDIA JOINTLAY)) ;Intersection in the middle of the polyline
	  )
	)
      
      ;Add joints at bands
      (if (setq L3 (cdr (reverse (cdr L1))))
	(foreach n3 L3
	  (setq M1 nil
		g2 (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv P1 (vlax-curve-getParamAtPoint P1 n3)))
		g3 (+ pi (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv P1 (1- (vlax-curve-getParamAtPoint P1 n3)))))
		)
	  (foreach n4 L2 ;Check if the Vertex is too close to any intersection point
	    (if (<= (abs (- (vlax-curve-getDistAtPoint P1 n3)(vlax-curve-getDistAtPoint P1 n4)))
		    (* BANDDIST 2.0))
	      (setq M1 T)
	      )
	    )
	  (if (not M1)
	    (progn
	      (AUTOPIPE_DrawJoint n3 g2 BANDDIST JOINTDIA JOINTLAY)
	      (AUTOPIPE_DrawJoint n3 g3 BANDDIST JOINTDIA JOINTLAY)
	      )
	    )
	  )
	)
      
      ;Add joints to break up long pipes
      (setq L3 L1)
      (foreach n5 L2
	(if (not (member n5 L3))
	  (setq L3 (append L3 (list n5)))
	  )
	) ;Add 'T' sections to polyline vertex list
      (setq L3 (vl-sort L3 '(lambda (x1 x2) (< (vlax-curve-getDistAtPoint P1 x1) (vlax-curve-getDistAtPoint P1 x2)))))
      (setq n6 0)
      (repeat (setq m0 (1- (length L3))) ;Ignore the Endpoint
	(if (> (setq d2 (abs (- (setq Dc2 (vlax-curve-getDistAtPoint P1 (nth (1+ n6) L3)))
				(setq Dc1 (vlax-curve-getDistAtPoint P1 (nth n6 L3)))
				(setq dst4
				       (if (member (nth n6 L3) L2) ;Current segment startpoint
					 (* BANDDIST JOINTSCL) ;Is 'T'
					 (if (= n6 0) 0.0 BANDDIST)
					 ))
				(if (member (nth (1+ n6) L3) L2) ;Current segment endpoint
				  (* BANDDIST JOINTSCL) ;Is 'T'
				  (if (= n6 (1- m0)) 0.0 BANDDIST)
				  )
				
				))) PIPELENG) ;pipe segment longer than maximum length
	  (progn
	    (setq n7 0)
	    (repeat (fix (/ d2 PIPELENG))
	      (setq pt3 (vlax-curve-getPointAtDist P1
			  (if (< n6 (1- m0))
			    (+ Dc1 dst4 (rem d2 PIPELENG) (* n7 PIPELENG))
			    (+ Dc1 dst4 (* (1+ n7) PIPELENG))
			    )
			  )
		    g4 (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv P1 (vlax-curve-getParamAtPoint P1 pt3)))
		    )
	      (entmake (list (cons 0 "LINE") (cons 8 JOINTLAY)
			     (cons 10 (polar pt3 (+ g4 (/ pi 2.0)) JOINTDIA))
			     (cons 11 (polar pt3 (- g4 (/ pi 2.0)) JOINTDIA))))
	      (setq n7 (1+ n7))
	      )
	    )
	  )
	(setq n6 (1+ n6))
	)
      
      (setq n1 (1+ n1))
      )
    )
  (princ)
  )