Author Topic: Convert HVAC radius elbow to segmented problem..  (Read 1930 times)

0 Members and 1 Guest are viewing this topic.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Convert HVAC radius elbow to segmented problem..
« on: October 13, 2016, 01:35:33 AM »
Hi All!
I need to convert radius elbow to segmented like shown in a picture..
(see attachments)
I find the appropriative routine to convert arc to segmented pline with user defined number of segments
 (see attachments) and now I need a little improvement in this program to draw line or plines from segment vertex’s to center of selected arcs
Can somebody help me to do it?
Any help will be very appreciated

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Convert HVAC radius elbow to segmented problem..
« Reply #1 on: October 13, 2016, 11:46:57 AM »
Give this a try:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:segarc (/ _makepolyline arc arc2 arcs cp d i p1 p2 pst sp x)
  2.   ;; RJP 10.13.2016
  3.   (defun _makepolyline (layer pts)
  4.                      (list (list '(0 . "LWPOLYLINE")
  5.                                  '(100 . "AcDbEntity")
  6.                                  (cons 8 layer)
  7.                                  '(100 . "AcDbPolyline")
  8.                                  (cons 90 (length pts))
  9.                                  '(43 . 0)
  10.                                  '(70 . 1)
  11.                            )
  12.                            (mapcar '(lambda (x) (list 10 (car x) (cadr x))) pts)
  13.                      )
  14.               )
  15.     )
  16.   )
  17.   ;; Change 'i' for number of segments
  18.   (setq i 8)
  19.   (if (setq arcs (ssget ":L" '((0 . "arc"))))
  20.     (progn (setq arcs (vl-remove-if 'listp (mapcar 'cadr (ssnamex arcs))))
  21.            (while (setq arc (car arcs))
  22.              (setq cp (cdr (assoc 10 (entget arc))))
  23.              (if (setq arc2 (car (vl-remove-if-not
  24.                                    '(lambda (x) (equal cp (cdr (assoc 10 (entget x))) 0.0001))
  25.                                    (setq arcs (cdr arcs))
  26.                                  )
  27.                             )
  28.                  )
  29.                (progn (setq arcs (vl-remove arc2 arcs))
  30.                       (setq sp (vlax-curve-getstartparam arc))
  31.                       (setq d (/ (- (vlax-curve-getendparam arc) sp) i))
  32.                       (repeat i
  33.                         (setq p1 (vlax-curve-getpointatparam arc sp))
  34.                         (setq p2 (vlax-curve-getpointatparam arc (setq sp (+ d sp))))
  35.                         (_makepolyline
  36.                           (cdr (assoc 8 (entget arc)))
  37.                           (list p1
  38.                                 p2
  39.                                 (vlax-curve-getclosestpointto arc2 p2)
  40.                                 (vlax-curve-getclosestpointto arc2 p1)
  41.                           )
  42.                         )
  43.                       )
  44.                       (entdel arc)
  45.                       (entdel arc2)
  46.                )
  47.              )
  48.            )
  49.     )
  50.   )
  51.   (princ)
  52. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Convert HVAC radius elbow to segmented problem..
« Reply #2 on: October 18, 2016, 01:20:27 AM »
Hi  ronjonp.
I'm sorry for not quick answer (it was very long holydays here). I don't know why, but your approach not working for me .. actually it didn’t make nothing. Do you have any explanation about it?

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Convert HVAC radius elbow to segmented problem..
« Reply #3 on: October 18, 2016, 02:13:30 AM »
Now I already find the "final" solution of this issue. You can see it here:

https://lispbox.wordpress.com/2016/10/18/convert-radius-elbow-to-segmented-with-user-defined-number-of-segments/


ronjonp

  • Needs a day job
  • Posts: 7529
Re: Convert HVAC radius elbow to segmented problem..
« Reply #4 on: October 18, 2016, 10:11:02 AM »
Hi  ronjonp.
I'm sorry for not quick answer (it was very long holydays here). I don't know why, but your approach not working for me .. actually it didn’t make nothing. Do you have any explanation about it?
Not sure why it does not work for you .. do your 2 arcs share a common center point?


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Convert HVAC radius elbow to segmented problem..
« Reply #5 on: October 18, 2016, 10:16:56 AM »
.. oops.. you are right!
Now I understand ..it was my mistake. Your picture help me a lot to understand a process
Thank you

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Convert HVAC radius elbow to segmented problem..
« Reply #6 on: October 18, 2016, 10:21:35 AM »
.. oops.. you are right!
Now I understand ..it was my mistake. Your picture help me a lot to understand a process
Thank you
Glad we got it sorted :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC