Thread Content
When drawing piping diagrams, top views and corresponding 45° angled views are often used. In fact, the information contained in the 45° view simply includes the horizontal height of each pipeline in addition to what is shown in the top-down view. The program written in LISP below can automatically convert a top-view into a 45° angled view at the same horizontal level; the user only needs to move each set of pipes vertically by the appropriate amount on the transformed diagram, and a 45° angled view is thus easily created. () Since each pipeline is represented by a straight line, it is sufficient to change the starting and ending coordinates of the line to those corresponding to the 45° angled view. In the program, the variable p0 records the coordinate origin of the 45° angle view, which is entered by the user. p1 records the starting coordinate of the line, while p2 records the ending coordinate of the line. (defun c:V45( / cmdmode sset ssl ent p0,p1,p2,x1,x2,y0,y1,y2,z1,z2) (setq cmdmode (getvar "cmdecho")) (setvar "cmdecho" 0) ;Ask the user to select lines (prompt "\nSelect lines:") (setq sset (ssget)) (if (not(null sset)) (progn (setq ssl (sslength sset)) ;Have the user enter the starting point (setq p0 (getpoint "\nThe base point: ")) (setq y0 (cadr p0)) (while (> ssl 0) (setq ent(entget (ssname sset (setq ssl (1- ssl))))) ;Filter the lines (if (= (cdr (assoc 0 ent)) "LINE") ;Change the start and end points of that line (progn (setq x1 (cadr(assoc 10 ent))) (setq y1 (caddr(assoc 10 ent))) (setq z1 (cadddr(assoc 10 ent))) (setq x2 (cadr(assoc 11 ent))) (setq y2 (caddr(assoc 11 ent))) (setq z2 (cadddr(assoc 11 ent))) (setq p1 (list (+ x1 (/ (* (sqrt 2) (- y1 y0)) 4)) (+ y0 (/ (* (sqrt 2) (- y1 y0))4)) z1)) (setq p2 (list (+ x2 (/ (* (sqrt 2) (- y2 y0)) 4)) (+ y0 (/ (* (sqrt 2) (- y2 y0))4)) z2)) (setq ent (entmod (subst (cons 10 p1) (assoc 10 ent) ent))) (entmod (subst (cons 11 p2) (assoc 11 ent) ent)) (redraw (cdr(assoc -1 ent)) 1)) ) ) ) ) (setvar "CMDECHO" cmdmode) ) (princ "\n\tc:V45 loaded. Start command with V45.")