Author Topic: Perforated ARC  (Read 6511 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
Perforated ARC
« on: December 13, 2013, 10:08:44 AM »
Greetings,

I'm having trouble trying to automate this process.

The perforated holes in the upper most ARC panel are being a pain.

Currently I cheat, using a BLOCK ( VL-CANOP ) inserted WCS a bit ( 0.2 ) above the ARC, then manually ROTATE and then ARRAY ( Polar ) the INSERT from a front view.  Very time consuming with a lot of fudging.  VL-CANOP is a flat WCS fixed size that represents a 5 hole pattern.

The ARC has some strange parameters as the chord height is consistent ( 4" ) but the chord length is variable as to the overall width of the base.  This way the overall heights and geometry of the units look to be symetrical.  It is always centered on the base unit width.


I have the ARC data ( CEnter, RAdius, StartAngle, EndAngle, Thickness (18) & OCS ).  It is almost as if a DIVIDE or MEASURE command would work only it need to work with at least (2) OCS directions.  I offset the ARC by 0.2 to represent material thickness

Any suggestions would be most appreciated.

Trying to model these monstrosities as a single entity would be ridiculous.

Thanks!  -David

( as you can see I do not have an aversion to shortcuts so long as the final model does a decent representation to a real world solution )

R12 Dos - A2K

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Perforated ARC
« Reply #1 on: December 13, 2013, 12:06:46 PM »
I don't know but to me it's prettier when flat top - no arcs at all...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Perforated ARC
« Reply #2 on: December 13, 2013, 12:24:27 PM »
I wish that were the case.  The manufacture doesn't have that as an option.   :cry:
R12 Dos - A2K

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Perforated ARC
« Reply #3 on: December 16, 2013, 02:21:05 PM »
I think this can be reduced to a (curved) linear problem. This may even conform to how the perforated arc is fabricated.
I would start with a function to distribute the pattern along the length of the arc (see PatternDataGet below), and then use the curve functions to project the pattern on the arc. Marking out the pattern with point entities may already be enough.

Code - Auto/Visual Lisp: [Select]
  1. (defun PatternDataGet (halfArcLen / distBetween distCurrent distEnd distPattern distRest num result)
  2.   (setq distBetween 3.0)
  3.   (setq distEnd 3.0)
  4.   (setq distPattern 10.0)
  5.  
  6.   (setq num
  7.     (fix
  8.       (/
  9.         (- halfArcLen distEnd (/ distBetween -2.0))
  10.         (+ distPattern distBetween)
  11.       )
  12.     )
  13.   )
  14.   (setq distRest
  15.     (-
  16.       halfArcLen
  17.       distEnd
  18.       (* num distPattern)
  19.       (* (- num 0.5) distBetween)
  20.     )
  21.   )
  22.   (while
  23.     (and
  24.       (> distRest (+ num 0.5)) ; (- num 0.5) for distBetween and 1 for distEnd.
  25.       (< distBetween 6.0)
  26.     )
  27.     (setq distBetween (1+ distBetween))
  28.     (setq distEnd (1+ distEnd))
  29.     (setq distRest (- distRest (+ num 0.5)))
  30.   )
  31.   (setq distEnd (+ distEnd distRest))
  32.  
  33.   (setq distCurrent (/ distBetween -2.0))
  34.   (repeat num
  35.     (setq result
  36.       (vl-list*
  37.         (+ distCurrent distBetween distPattern)
  38.         (+ distCurrent distBetween)
  39.         result
  40.       )
  41.     )
  42.     (setq distCurrent (+ distCurrent distBetween distPattern))
  43.   )
  44.   result
  45. )

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Perforated ARC
« Reply #4 on: December 17, 2013, 08:57:43 AM »
Thanks!

I leaning more toward determining the OCS and then translating the pertinent points.  The rotation angle still isn't quite right.

Code: [Select]
;;;ARG ->  Arc_entity_Name
(defun ins_canop (an / bn x y ad ce ra sa ea tk ia al iq ii fa ip uc oc)

(defun pt2ocs (pt)
  (mapcar '(lambda (c) (* c (/ 1. (distance '(0 0 0) pt)))) pt))

