Author Topic: Ghosting  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
Ghosting
« 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


fig 2


fig 3


fig 4


I've thought of a bunch of scenarios, but none are working out well at all.
Any suggestions would be appreciated

Code: [Select]
  (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
R12 Dos - A2K

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Ghosting
« Reply #1 on: March 16, 2006, 12:51:18 PM »
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?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ghosting
« Reply #2 on: March 16, 2006, 01:03:03 PM »
Basically to extrude a line using a square solid.  Only in R14 or earlier.  -David
R12 Dos - A2K

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Ghosting
« Reply #3 on: March 16, 2006, 02:19:56 PM »
I think this fits the bill.  I guess the "Thk" argument, could be Square Size, but Thk just came to me.
Code: [Select]
(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 don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Ghosting
« Reply #4 on: March 16, 2006, 02:32:30 PM »
Tim, I'd be looking for the maximum accuracy possible here .. perhaps something like ;
Code: [Select]
(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))
  )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Ghosting
« Reply #5 on: March 16, 2006, 02:38:46 PM »
Thanks Kerry.  My math skills have suffered from not being stimulated enough.  I will use this one now.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ghosting
« Reply #6 on: March 16, 2006, 04:21:11 PM »
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:

Code: [Select]
 
(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


-David
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Ghosting
« Reply #7 on: March 16, 2006, 10:24:55 PM »
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.

Code: [Select]
(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)
)
« Last Edit: March 16, 2006, 10:36:15 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ghosting
« Reply #8 on: March 17, 2006, 08:17:35 AM »
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
R12 Dos - A2K