Anuncios

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

leeminardi
en respuesta a: andriuschar

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