Tutorial: Page (1) of 1 - 10/04/01 Email this story to a friend. email article Print this page (Article printing at MyDmn.com).print page facebook

Vertical Offset - part 2

Selecting pipes in vertical offset, finding points of the triangle and more By Jos van Doorn
Here's a description of what the program does:

1. a pipe in vertical offset is selected
2. the points of the triangle are found
3. a temporarily triangle is drawn
4. asked is whether the triangle is OK
5. if the triangle is not OK then the outer point of the triangle is changed
6. the permanent triangle is drawn


The points of the triangle are the two endpoints of the line in vertical offset and an outer point. The outer point is found using the INTERS function.

Two artificial points are calculated using the two endpoints. The first point is above the upper point and the second point under an angle of thirty degrees.

The point under an angle of 90 degrees is calculated from the upper point. The other point is calculated from the lower point.

So before the outer point of the triangle can be calculated the position of the two endpoints must be determined.

Determined must be what's the upper point and what's the lower point. If that's known the outer point can be calculated.

The find the position of the endpoints the Y value of each point is checked. The upper point has the highest Y value.

If necessary the two endpoints are switched.

2.1 So the second point is extended. Find the highest point. Calculate the outer point using the upper point and the lower point.

The INTYERS function is used to calculate the outer point. The function has the option to extend lines going through points. That option is used.

For drawing the temporarily triangle a function is used. The three points of the triangle are the arguments of the function.

The function has another argument. It's an type argument. The type of the triangle to be drawn is permanent or temporarily.

If a temporarily triangle is drawn the GRDRAW function is used. If a permanent triangle is drawn then the LINE function is used.

These are the steps of the function:

1. drawing the triangle on base of the three points

2. drawing a hatch. The hatch is drawn with separate lines. The points of the hatch The points of the hatch are calculated with the INTEWRS function

The same function is used for drawing the permanent triangle.

Here's the listing of the program. All that has been described above can be found in the program. Go ahead. Load the program in AutoCAD. (For a txt file with indentations, click here.)

(defun vhtdr (p1 p2 xp tp)
(if (= tp "perm")
(command "line" p1 xp p2 "")
(progn
(grdraw p1 xp 1)
(grdraw p2 xp 1)
)
)
(setq d1 (distance p1 xp)
d2 (distance p2 xp)
ds d2
p3 p2
an (angle xp p1)
)
(while (> ds 10)
(setq p3 (polar p3 (angle p2 xp) 10)
p4 (inters p1 p2 p3 (polar p3 an 1) nil)
)
(if (= tp "perm")
(command "line" p3 p4 "")
(grdraw p3 p4 1)
)
(setq ds (- ds 10))
)
)

(defun c:verof ()
(setvar "cmdecho" 0)
(setq et (car (entsel " Select pipe: "))
el (entget et)
p1 (cdr (assoc 10 el))
p2 (cdr (assoc 11 el))
)
(if (< (cadr p1) (cadr p2))
(setq hp p1
p1 p2
p2 hp
)
)
(setq xp (inters p1
(polar p1 (/ pi 2) 1)
p2
(polar p2 (/ pi 6) 1)
nil
)
)
(vhtdr p1 p2 xp "no_perm")
(initget "Yes No")
(setq aw (getkword "Hatch OK? (Yes/No): "))
(if (null aw)
(setq aw "Yes")
)
(redraw)
(if (= aw "Yes")
(vhtdr p1 p2 xp "perm")
(progn
(setq xp (inters p1
(polar p1 (/ pi 2) 1)
p2
(polar p2 (* (/ pi 6) 5) 1)
nil
)
)
(vhtdr p1 p2 xp "perm")
)
)
(setvar "cmdecho" 1)
(princ)
)

One final remark. If you start using the program then make a drawing with a vertical line in offset. Make sure the drawing is isometric.

****************************************************
Jos van Doorn.is an AutoCAD specialist, AutoLISP programmer and editor of the ACAD newsletter. To subscribe to the FREE newsletter send e-mail to: mailto:acadnewsletter-subscribe@topica.com

He has written six AutoCAD books. Interested in the books. Let him know. Send an e-mail to: mailto:josvandoorn@consultant.com

Page: 1


Related Keywords:CAD, vertical offset

HOT THREADS on DMN Forums
Content-type: text/html  Rss  Add to Google Reader or
Homepage    Add to My AOL  Add to Excite MIX  Subscribe in
NewsGator Online 
Real-Time - what users are saying - Right Now!

Our Privacy Policy --- @ Copyright, 2015 Digital Media Online, All Rights Reserved