Author Topic: region2pl  (Read 4479 times)

0 Members and 1 Guest are viewing this topic.

taner

  • Guest
region2pl
« on: October 05, 2009, 11:53:42 AM »
Dear all,

Can anyone write some codes to convert all kinds of regions to polylines?
Thanks in advance.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: region2pl
« Reply #1 on: October 05, 2009, 12:22:49 PM »
Hi

It is not possible to convert "all kind" of regions into polylines. Polylines have only lines and arcs.

Here's a routine which convert valid selected regions (which countains onlt lines and arcs) into polylines

Code: [Select]
;;; R2PL -Gilles Chanteau- 01/01/07
;;; Transforme les régions sélectionnées en polylignes.

(defun c:r2pl (/ *error* arcbugle acdoc space
ss n reg norm expl olst
blst dlst plst tlst blg pline
)
  (vl-load-com)

;;;***************************************************************;;;

  (defun *error* (msg)
    (if (/= msg "Function cancelled")
      (princ (strcat "\nError: " msg))
    )
    (vla-EndUndoMark
      (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    (princ)
  )

;;;***************************************************************;;;

  (defun arcbulge (arc)
    (/ (sin (/ (vla-get-TotalAngle arc) 4))
       (cos (/ (vla-get-TotalAngle arc) 4))
    )
  )

;;;***************************************************************;;;

  (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))
space (if (= 1 (getvar "CVPORT"))
  (vla-get-PaperSpace acdoc)
  (vla-get-ModelSpace acdoc)
)
  )
  (if (ssget '((0 . "REGION")))
    (progn
      (vla-StartUndoMark acdoc)
      (vlax-for reg (setq ss (vla-get-ActiveSelectionSet acdoc))
(setq norm (vlax-get reg 'Normal)
      expl (vlax-invoke reg 'Explode)
)
(if (vl-every '(lambda (x)
(or
   (= (vla-get-ObjectName x) "AcDbLine")
   (= (vla-get-ObjectName x) "AcDbArc")
)
       )
      expl
    )
  (progn
    (vla-delete reg)
    (setq olst (mapcar '(lambda (x)
  (list x
(vlax-get x 'StartPoint)
(vlax-get x 'EndPoint)
  )
)
       expl
       )
    )
    (while olst
      (setq blst nil)
      (if (= (vla-get-ObjectName (caar olst)) "AcDbArc")
(setq blst (list (cons 0 (arcbulge (caar olst)))))
      )
      (setq plst (cdar olst)
    dlst (list (caar olst))
    olst (cdr olst)
      )
      (while
(setq
  tlst
   (vl-member-if
     '(lambda (x)
(or (equal (last plst) (cadr x) 1e-9)
    (equal (last plst) (caddr x) 1e-9)
)
      )
     olst
   )
)
(if (equal (last plst) (caddar tlst) 1e-9)
   (setq blg -1)
   (setq blg 1)
)
(if
   (= (vla-get-ObjectName (caar tlst)) "AcDbArc")
    (setq
      blst
       (cons (cons (1- (length plst))
   (* blg (arcbulge (caar tlst)))
     )
     blst
       )
    )
)
(setq plst (append plst
    (if (minusp blg)
      (list (cadar tlst))
      (list (caddar tlst))
    )
    )
       dlst (cons (caar tlst) dlst)
       olst (vl-remove (car tlst) olst)
)
      )
      (setq pline
     (vlax-invoke
       Space
       'addLightWeightPolyline
       (apply 'append
      (mapcar '(lambda (x)
(setq x (trans x 0 Norm))
(list (car x) (cadr x))
       )
      (reverse (cdr (reverse plst)))
      )
       )
     )
      )
      (vla-put-Closed pline :vlax-true)
      (mapcar
'(lambda (x) (vla-setBulge pline (car x) (cdr x)))
blst
      )
      (vla-put-Elevation
pline
(caddr (trans (car plst) 0 Norm))
      )
      (vla-put-Normal pline (vlax-3d-point Norm))
      (mapcar 'vla-delete dlst)
    )
  )
  (mapcar 'vla-delete expl)
)
      )
      (vla-delete ss)
      (vla-EndUndoMark acdoc)
    )
  )
  (princ)
)
« Last Edit: October 05, 2009, 12:30:12 PM by gile »
Speaking English as a French Frog

taner

  • Guest
Re: region2pl
« Reply #2 on: October 05, 2009, 08:22:05 PM »
Hi

It is not possible to convert "all kind" of regions into polylines. Polylines have only lines and arcs.

Here's a routine which convert valid selected regions (which countains onlt lines and arcs) into polylines


Thanks very much Sir.

Beekee

  • Mosquito
  • Posts: 19
Re: region2pl
« Reply #3 on: June 26, 2016, 03:43:32 PM »
Hello, I would like to use this routine as sub-function...

I have my routine in LISP and I need to convert a regular selection set of regions to polylines. I can't figure out how to adjust this (vlax-for reg (setq ss (vla-get-ActiveSelectionSet acdoc)) loop... to use my selection set (created by (ssadd)). I tried to add (sssetfirst nil sel) before, but you know, it did not work...

Thanks in advance.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: region2pl
« Reply #4 on: June 27, 2016, 01:04:44 AM »
Hi

Replace:
Code - Auto/Visual Lisp: [Select]
with:
Code - Auto/Visual Lisp: [Select]
  1. (repeat (setq i (sslength sel))
  2.   (setq reg (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
and remove:
Code - Auto/Visual Lisp: [Select]
This should do the trick (not tested).
Speaking English as a French Frog

lamarn

  • Swamp Rat
  • Posts: 636
Re: region2pl
« Reply #5 on: June 27, 2016, 05:18:55 AM »
Edit: It works!
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Beekee

  • Mosquito
  • Posts: 19
Re: region2pl
« Reply #6 on: June 27, 2016, 10:32:33 AM »
Hi and thank you, gile! It works nicely!

(just for the record... ss and sel should be the same.. )

Hi

Replace:
Code - Auto/Visual Lisp: [Select]
with:
Code - Auto/Visual Lisp: [Select]
  1. (repeat (setq i (sslength sel))
  2.   (setq reg (vlax-ename->vla-object (ssname sel (setq i (1- i)))))
and remove:
Code - Auto/Visual Lisp: [Select]
This should do the trick (not tested).

dexus

  • Bull Frog
  • Posts: 207
Re: region2pl
« Reply #7 on: July 14, 2023, 05:11:15 AM »
I was looking for a function to convert regions into polylines.
The ones that use PEDIT do not work on regions that are perpendicular to the UCS.
I made one myself but it was a lot slower than this one. If only I found this earlier, thanks for sharing gile!

This one didn't work on combined regions like when you use "Union" on two regions that are not connected.
So I made a modification for that and thought I would share it back to the community.

Here is the function:
Code - Auto/Visual Lisp: [Select]
  1. ;;-----------------------------------;;
  2. ;; region->polyline                  ;;
  3. ;;-----------------------------------;;
  4. ;; Gilles Chanteau - 01/01/07        ;;
  5. ;; Small changes by dexus - 14/07/23 ;;
  6. ;;-----------------------------------;;
  7. (defun region->polyline (ent / n reg norm expl olst blst dlst plst tlst blg space pline prop _arcbulge)
  8.   (defun _arcbulge (arc)
  9.     (/
  10.       (sin (/ (vla-get-TotalAngle arc) 4))
  11.       (cos (/ (vla-get-TotalAngle arc) 4))
  12.     )
  13.   )
  14.   (if
  15.     (and
  16.       (setq reg (cond ((= (type ent) 'vla-object) ent) ((= (type ent) 'ename) (vlax-ename->vla-object ent))))
  17.       (= (vla-get-ObjectName reg) "AcDbRegion")
  18.     )
  19.     (progn
  20.       (setq prop (mapcar (function (lambda (p) (vlax-get reg p))) '(Layer LineType Color))
  21.             norm (vlax-get reg 'Normal)
  22.             expl (vlax-invoke reg 'Explode)
  23.             space (vlax-get (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
  24.       (cond
  25.         ((vl-every (function (lambda (x) (or (= (vla-get-ObjectName x) "AcDbLine") (= (vla-get-ObjectName x) "AcDbArc")))) expl)
  26.           (vla-delete reg)
  27.           (setq olst (mapcar (function (lambda (x) (list x (vlax-get x 'StartPoint) (vlax-get x 'EndPoint)))) expl))
  28.           (while olst
  29.             (setq blst nil)
  30.             (if (= (vla-get-ObjectName (caar olst)) "AcDbArc")
  31.               (setq blst (list (cons 0 (_arcbulge (caar olst)))))
  32.             )
  33.             (setq plst (cdar olst)
  34.                   dlst (list (caar olst))
  35.                   olst (cdr olst))
  36.             (while (setq tlst (vl-member-if (function (lambda (x) (or (equal (last plst) (cadr x) 1e-9) (equal (last plst) (caddr x) 1e-9)))) olst))
  37.               (if (equal (last plst) (caddar tlst) 1e-9)
  38.                 (setq blg -1)
  39.                 (setq blg 1)
  40.               )
  41.               (if (= (vla-get-ObjectName (caar tlst)) "AcDbArc")
  42.                 (setq blst (cons (cons (1- (length plst)) (* blg (_arcbulge (caar tlst)))) blst))
  43.               )
  44.               (setq plst
  45.                       (append plst
  46.                         (if (minusp blg)
  47.                           (list (cadar tlst))
  48.                           (list (caddar tlst))
  49.                         )
  50.                       )
  51.                     dlst (cons (caar tlst) dlst)
  52.                     olst (vl-remove (car tlst) olst))
  53.             )
  54.             (setq pline (vlax-invoke space 'addLightWeightPolyline (apply 'append (mapcar (function (lambda (x) (setq x (trans x 0 Norm)) (list (car x) (cadr x)))) (reverse (cdr (reverse plst)))))))
  55.             (vla-put-Closed pline :vlax-true)
  56.             (mapcar (function (lambda (x) (vla-setBulge pline (car x) (cdr x)))) blst)
  57.             (vla-put-Elevation pline (caddr (trans (car plst) 0 Norm)))
  58.             (vla-put-Normal pline (vlax-3d-point Norm))
  59.             (mapcar (function (lambda (p v) (vlax-put pline p v))) '(Layer LineType Color) prop)
  60.             (mapcar 'vla-delete dlst)
  61.           )
  62.           (if pline (list pline))
  63.         )
  64.         ((vl-every (function (lambda (x) (= (vla-get-ObjectName x) "AcDbRegion"))) expl)
  65.           (vla-delete reg)
  66.           (apply 'append (mapcar 'region->polyline expl))
  67.         )
  68.         ((mapcar 'vla-delete dlst))
  69.       )
  70.     )
  71.   )
  72. )

Could be used like this:
Code - Auto/Visual Lisp: [Select]
  1. ;; Active Document - Lee Mac
  2. ;; Returns the VLA Active Document Object
  3. (defun LM:acdoc nil
  4.   (LM:acdoc)
  5. )
  6.  
  7. ;; SelectionSet -> VLA Objects - by Lee Mac
  8. (defun LM:ss->vla ( ss / i l )
  9.   (if ss
  10.     (repeat (setq i (sslength ss))
  11.       (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
  12.     )
  13.   )
  14. )
  15.  
  16. (defun c:r2pl nil
  17.   (mapcar 'region->polyline (lm:ss->vla (ssget '((0 . "REGION")))))
  18.   (princ)
  19. )
« Last Edit: July 17, 2023, 02:32:10 AM by dexus »

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: region2pl
« Reply #8 on: July 14, 2023, 10:16:11 AM »
@dexus,
I've found some lacks in your posted code, so I corrected them...
I hope that now it should perform well...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:r2pl ( / LM:ss->vla LM:acdoc region->polyline )
  2.  
  3.   ;; SelectionSet -> VLA Objects - by Lee Mac
  4.   (defun LM:ss->vla ( ss / i l )
  5.     (if ss
  6.       (repeat (setq i (sslength ss))
  7.         (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
  8.       )
  9.     )
  10.   )
  11.  
  12.   ;; Active Document  -  Lee Mac
  13.   ;; Returns the VLA Active Document Object
  14.    
  15.   (defun LM:acdoc nil
  16.     (LM:acdoc)
  17.   )
  18.  
  19.   ;;-----------------------------------;;
  20.   ;; region->polyline                  ;;
  21.   ;;-----------------------------------;;
  22.   ;; Gilles Chanteau - 01/01/07        ;;
  23.   ;; Small changes by dexus - 14/07/23 ;;
  24.   ;;-----------------------------------;;
  25.   (defun region->polyline (ent / n reg norm expl olst blst dlst plst tlst blg space pline prop alst mlst mp pos _arcbulge)
  26.     (defun _arcbulge (arc)
  27.       (/
  28.         (sin (/ (vla-get-TotalAngle arc) 4))
  29.         (cos (/ (vla-get-TotalAngle arc) 4))
  30.       )
  31.     )
  32.     (if
  33.       (and
  34.         (setq reg (cond ((= (type ent) 'vla-object) ent) ((= (type ent) 'ename) (vlax-ename->vla-object ent))))
  35.         (= (vla-get-ObjectName reg) "AcDbRegion")
  36.       )
  37.       (progn
  38.         (setq prop (mapcar (function (lambda (p) (vlax-get reg p))) '(Layer LineType Color))
  39.               norm (vlax-get reg 'Normal)
  40.               expl (vlax-invoke reg 'Explode)
  41.               space (vlax-get (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
  42.         (cond
  43.           ((vl-every (function (lambda (x) (or (= (vla-get-ObjectName x) "AcDbLine") (= (vla-get-ObjectName x) "AcDbArc")))) expl)
  44.             (vla-delete reg)
  45.             (setq olst (mapcar (function (lambda (x) (list x (vlax-get x 'StartPoint) (vlax-get x 'EndPoint)))) expl))
  46.             (while olst
  47.               (setq blst nil)
  48.               (if (= (vla-get-ObjectName (caar olst)) "AcDbArc")
  49.                 (setq blst (list (cons 0 (_arcbulge (caar olst)))))
  50.               )
  51.               (setq plst (cdar olst)
  52.                     dlst (list (caar olst))
  53.                     olst (cdr olst))
  54.               (while (setq tlst (vl-member-if (function (lambda (x) (or (equal (last plst) (cadr x) 1e-9) (equal (last plst) (caddr x) 1e-9)))) olst))
  55.                 (if (equal (last plst) (caddar tlst) 1e-9)
  56.                   (setq blg -1)
  57.                   (setq blg 1)
  58.                 )
  59.                 (if (= (vla-get-ObjectName (caar tlst)) "AcDbArc")
  60.                   (setq blst (cons (cons (1- (length plst)) (* blg (_arcbulge (caar tlst)))) blst))
  61.                 )
  62.                 (setq plst
  63.                         (append plst
  64.                           (if (minusp blg)
  65.                             (list (cadar tlst))
  66.                             (list (caddar tlst))
  67.                           )
  68.                         )
  69.                       dlst (cons (caar tlst) dlst)
  70.                       olst (vl-remove (car tlst) olst))
  71.               )
  72.               (setq pline (vlax-invoke space 'addLightWeightPolyline (apply 'append (mapcar (function (lambda (x) (setq x (trans x 0 Norm)) (list (car x) (cadr x)))) (reverse (cdr (reverse plst)))))))
  73.               (vla-put-Closed pline :vlax-true)
  74.               (vla-put-Elevation pline (caddr (trans (car plst) 0 Norm)))
  75.               (vla-put-Normal pline (vlax-3d-point Norm))
  76.               (setq alst (vl-remove-if-not (function (lambda (x) (= (vla-get-ObjectName x) "AcDbArc"))) dlst))
  77.               (setq mlst (mapcar (function (lambda (x) (vlax-curve-GetPointAtParam x (/ (+ (vlax-curve-GetStartParam x) (vlax-curve-GetEndParam x)) 2.0)))) alst))
  78.               (mapcar (function (lambda (x) (vla-setBulge pline (car x) (cdr x)))) blst)
  79.               (while (setq mp (vl-some (function (lambda (x) (if (not (vlax-curve-GetParamAtPoint pline x)) x))) mlst))
  80.                 (setq pos (vl-position mp mlst))
  81.                 (vla-SetBulge pline (car (nth pos blst)) (- (cdr (nth pos blst))))
  82.                 (setq mp nil)
  83.               )
  84.               (mapcar (function (lambda (p v) (vlax-put pline p v))) '(Layer LineType Color) prop)
  85.               (mapcar 'vla-delete dlst)
  86.             )
  87.             (if pline (list pline))
  88.           )
  89.           ((vl-every (function (lambda (x) (= (vla-get-ObjectName x) "AcDbRegion"))) expl)
  90.             (vla-delete reg)
  91.             (apply 'append (mapcar 'region->polyline expl))
  92.           )
  93.           ((mapcar 'vla-delete dlst))
  94.         )
  95.       )
  96.     )
  97.   )
  98.  
  99.   (mapcar 'region->polyline (lm:ss->vla (ssget "_:L" '((0 . "REGION")))))
  100.   (princ)
  101. )
  102.  

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

:)

M.R. on Youtube

ScottMC

  • Newt
  • Posts: 192
Re: region2pl
« Reply #9 on: July 14, 2023, 11:13:32 PM »
Boundary [selective]?

dexus

  • Bull Frog
  • Posts: 207
Re: region2pl
« Reply #10 on: July 17, 2023, 03:20:49 AM »
@dexus,
I've found some lacks in your posted code, so I corrected them...
I hope that now it should perform well...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:r2pl ( / LM:ss->vla LM:acdoc region->polyline )
  2.  
  3.   ;; SelectionSet -> VLA Objects - by Lee Mac
  4.   (defun LM:ss->vla ( ss / i l )
  5.     (if ss
  6.       (repeat (setq i (sslength ss))
  7.         (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
  8.       )
  9.     )
  10.   )
  11.  
  12.   ;; Active Document  -  Lee Mac
  13.   ;; Returns the VLA Active Document Object
  14.    
  15.   (defun LM:acdoc nil
  16.     (LM:acdoc)
  17.   )
  18.  
  19.   ;;-----------------------------------;;
  20.   ;; region->polyline                  ;;
  21.   ;;-----------------------------------;;
  22.   ;; Gilles Chanteau - 01/01/07        ;;
  23.   ;; Small changes by dexus - 14/07/23 ;;
  24.   ;;-----------------------------------;;
  25.   (defun region->polyline (ent / n reg norm expl olst blst dlst plst tlst blg space pline prop alst mlst mp pos _arcbulge)
  26.     (defun _arcbulge (arc)
  27.       (/
  28.         (sin (/ (vla-get-TotalAngle arc) 4))
  29.         (cos (/ (vla-get-TotalAngle arc) 4))
  30.       )
  31.     )
  32.     (if
  33.       (and
  34.         (setq reg (cond ((= (type ent) 'vla-object) ent) ((= (type ent) 'ename) (vlax-ename->vla-object ent))))
  35.         (= (vla-get-ObjectName reg) "AcDbRegion")
  36.       )
  37.       (progn
  38.         (setq prop (mapcar (function (lambda (p) (vlax-get reg p))) '(Layer LineType Color))
  39.               norm (vlax-get reg 'Normal)
  40.               expl (vlax-invoke reg 'Explode)
  41.               space (vlax-get (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
  42.         (cond
  43.           ((vl-every (function (lambda (x) (or (= (vla-get-ObjectName x) "AcDbLine") (= (vla-get-ObjectName x) "AcDbArc")))) expl)
  44.             (vla-delete reg)
  45.             (setq olst (mapcar (function (lambda (x) (list x (vlax-get x 'StartPoint) (vlax-get x 'EndPoint)))) expl))
  46.             (while olst
  47.               (setq blst nil)
  48.               (if (= (vla-get-ObjectName (caar olst)) "AcDbArc")
  49.                 (setq blst (list (cons 0 (_arcbulge (caar olst)))))
  50.               )
  51.               (setq plst (cdar olst)
  52.                     dlst (list (caar olst))
  53.                     olst (cdr olst))
  54.               (while (setq tlst (vl-member-if (function (lambda (x) (or (equal (last plst) (cadr x) 1e-9) (equal (last plst) (caddr x) 1e-9)))) olst))
  55.                 (if (equal (last plst) (caddar tlst) 1e-9)
  56.                   (setq blg -1)
  57.                   (setq blg 1)
  58.                 )
  59.                 (if (= (vla-get-ObjectName (caar tlst)) "AcDbArc")
  60.                   (setq blst (cons (cons (1- (length plst)) (* blg (_arcbulge (caar tlst)))) blst))
  61.                 )
  62.                 (setq plst
  63.                         (append plst
  64.                           (if (minusp blg)
  65.                             (list (cadar tlst))
  66.                             (list (caddar tlst))
  67.                           )
  68.                         )
  69.                       dlst (cons (caar tlst) dlst)
  70.                       olst (vl-remove (car tlst) olst))
  71.               )
  72.               (setq pline (vlax-invoke space 'addLightWeightPolyline (apply 'append (mapcar (function (lambda (x) (setq x (trans x 0 Norm)) (list (car x) (cadr x)))) (reverse (cdr (reverse plst)))))))
  73.               (vla-put-Closed pline :vlax-true)
  74.               (vla-put-Elevation pline (caddr (trans (car plst) 0 Norm)))
  75.               (vla-put-Normal pline (vlax-3d-point Norm))
  76.               (setq alst (vl-remove-if-not (function (lambda (x) (= (vla-get-ObjectName x) "AcDbArc"))) dlst))
  77.               (setq mlst (mapcar (function (lambda (x) (vlax-curve-GetPointAtParam x (/ (+ (vlax-curve-GetStartParam x) (vlax-curve-GetEndParam x)) 2.0)))) alst))
  78.               (mapcar (function (lambda (x) (vla-setBulge pline (car x) (cdr x)))) blst)
  79.               (while (setq mp (vl-some (function (lambda (x) (if (not (vlax-curve-GetParamAtPoint pline x)) x))) mlst))
  80.                 (setq pos (vl-position mp mlst))
  81.                 (vla-SetBulge pline (car (nth pos blst)) (- (cdr (nth pos blst))))
  82.                 (setq mp nil)
  83.               )
  84.               (mapcar (function (lambda (p v) (vlax-put pline p v))) '(Layer LineType Color) prop)
  85.               (mapcar 'vla-delete dlst)
  86.             )
  87.             (if pline (list pline))
  88.           )
  89.           ((vl-every (function (lambda (x) (= (vla-get-ObjectName x) "AcDbRegion"))) expl)
  90.             (vla-delete reg)
  91.             (apply 'append (mapcar 'region->polyline expl))
  92.           )
  93.           ((mapcar 'vla-delete dlst))
  94.         )
  95.       )
  96.     )
  97.   )
  98.  
  99.   (mapcar 'region->polyline (lm:ss->vla (ssget "_:L" '((0 . "REGION")))))
  100.   (princ)
  101. )
  102.  

Regards, M.R.
Thanks for the addition Marko.
Could you explain what the change does?
As far as I can tell you get all the midpoints of arcs, and if they do not exist on the polyline you try flip the bulge.

Edit: The while loop sets mp to the output of vl-some. Which will return T or Nil.
Then tries to find the vl-position of T, which will not exist in mlst returning Nil.
And Nil is not a valid argument for nth.
So when it does find a arc that is flipped the wrong way, it will return a bad argument type error.
« Last Edit: July 17, 2023, 03:58:07 AM by dexus »

dexus

  • Bull Frog
  • Posts: 207
Re: region2pl
« Reply #11 on: July 17, 2023, 03:55:00 AM »
Boundary [selective]?
I'm not sure if I'm not using the boundary function incorrectly, but I cant seem to get it to work when the lines are not flat on the ucs.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: region2pl
« Reply #12 on: July 17, 2023, 07:53:39 AM »
Quote
So when it does find a arc that is flipped the wrong way, it will return a bad argument type error.

So when it does find a arc that is flipped the wrong way, it'll flip it with negative bulge right way...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

dexus

  • Bull Frog
  • Posts: 207
Re: region2pl
« Reply #13 on: July 17, 2023, 09:11:10 AM »
Quote
So when it does find a arc that is flipped the wrong way, it will return a bad argument type error.

So when it does find a arc that is flipped the wrong way, it'll flip it with negative bulge right way...
How does it know which one?
It does find the arc, but then it saves True to the mp variable.
Because vl-some doesn't return the variable from the lambda function, it only returns True or Nil.
Which doesn't have a position in mlst, therefore it doesn't know which one to flip.
Am I missing something here?

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: region2pl
« Reply #14 on: July 17, 2023, 09:24:13 AM »
Quote
So when it does find a arc that is flipped the wrong way, it will return a bad argument type error.

So when it does find a arc that is flipped the wrong way, it'll flip it with negative bulge right way...
How does it know which one?
It does find the arc, but then it saves True to the mp variable.
Because vl-some doesn't return the variable from the lambda function, it only returns True or Nil.
Which doesn't have a position in mlst, therefore it doesn't know which one to flip.
Am I missing something here?

Yes, you are missing the fact that (vl-some) not always return T or nil... In our particular case it returns variable mp which is mid point of exploded arc...
So if polyline at some position where is placed arc don't have parameter at mp - meaning that exploded arc don't pass - overlap with pline, at that position bulge should be negative from that that was calculated through (_arcbulge) sub...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube