Author Topic: Entmake a Wipeout in rotated WCS ?  (Read 10656 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #15 on: February 07, 2013, 12:06:31 PM »
Thought I would share the lisp. Both versions.
This is the Wipeout version.
Code - Auto/Visual Lisp: [Select]
  1. ;;  This is a specialised Railing Routine
  2. ;;  CAB - Jan. 3,2010 to present
  3. ;;  This version uses Wipeouts
  4. ;;  Creates an elevation view of  2X Pressure Treated Lumber Hand Rail System
  5. ;;  Pickets do not touch the deck below
  6. ;;  Rails are made of 2x4 lumber
  7. ;;  Rail Cap is made of 2x6 lumber
  8. ;;  Pickets are made of 2x2 lumber
  9. ;;  Note: actual lumber sizes are -.5"
  10. (defun c:Railing(/ a ang b c clr count deflayer dis gap ht m p1 p2 pll rail1 rail2 spc
  11.                  step tmp whole wid y1 y2 y3 y4 y5)
  12.  
  13.  
  14.   (defun MkWipeout (lst lay / c m p)
  15.     (setq lst (cons (last lst) lst)
  16.           p (apply 'mapcar (cons 'min lst))
  17.           m (apply 'max (mapcar '- (apply 'mapcar (cons 'max lst)) p))
  18.           c (mapcar '+ p (list (/ m 2.0) (/ m 2.0)))
  19.     )
  20.     (entmakex
  21.       (append
  22.         (list
  23.           '(000 . "WIPEOUT")
  24.           '(100 . "AcDbEntity")
  25.           '(100 . "AcDbWipeout")
  26.           (cons 8 lay)
  27.           (cons 10 (trans p 1 0))
  28.           (cons 11 (trans (list m 0.0) 1 0))
  29.           (cons 12 (trans (list 0.0 m) 1 0))
  30.           '(280 . 1)
  31.           '(071 . 2)
  32.         )
  33.         (mapcar
  34.           (function
  35.             (lambda (x)
  36.               (cons 14 (mapcar '(lambda (a b c) (/ (- a b) c)) x c (list m (- m)))))) lst)))
  37.    )
  38.  
  39.   (defun up (p a d)
  40.     (polar p (+ a (/ pi 2.)) d)
  41.   )
  42.  
  43.  
  44.   ;;  width of pattern 7.5 center of one ballaster to the center of next
  45.   ;;  width of ballaster is 1.5
  46.   ;;  Radius of circle is 3.0
  47.   (setq defLayer "zDtl Light 5"  ; picket layer
  48.         rail1    "zDtl Medium 5"
  49.         rail2    "zDtl Medium 4"
  50.         wid  1.5   ; picket width
  51.         ht   37.0  ; picket height
  52.         spc  3.5   ; space between pickets (max < 4.0")
  53.         clr  1.625 ; picket clearance from deck
  54.         y1   3.5   ; height of rail lines
  55.         y2   7.0   ; y1-y2 are botton rail
  56.         y3   37.0  ; y3-y4 are top rail
  57.         y4   40.5  ; y4-y5 are rail cap
  58.         y5   42.0
  59.   )
  60.   (if (and
  61.          (setq p1 (getpoint "\nPick lower left."))
  62.          (setq p2 (getpoint "\nPick lower right."))
  63.       )
  64.     (progn
  65.       (command "._undo" "_begin")
  66.       (if (< (car p2)(car p1)) (setq tmp p1 p1 p2 p2 tmp)) ; make left to right
  67.      
  68.       (setq step  (+ wid spc)
  69.             count (/ (distance p1 p2) step)
  70.             whole (1- (fix count))
  71.             dis   (+ wid (* (+ wid spc) whole))
  72.             gap   (/ (- (distance p1 p2) dis) 2.)
  73.             ang   (angle p1 p2)
  74.             pll   (polar (polar p1 ang gap) (+ ang (/ pi 2)) clr)  ; LowerLeft of 1st picket
  75.       )
  76.       ;;  draw rails from bottom up, numbers are the relative Y position
  77.       (MkWipeout (list(up p1 ang y4)(up p2 ang y4)(up p2 ang y3)(up p1 ang y3)) defLayer)
  78.       (MkWipeout (list(up p1 ang y5)(up p2 ang y5)(up p2 ang y4)(up p1 ang y4)) rail1) ; top of railing
  79.       (MkWipeout (list(up p1 ang y1)(up p2 ang y1)(up p2 ang y2)(up p1 ang y2)) rail2) ; bottom
  80.      
  81.       ;; Draw pickets
  82.       (repeat (1+ whole)
  83.         (MkWipeout (list
  84.                        pll                                            
  85.                       (polar pll (+ ang (/ pi 2)) ht)                
  86.                       (polar (polar pll (+ ang (/ pi 2)) ht) ang wid)
  87.                       (polar pll ang wid)                            
  88.                     ) defLayer)
  89.         (setq pll (polar pll ang step))
  90.        )
  91.  
  92.       (command "._undo" "_end")
  93.     )
  94.   )
  95.   (princ)
  96. )
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #16 on: February 07, 2013, 12:10:03 PM »
This is the Hatch version.
Note that it uses a routine by Lee to correct the draw order of the pline border
The routine can be found here: http://lee-mac.com/draworderfunctions.html
Code - Auto/Visual Lisp: [Select]
  1. ;;  This is a specialised Railing Routine
  2. ;;  CAB - Jan. 3,2010 to present
  3. ;;  This version uses Plines & Hatches, previous version used Wipeouts
  4. ;;  Creates an elevation view of 2X Pressure Treated Lumber Hand Rail System
  5. ;;  Pickets do not touch the deck below
  6. ;;  Rails are made of 2x4 lumber
  7. ;;  Rail Cap is made of 2x6 lumber
  8. ;;  Pickets are made of 2x2 lumber
  9. ;;  Note: actual lumber sizes are -.5"
  10. (defun c:Railing(/ ang clr count deflayer dis gap ht lst norm obj p1 p2 pll spc step tmp
  11.                  whole wid y1 y2 y3 y4 y5 rail1 rail2 hLayer)
  12.  
  13.   (defun mkhatch (spc obj lst lay / hatch spc)
  14.         (vl-catch-all-apply
  15.           '(lambda (/)
  16.              (setq hatch (vla-AddHatch spc acHatchPatternTypePredefined "SOLID" :vlax-true))
  17.              (vlax-invoke hatch 'AppendOuterLoop (list obj))
  18.              (vla-evaluate hatch)
  19.              (vla-put-layer hatch lay)
  20.            )
  21.        )
  22.     (LM:SwapOrder (vla-get-activedocument (vlax-get-acad-object)) hatch obj)
  23.     ;;  http://lee-mac.com/draworderfunctions.html
  24.   )
  25.  
  26.  
  27.   ;;  by CAB 03/22/2009 - modified too close pline
  28.   ;;  Expects pts to be a list of 2D or 3D points
  29.   ;;  Returns new pline object
  30.   (defun makePline (spc pts lay / norm elv pline)
  31.     (setq norm  (trans '(0 0 1) 1 0 T)
  32.           elv   (caddr (trans (car pts) 1 norm))
  33.     )
  34.     (setq pline
  35.       (vlax-invoke Spc 'addLightWeightPolyline
  36.         (apply 'append
  37.           (mapcar  (function (lambda (pt)
  38.              (setq pt (trans pt 1 norm))
  39.              (list (car pt) (cadr pt))))
  40.             pts)))
  41.     )
  42.     (vla-put-Elevation pline elv)
  43.     (vla-put-Normal pline (vlax-3d-point norm))
  44.     (vla-put-Closed pline :vlax-true)
  45.     (vla-put-Layer Pline lay)
  46.     pline
  47.   )
  48.  
  49.   (defun up (p a d) (polar p (+ a (/ pi 2.)) d))
  50.  
  51.  
  52.   ;;  width of pattern 7.5 center of one picket to the center of next.
  53.   ;;  width of picket is 1.5
  54.   (setq defLayer "zDtl Light 5"  ; picket layer
  55.         rail1    "zDtl Medium 5"
  56.         rail2    "zDtl Medium 4"
  57.         hLayer   "WipeOut"
  58.         wid  1.5   ; picket width
  59.         ht   37.0  ; picket height
  60.         spc  3.5   ; space between pickets (max < 4.0")
  61.         clr  1.625 ; picket clearance from deck
  62.         y1   3.5   ; height of rail lines
  63.         y2   7.0   ; y1-y2 are botton rail
  64.         y3   37.0  ; y3-y4 are top rail
  65.         y4   40.5  ; y4-y5 are rail cap
  66.         y5   42.0
  67.   )
  68.   (if (and
  69.          (setq p1 (getpoint "\nPick lower left."))
  70.          (setq p2 (getpoint "\nPick lower right."))
  71.       )
  72.     (progn
  73.       (command "._undo" "_begin")
  74.       (if (< (car p2)(car p1)) (setq tmp p1 p1 p2 p2 tmp)) ; make p1-p2 left to right
  75.      
  76.       (setq step  (+ wid spc)
  77.             count (/ (distance p1 p2) step)
  78.             whole (1- (fix count))
  79.             dis   (+ wid (* (+ wid spc) whole))
  80.             gap   (/ (- (distance p1 p2) dis) 2.)
  81.             ang   (angle p1 p2)
  82.             pll   (polar (polar p1 ang gap) (+ ang (/ pi 2)) clr)  ; LowerLeft of 1st picket
  83.       )
  84.  
  85.       (setq Spc
  86.             (if (= 1 (getvar "CVPORT"))
  87.             )
  88.       )
  89.      
  90.       (setq lst (list(up p1 ang y4)(up p2 ang y4)(up p2 ang y3)(up p1 ang y3)))
  91.       (setq obj (makePline spc lst defLayer))
  92.       (mkhatch spc obj lst hLayer)
  93.       (setq lst (list(up p1 ang y5)(up p2 ang y5)(up p2 ang y4)(up p1 ang y4)))
  94.       (setq obj (makePline spc lst rail1))
  95.       (mkhatch spc obj lst hLayer)
  96.       (setq lst (list(up p1 ang y1)(up p2 ang y1)(up p2 ang y2)(up p1 ang y2)))
  97.       (setq obj (makePline spc lst rail2))
  98.       (mkhatch spc obj lst hLayer)
  99.  
  100.       ;; Draw pickets
  101.       (repeat (1+ whole)
  102.         (setq lst (list
  103.                      pll                                            
  104.                     (polar pll (+ ang (/ pi 2)) ht)                
  105.                     (polar (polar pll (+ ang (/ pi 2)) ht) ang wid)
  106.                     (polar pll ang wid)                            
  107.                     ))
  108.         (setq obj (makePline spc lst defLayer))
  109.         (mkhatch spc obj lst hLayer)
  110.         (setq pll (polar pll ang step))
  111.       ) ; end repeat
  112.      
  113.       (command "._undo" "_end")
  114.       (command "._regen")
  115.     )
  116.   )
  117.   (princ)
  118. )
  119.  
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.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Entmake a Wipeout in rotated WCS ?
« Reply #17 on: February 07, 2013, 01:08:26 PM »
i would add that hatches must be of (255 255 255) RGB color

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #18 on: February 07, 2013, 01:32:36 PM »
Thanks, my LAYER "Wipeout" is set to color 255
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.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Entmake a Wipeout in rotated WCS ?
« Reply #19 on: February 07, 2013, 02:39:48 PM »
Thanks, my LAYER "Wipeout" is set to color 255
have you plotted it already? indexed color 255 will become RGB (250 250 250) when printed out and may turn into gray.
so i suggest using true color (255 255 255) which is 'pure' white

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #20 on: February 07, 2013, 02:59:55 PM »
You're quite right and I should have mentioned I use STB method with a style called Wipeout also.
The style color is 254 254 254 which is what controls my plotting.
Sorry for the confusion.
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.