TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: David Bethel on March 16, 2006, 12:35:15 PM
-
Ghost images
I have a program that takes 2D extruded solids (fig 1 & 2 ) and converts them to
true wire frame outlines. ( 1 solid with thickness = 12 lines )
The lines are all WCS, 3d points on a unique layer ( fig 3)
The end result that I am after is to create a ghosted image of the outline of the boxes
so that the psychical space of each box is shown but not any of the details about the box. ( fig 4)
A simple line entity does not render at all.
Giving a 3D line thickness can give unwanted results
Even then there isn't enough surface area to render well
Where I am getting stuck is converting each line into an extruded 2d solid or trace
thickness = the distance from point 10 to point 11 of the line
solid shape = 4 sided square
each side 0.1 long
rotated around point 10 in the plane perpendicular to point 11
( I did this manually to be able to create fig 4 )
[ Circles are harder to render well due the infinite number of reflections that they give off ]
fig 1
(http://www.davidbethel.com/cadtutor/box0.gif)
fig 2
(http://www.davidbethel.com/cadtutor/box1.gif)
fig 3
(http://www.davidbethel.com/cadtutor/box2.gif)
fig 4
(http://www.davidbethel.com/cadtutor/ar-box01.jpg)
I've thought of a bunch of scenarios, but none are working out well at all.
Any suggestions would be appreciated
(setq ss (ssget "X" '((0 . "LINE")(8 . "0D"))))
(setq i (sslength ss))
(while (not (minusp (setq i (1- i))))
(setq en (ssname ss i)
ed (entget en)
p10 (cdr (assoc 10 ed))
p11 (cdr (assoc 11 ed)))
;;;Convert the thing to a solid........
)
Thanks to anyone in advance. -David
-
I don't think I understand what you want, sorry. Are you trying to give each line some thickness? If so can you conver each line to a solid from end point to end point?
-
Basically to extrude a line using a square solid. Only in R14 or earlier. -David
-
I think this fits the bill. I guess the "Thk" argument, could be Square Size, but Thk just came to me.
(defun DrawSolidRec (Pt1 Pt2 Thk / Ang Dist p1 p2 p3 p4 osnp)
;-------------------------------------------------------
(defun GetTrueAngle (RadAng)
; Get a usable angle in radians.
(cond
((<= 0.0 RadAng 6.28319)
RadAng
)
((< RadAng 0.0)
(+ 6.28319 RadAng)
)
((> RadAng 6.28319)
(rem RadAng 6.28319)
)
)
)
;-------------------------------------------------------
(defun DTR (a) ;Degrees to radians conversion
(* pi (/ a 180.0)))
;------------------------------------------------------
(setq Ang (angle Pt1 Pt2))
(setq Dist (sqrt (+ (* Thk Thk) (* Thk Thk))))
(setq p1 (polar Pt1 (GetTrueAngle (+ (DTR 45) Ang)) (/ Dist 2.0)))
(setq p2 (polar Pt1 (GetTrueAngle (+ (DTR 135) Ang)) (/ Dist 2.0)))
(setq p3 (polar Pt1 (GetTrueAngle (+ (DTR 225) Ang)) (/ Dist 2.0)))
(setq p4 (polar Pt1 (GetTrueAngle (+ (DTR 315) Ang)) (/ Dist 2.0)))
(setq osnp (getvar "osmode"))
(setvar "osmode" 0)
(command "_.pline" p1 p2 p3 p4 "_c")
(command "_.rotate3d" (entlast) "" Pt1 (polar Pt1 (GetTrueAngle (+ (DTR 90) Ang)) 0.05) 90.0)
(command "_.extrude" (entlast) "" (distance Pt1 Pt2) "")
(setvar "osmode" osnp)
(princ)
)
-
Tim, I'd be looking for the maximum accuracy possible here .. perhaps something like ;
(defun GetTrueAngle (RadAng / twoPI)
;; Convert an angle in radians
;; to be in the range 0 >< 2*PI
;;
(setq twoPI (* 2 pi))
(cond ((<= 0.0 RadAng twoPI) RadAng)
((< RadAng 0.0) (+ twoPI RadAng))
((> RadAng twoPI) (rem RadAng twoPI))
)
)
-
Thanks Kerry. My math skills have suffered from not being stimulated enough. I will use this one now.
-
Tim,
That looks like it could work, only we don't use solids, so the EXTRUDE command is out of the question.
Mine so far:
(defun pt2ocs (pt)
(mapcar '(lambda (c) (* c (/ 1. (distance '(0 0 0) pt)))) pt))
(and
(setq ss (ssget "X" '((0 . "LINE")(8 . "0D"))))
(setq i (sslength ss))
(while (not (minusp (setq i (1- i))))
(setq en (ssname ss i)
ed (entget en)
p10 (cdr (assoc 10 ed))
p11 (cdr (assoc 11 ed))
dis (distance p10 p11))
(and (> dis 0)
(setq dir (mapcar '- p11 p10)
ocs (pt2ocs dir))
(entmake (list (cons 0 "TRACE")
(cons 8 "3D-GHOST")
(cons 39 dis)
(cons 10 (polar (trans p10 0 ocs) (* pi 0.0) 0.05))
(cons 11 (polar (trans p10 0 ocs) (* pi 0.5) 0.05))
(cons 12 (polar (trans p10 0 ocs) (* pi 1.5) 0.05))
(cons 13 (polar (trans p10 0 ocs) (* pi 1.0) 0.05))
(cons 210 ocs)))))
The two pieces of equipment on the outboard side of the charbroiler
(http://www.davidbethel.com/cadtutor/ar-gcook.jpg)
-David
-
Shoot, no extrude! well I was running this little test routine which seems to work
but that blew it out of the water. :-(
Looking at your code I'd say you've got quite a handle on the problem.
You're a very talented programmer David.
I especially like the way you used the thickness as the distance & the corners for the shape.
I'm sure I would have tried it the other way.
(defun c:test ()
(setq w 2.0 ; width of extrusion
ent (car (entsel)) ; select the line
)
(setq p1 (cdr (assoc 10 (entget ent)))
p2 (cdr (assoc 11 (entget ent)))
)
(setvar "osmode" 0)
(command "_.rectangle" "0,0" (list w w))
(setq rec (entlast))
(command "_.align" rec ""
(list (/ w 2) (/ w 2) 0.0) p1
(list (/ w 2) (/ w 2) 10.0) p2
"" "N")
(command "_.extrude" rec "" "P" ent)
(princ)
)
-
Not being a user of extrude, I know little of it's capabilities. I have seen a lot of questions when a 3DPOLY line is chosen as the path. I would have thought a 3Dline would have been a problem as well. Thanks -David