;;;BLOCK NAME AND BOUNDARIES
(setq bn "VL-CANOP"
      x 12.0
      y 18.0)

(if (not (tblsearch "BLOCK" bn))
    (progn (command "_.INSERT" bn)
           (command)))

(setq ad (entget an)
      ce (cdr (assoc 10 ad))
      ra (cdr (assoc 40 ad))
      sa (cdr (assoc 50 ad))
      ea (cdr (assoc 51 ad))
      tk (cdr (assoc 39 ad))
      ia (if (> sa ea)
             (+ (- (* 2 pi) sa) ea)
             (- ea sa))
      al (* ra 2.0 pi (/ ia (* pi 2.0)))
      iq (fix (/ al x))
      ii (/ ia iq)
      fa (+ sa (* ii 0.5))
      ce (list (car ce) (cadr ce) (+ (caddr ce) (if tk (* tk 0.5) 0)))
      ip (polar ce fa ra))

(repeat iq
   (setq uc (mapcar '- (trans ip an 0) (trans ce an 0))
         oc (pt2ocs uc))
   (entmake (list (cons 0 "INSERT")(cons 2 "VL-CANOP")
                  (cons 10 (trans ip an oc))
                  (cons 50 (* pi 0.5))
                  (cons 210 oc)
                  ))
   (setq fa (+ fa ii))
   (setq ip (polar ce fa ra)))

(prin1))


R12 Dos - A2K

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Perforated ARC
« Reply #5 on: December 18, 2013, 05:29:02 AM »
Here is my solution. I have not yet looked at your code.
Code - Auto/Visual Lisp: [Select]
  1. (defun DistListGet (arcLen / distBetween distCurrent distEnd distPattern distRest halfArcLen num tmp)
  2.   (setq halfArcLen (/ arcLen 2.0)) ; Even number of patterns.
  3.   (setq distBetween 3.0)
  4.   (setq distEnd 3.0)
  5.   (setq distPattern 10.0)
  6.  
  7.   (setq num
  8.     (fix
  9.       (/
  10.         (- halfArcLen distEnd (/ distBetween -2.0))
  11.         (+ distPattern distBetween)
  12.       )
  13.     )
  14.   )
  15.   (setq distRest
  16.     (-
  17.       halfArcLen
  18.       distEnd
  19.       (* num distPattern)
  20.       (* (- num 0.5) distBetween)
  21.     )
  22.   )
  23.   (while
  24.     (and
  25.       (> distRest (+ num 0.5)) ; (- num 0.5) for distBetween and 1 for distEnd.
  26.       (< distBetween 6.0)
  27.     )
  28.     (setq distBetween (1+ distBetween))
  29.     (setq distEnd (1+ distEnd))
  30.     (setq distRest (- distRest (+ num 0.5)))
  31.   )
  32.   (setq distEnd (+ distEnd distRest))
  33.  
  34.   (setq distCurrent (/ (+ distBetween distPattern) -2.0)) ; Center of 'previous' pattern.
  35.   (repeat num
  36.     (setq tmp
  37.       (cons
  38.         (setq distCurrent (+ distCurrent distBetween distPattern))
  39.         tmp
  40.       )
  41.     )
  42.   )
  43.   (append
  44.     (mapcar
  45.       '(lambda (a) (- halfArcLen a))
  46.       tmp
  47.     )
  48.     (mapcar
  49.       '(lambda (a) (+ a halfArcLen))
  50.       (reverse tmp)
  51.     )
  52.   )
  53. )
  54.  
  55. (defun c:InsertAlongArc ( / arcCenPoint arcEname arcNormal arcObject)
  56.   (if
  57.     (and
  58.       (or
  59.         (tblobjname "block" "VL-CANOP")
  60.         (prompt "\nVL-CANOP Block is missing ")
  61.       )
  62.       (setq arcEname (car (entsel)))
  63.       (setq arcObject (vlax-ename->vla-object arcEname))
  64.       (= (vla-get-objectname arcObject) "AcDbArc")
  65.     )
  66.     (progn
  67.       (setq arcCenPoint (vlax-get arcObject 'center))
  68.       (setq arcNormal (vlax-get arcObject 'normal))
  69.       (mapcar
  70.         '(lambda (dist / insNormal insPoint)
  71.           (setq insPoint (vlax-curve-getpointatdist arcObject dist)) ; In WCS.
  72.           (setq insNormal (mapcar '- insPoint arcCenPoint)) ; Not a unit vector.
  73.           (entmake
  74.             (list
  75.               '(0 . "INSERT")
  76.               '(8 . "0")
  77.               '(2 . "VL-CANOP")
  78.               (cons 10 (trans insPoint 0 insNormal))
  79.               '(41 . 1.0)
  80.               '(42 . 1.0)
  81.               '(43 . 1.0)
  82.               (cons
  83.                 50
  84.                 (+
  85.                   (angle
  86.                     '(0.0 0.0 0.0)
  87.                     (trans arcNormal 0 insNormal)
  88.                   )
  89.                   (/ pi 2.0)
  90.                 )
  91.               )
  92.               ; '(70 . 0)
  93.               ; '(71 . 0)
  94.               ; '(44 . 0.0)
  95.               ; '(45 . 0.0)
  96.               (cons 210 insNormal)
  97.             )
  98.           )
  99.         )
  100.         (DistListGet (vla-get-arclength arcObject))
  101.       )
  102.     )
  103.   )
  104.   (princ)
  105. )
  106.  

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Perforated ARC
« Reply #6 on: December 18, 2013, 05:57:49 AM »
Remarks:
1.
Your code does not calculate the insert angle relative to the OCS of the insert.
2.
Turning uc into a unit vector is not required on BricsCAD.
3.
My code does not look at the thickness of the arc.
4.
My code assumes an even number of patterns and some 'aesthetic logic' for the distribution.
« Last Edit: December 18, 2013, 06:03:44 AM by roy_043 »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Perforated ARC
« Reply #7 on: December 18, 2013, 08:35:59 AM »
I've looked at your code David, and I've just modified it for any 3d arc case... It's slower, but I struggled to do just like you did with (entmake), and had no success... So, I've decided to use more reliable method with (command "_.ucs" ...)... Look in attached DWG... All body of your code I kept intact...

Code: [Select]
;;;ARG ->  Arc_entity_Name
(defun ins_canop ( an / bn x y ad ce ra sa ea tk ia al iq ii fa ip ipw cew )

(command "_.ucs" "w")

(defun v^v ( u v / cda )
  (defun cda ( p ) (cdr (append p p)))
  (mapcar '- (mapcar '* (cda u) (cdr (cda v))) (mapcar '* (cdr (cda u)) (cda v)) '(0.0 0.0 0.0))
)

;;;BLOCK NAME AND BOUNDARIES
(setq bn "VL-CANOP"
      x 12.0
      y 18.0
)

(if (not (tblsearch "BLOCK" bn))
    (progn (command "_.INSERT" bn)
           (command)
    )
)

(setq ad (entget an)
      ce (cdr (assoc 10 ad))
      ra (cdr (assoc 40 ad))
      sa (cdr (assoc 50 ad))
      ea (cdr (assoc 51 ad))
      tk (cdr (assoc 39 ad))
      ia (if (> sa ea)
             (+ (- (* 2 pi) sa) ea)
             (- ea sa))
      al (* ra 2.0 pi (/ ia (* pi 2.0)))
      iq (fix (/ al x))
      ii (/ ia iq)
      fa (+ sa (* ii 0.5))
      ce (list (car ce) (cadr ce) (+ (caddr ce) (if tk (* tk 0.5) 0)))
      ip (polar ce fa ra)
)

(repeat iq
   (setq ipw (trans ip an 0)
         cew (trans ce an 0)
   )
   (command "_.ucs" "3p" ipw (mapcar '+ ipw (v^v (cdr (assoc 210 ad)) (mapcar '- ipw cew))) (mapcar '+ ipw (cdr (assoc 210 ad))))
   (command "_.insert" bn "0.0,0.0,0.0" "" "" "")
   (command "_.ucs" "p")
   (setq fa (+ fa ii))
   (setq ip (polar ce fa ra))
)
(prin1)
)
« Last Edit: December 18, 2013, 09:20:44 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Perforated ARC
« Reply #8 on: December 18, 2013, 01:40:30 PM »
Here is my solution. I have not yet looked at your code.

Thanks!  I'll have to dig into as my versions don't have vl*** calls.  I'kl have to try it on a newer release.

-David
R12 Dos - A2K

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Perforated ARC
« Reply #9 on: December 18, 2013, 01:43:15 PM »
I've looked at your code David, and I've just modified it for any 3d arc case... It's slower, but I struggled to do just like you did with (entmake), and had no success... So, I've decided to use more reliable method with (command "_.ucs" ...)... Look in attached DWG... All body of your code I kept intact...


Thanks!  I see the UCS 3P call.  Very interesting.  I wonder if it differs from a UCS _Ent approach.

I was going to look into how the start angle ( 50 ) relates to an OCS of an ARC.

-David
R12 Dos - A2K

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Perforated ARC
« Reply #10 on: December 19, 2013, 03:35:03 AM »
However, I've changed your code to be more precise while calculation... I used x value projected on arc to obtain segmentation values... Formula is little big for projection of X tangent to arc... But with it you can further modify arc length, so that plates touch each other in the same adjacent edges...

Code - Auto/Visual Lisp: [Select]
  1. ;;;ARG ->  Arc_entity_Name
  2. (defun ins_canop ( an / bn x y ad ce ra sa ea tk ia al tt b iq si ii fa ip uc oc arcNormal )
  3.  
  4. (defun unit ( v )
  5.   (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v)
  6. )
  7.  
  8. (defun acos ( x )
  9.   (cond
  10.     ((equal x 1.0 1e-8) 0.0)
  11.     ((equal x -1.0 1e-8) pi)
  12.     ((equal x 0.0 1e-8) (/ pi 2.0))
  13.     ((equal x -0.0 1e-8) (* 3.0 (/ pi 2.0)))
  14.     ((atan (/ (sqrt (- 1.0 (* x x))) x)))
  15.   )
  16. )
  17.  
  18. ;;;BLOCK NAME AND BOUNDARIES
  19. (setq bn "VL-CANOP"
  20.       x 12.0
  21.       y 18.0
  22. )
  23.  
  24. (if (not (tblsearch "BLOCK" bn))
  25.     (progn (command "_.INSERT" bn)
  26.            (command)
  27.     )
  28. )
  29.  
  30. (setq ad (entget an)
  31.       ce (cdr (assoc 10 ad))
  32.       ra (cdr (assoc 40 ad))
  33.       sa (cdr (assoc 50 ad))
  34.       ea (cdr (assoc 51 ad))
  35.       tk (cdr (assoc 39 ad))
  36.       ia (if (> sa ea)
  37.              (+ (- (* 2 pi) sa) ea)
  38.              (- ea sa)
  39.          )
  40.       al (* ra 2.0 pi (/ ia (* pi 2.0)))
  41.       tt (- (sqrt (+ (expt ra 2) (expt (/ x 2.0) 2))) ra)
  42.       b  (acos (/ (- (* 2.0 (expt ra 2)) (expt (- x (/ (+ (- (* x (expt tt 2))) (sqrt (+ (* (expt x 2) (expt tt 4)) (* (- (expt ra 2) (expt tt 2)) (expt tt 2) (expt x 2))))) (- (expt ra 2) (expt tt 2)))) 2)) (* 2.0 (expt ra 2))))
  43.       x  (* ra b)
  44.       iq (fix (/ al x))
  45.       si (/ (- ia (* iq b)) 2.0)
  46.       ia (* iq b)
  47.       ii (/ ia iq)
  48.       fa (+ sa si (* ii 0.5))
  49.       ce (list (car ce) (cadr ce) (+ (caddr ce) (if tk (* tk 0.5) 0)))
  50.       ip (polar ce fa ra)
  51.       arcNormal (cdr (assoc 210 ad))
  52. )
  53.  
  54. (repeat iq
  55.   (setq uc (mapcar '- (trans ip an 0) (trans ce an 0))
  56.         oc (unit uc)
  57.   )
  58.   (entmake (list (cons 0 "INSERT")(cons 2 "VL-CANOP")
  59.                  (cons 10 (trans ip an oc))
  60.                  (cons
  61.                    50
  62.                    (+
  63.                      (angle '(0.0 0.0 0.0) (trans arcNormal 0 oc))
  64.                      (* pi 0.5)
  65.                    )
  66.                  )
  67.                  (cons 210 oc)
  68.            )
  69.   )
  70.   (setq fa (+ fa ii))
  71.   (setq ip (polar ce fa ra))
  72. )
  73.  
  74. )
  75.  

Equations :
Code: [Select]
1.b=2a
2.x'=(L-R)*sin(a)
3.z=x-2x'
4.z^2=R^2+R^2-2*R*R*cos(b)
5.L^2=R^2+(x/2)^2
--------------------------
2.sin(a)=x'/(L-R)
4.cos(b)=cos(2a)=(2R^2-z^2)/2R^2
--------------------------------
4.(cos(a))^2-(sin(a))^2=cos(2a)=(2R^2-z^2)/2R^2
6.(cos(a))^2+(sin(a))^2=1
-----------------------------------------------
4.6. => 7. 2(cos(a))^2=(2R^2-z^2)/2R^2+1
           (cos(a))^2=((2R^2-z^2)/2R^2+1)/2
-------------------------------------------
2.7.6. => 8. ((2R^2-z^2)/2R^2+1)/2+x'^2/(L-R)^2=1
5. => 9.      (L-R)=tt=(sqrt(R^2+(x/2)^2))-R
9.8. => 10.   (2R^2-z^2)/4R^2+x'^2/tt^2-1/2=0
---------------------------------------------
3.10. => (2R^2-(x-2x')^2)/4R^2+x'^2/tt^2-1/2=0 /*4R^2tt^2
---------------------------------------------------------
(2R^2-(x-2x')^2)*tt^2+x'^2*4R^2-2R^2tt^2=0
------------------------------------------
2R^2*tt^2-x^2*tt^2+4xx'*tt^2-4x'^2*tt^2+x'^2*4R^2-2R^2tt^2=0
---------                                        ---------
------------------------------------------------------------
(4R^2-4tt^2)*x'^2+4xtt^2*x'-x^2*tt^2=0
--------------------------------------
x'12=(-2xtt^2+-(sqrt(4x^2tt^4+(4R^2-4tt^2)tt^2x^2)))/(4R^2-4tt^2)
-----------------------------------------------------------------
-2xtt^2<0 ; x'>0 =>
x'=(-2xtt^2+-(sqrt(4x^2tt^4+(4R^2-4tt^2)tt^2x^2)))/(4R^2-4tt^2)
           --
           +
---------------------------------------------------------------
x'=(-xtt^2+(sqrt(x^2tt^4+(R^2-tt^2)tt^2x^2)))/(2R^2-2tt^2)
----------------------------------------------------------
2x'=(-xtt^2+(sqrt(x^2tt^4+(R^2-tt^2)tt^2x^2)))/(R^2-tt^2)
---------------------------------------------------------
---------------------------------------------------------
4.3.10. => b=2a=acos(2R^2-(x-2x')^2)/2R^2
           b=acos(2R^2-(x-((-xtt^2+(sqrt(x^2tt^4+(R^2-tt^2)tt^2x^2)))/(R^2-tt^2)))^2)/2R^2
« Last Edit: December 21, 2013, 12:04:53 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Perforated ARC
« Reply #11 on: December 19, 2013, 04:25:00 AM »
I was going to look into how the start angle ( 50 ) relates to an OCS of an ARC.
My code does solve that problem. Here is your code adapted accordingly (line 2, 31 and 38-44):
Code - Auto/Visual Lisp: [Select]
  1. ;;;ARG ->  Arc_entity_Name
  2. (defun ins_canop (an / bn x y ad ce ra sa ea tk ia al iq ii fa ip uc oc arcNormal)
  3.  
  4. (defun pt2ocs (pt)
  5.   (mapcar '(lambda (c) (* c (/ 1. (distance '(0 0 0) pt)))) pt))
  6.  
  7. ;;;BLOCK NAME AND BOUNDARIES
  8. (setq bn "VL-CANOP"
  9.       x 12.0
  10.       y 18.0)
  11.  
  12. (if (not (tblsearch "BLOCK" bn))
  13.     (progn (command "_.INSERT" bn)
  14.            (command)))
  15.  
  16. (setq ad (entget an)
  17.       ce (cdr (assoc 10 ad))
  18.       ra (cdr (assoc 40 ad))
  19.       sa (cdr (assoc 50 ad))
  20.       ea (cdr (assoc 51 ad))
  21.       tk (cdr (assoc 39 ad))
  22.       ia (if (> sa ea)
  23.              (+ (- (* 2 pi) sa) ea)
  24.              (- ea sa))
  25.       al (* ra 2.0 pi (/ ia (* pi 2.0)))
  26.       iq (fix (/ al x))
  27.       ii (/ ia iq)
  28.       fa (+ sa (* ii 0.5))
  29.       ce (list (car ce) (cadr ce) (+ (caddr ce) (if tk (* tk 0.5) 0)))
  30.       ip (polar ce fa ra)
  31.       arcNormal (cdr (assoc 210 ad))) ; Normal of the arc.
  32.  
  33. (repeat iq
  34.    (setq uc (mapcar '- (trans ip an 0) (trans ce an 0))
  35.          oc (pt2ocs uc))
  36.    (entmake (list (cons 0 "INSERT")(cons 2 "VL-CANOP")
  37.                   (cons 10 (trans ip an oc))
  38.                   (cons
  39.                     50
  40.                     (+
  41.                       (angle '(0.0 0.0 0.0) (trans arcNormal 0 oc))
  42.                       (* pi 0.5)
  43.                     )
  44.                   )
  45.                   (cons 210 oc)
  46.                   ))
  47.    (setq fa (+ fa ii))
  48.    (setq ip (polar ce fa ra)))
  49.  
« Last Edit: December 19, 2013, 04:28:27 AM by roy_043 »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Perforated ARC
« Reply #12 on: December 19, 2013, 04:44:10 AM »
Thanks, roy_043, I've updated my code according to your discovery... Now it's faster and I think this is what OP wanted...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Perforated ARC
« Reply #13 on: December 19, 2013, 12:07:19 PM »
Thanks guys!  So for so good.  I have a lot of uses for this if it keeps on working.  -David
R12 Dos - A2K

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Perforated ARC
« Reply #14 on: December 20, 2013, 03:02:34 PM »
The latest final product !  Thanks again !  -David
R12 Dos - A2K