Author Topic: Triangulation (re-visited)  (Read 310575 times)

0 Members and 2 Guests are viewing this topic.

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #495 on: December 01, 2015, 10:12:20 AM »
YMG,

I have an idea for eliminating the bogus exterior TIN's...

1) Prior to a TIN network being built, provide a routine for the user to construct a straight-line polyline (as a boundary) by their valid exterior points. If it is not a single polyline (by messing up and restarting), have the user merge all of its polyline segments.

2) Prompt the user to select the boundary and indicate an offset direction and distance for a temporary offset polyline (by a foot more-or-less) to its outside.

3) At activating the TIN, the boundary can be exploded to be used as breaklines. The temporary polyline can be moved to a layer that is frozen.

4) The TIN proceeds to build.

5) At completion the TIN's that are intercepted (crossed/fenced) by the temporary polyline are deleted.

6) Delete (or freeze the layer for) the temporary polyline.

Note: Before deriving this scheme I had looked at Xshape to force it to not violate breaklines. Rather than possibly damage Xshape, I thought that this alternative might work just as well.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #496 on: December 01, 2015, 01:47:06 PM »
Rick,

If you are willing to draw a boudary before, of course it simply becomes a breakline.

However it is a closed breakline, so you would need a case where you do not clean
the inside of it but instead the outside.

Xshape, is simply a way to trace a boundary after the triangulation.

The routine to creates the boundary before would simply be creating
an lwpolyline  with node osnap on and placing it on the boundary layer.

Any 3dface outside that lwpoly gets erased. Triangle List is updated.

Could add it, although I prefer doing the boundary  after.

ymg

« Last Edit: December 01, 2015, 01:53:01 PM by ymg »

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #497 on: December 02, 2015, 09:51:32 AM »
Rick,

Modify this section of c:tin
Code - Auto/Visual Lisp: [Select]
  1.           ;;                                                                  ;
  2.           ;; Building Points List  and Selection Set of Constraints           ;
  3.           ;;                                                                  ;
  4.           ;;  pl, List of Points (3D)                                         ;
  5.           ;;                                                                  ;
  6.           ;;     Entities that Creates Points are:                            ;
  7.           ;;           "POINT"     , 3D coordinates                           ;
  8.           ;;           "INSERT"    , Insertion Point of Block                 ;
  9.           ;;           "POLYLINE"  , Coordinates of all Vertices              ;
  10.           ;;           "LINE"      , Coordinates of Both Endpoints            ;
  11.           ;;                                                                  ;
  12.           ;; ssb, Selection Set of Constraints.                               ;
  13.           ;;                                                                  ;
  14.           ;;    Valid Entities for Constraints Are:                           ;
  15.           ;;          "LWPOLYNE"   , Vertex have to be on Existing Point      ;
  16.           ;;          "POLYLINE"   , Open or Closed (Same for LWpoly)         ;
  17.           ;;          "LINE"       , Make Sure you Have Z Value in Them       ;
  18.           ;;                                                                  ;
  19.          
  20.           (setq pl nil  ssb (ssadd) lay (mk_layer (list "Point" 7)))
  21.           (repeat (setq i (sslength ss))
  22.               (setq  en (ssname ss (setq i (1- i)))
  23.                     ent (entget en)
  24.                    etyp (cdr (assoc 0 ent))                    
  25.               )
  26.               (cond
  27.                  ((= etyp "LWPOLYLINE") (ssadd en ssb))
  28.                  ((= etyp "POLYLINE")
  29.                      (ssadd en ssb)
  30.                      (setq pol (listpol en))
  31.                      (foreach p pol
  32.                         (setq pl (cons p pl))
  33.                      )
  34.                      
  35.                  )
  36.                  ((= etyp "LINE")
  37.                      (ssadd en ssb)
  38.                      (setq   a (cdr (assoc 10 ent))
  39.                              b (cdr (assoc 11 ent))
  40.                             pl (cons a (cons b pl))                        
  41.                      )     
  42.                  )
  43.                  ((= etyp "INSERT")
  44.                      (setq pl (cons (cdr (assoc 10 ent)) pl))
  45.                  )
  46.                  ((= etyp "POINT")
  47.                      (setq  pl (cons (cdr (assoc 10 ent)) pl)
  48.                            ent (entmod (subst (cons 8 lay) (assoc 8 ent) ent)))
  49.                  )
  50.               )
  51.           )
  52.          
  53.           ;; Sort pl on X and Y Coordinates, then Remove Duplicates           ;
  54.          
  55.           (setq pl (remduppoint (sortxy pl) fuzz))
  56.  
  57.  
  58.           ;;                                                                  ;
  59.           ;; Building Constraints List                                        ;
  60.           ;;                                                                  ;
  61.           ;; cdtl, List of Points (3d) Forming Constraints                    ;
  62.           ;;                                                                  ;
  63.           ;;  nfl, List of Points in Constraint That Are Not in pl            ;
  64.           ;;       Simply Issues a Warning to User, Constraint is             ;
  65.           ;;       Ignored and Triangulation Allowed to Continue.             ;
  66.           ;;                                                                  ;
  67.           ;;  wpl, List of Points List, Closed Constraints (Closed Polylines) ;
  68.           ;;       With No Points Inside.  These List are Used at End of the  ;
  69.           ;;       Triangulation to Erase All 3dfaces Inside these Polygons   ;
  70.           ;;       by "WP" Selection and Triangle List is Adjsuted.           ;
  71.           ;;                                                                  ;
  72.          
  73.          
  74.           (if (> (setq len (sslength ssb)) 0)
  75.              (progn
  76.                 (acet-ui-progress "Gathering Constraints:"  len )
  77.                 (setq cdtl nil nfl nil wpl nil lay (mk_layer (list "Boundary" 2)))
  78.                 (repeat (setq i len)
  79.                    (setq  en (ssname ssb (setq i (1- i)))
  80.                          ent (entget en)
  81.                         etyp (cdr (assoc 0 ent))
  82.                    )
  83.                    (cond
  84.                       ((= etyp "LWPOLYLINE")
  85.                          (setq pol (listpol en)
  86.                                  a (pos2d (car  pol) pl fuzz)
  87.                                  b (pos2d (cadr pol) pl fuzz)
  88.                          )         
  89.                          (if (and a b)
  90.                             (setq cdtl (cons (list a b) cdtl))
  91.                             (setq  nfl (cons (list a b) nfl))
  92.                          )     
  93.                          (foreach p (cdr pol)
  94.                             (if (setq a (pos2d p pl fuzz))
  95.                                (setq cdtl (cons (list (cadar cdtl) a) cdtl))
  96.                                (setq  nfl (cons (list (cadar  nfl) a)  nfl))
  97.                             )
  98.                          )
  99.                          (if (and (equal (car pol) (last pol) 0.001)
  100.                                   (> (length pol) 2)
  101.                                   (not (ssget "_WP" (cdr pol) '((0 . "POINT"))))
  102.                                   (not (vl-position pol wpl))
  103.                              )
  104.                             (setq wpl (cons pol wpl)
  105.                                   ent (entmod (subst (cons 8 lay) (assoc 8 ent) ent))
  106.                             )
  107.                          )
  108.                       )
  109.                       ((= etyp "POLYLINE")
  110.                          (setq pol (listpol en)
  111.                                  a (pos2d (car  pol) pl fuzz)
  112.                                  b (pos2d (cadr pol) pl fuzz)
  113.                          )
  114.                          (if (and a b)
  115.                             (setq cdtl (cons (list a b) cdtl))
  116.                             (setq  nfl (cons (list a b) nfl))
  117.                          )
  118.                          (foreach p (cdr pol)
  119.                             (if (setq b (pos2d p pl fuzz))
  120.                                (setq cdtl (cons (list (cadar cdtl) b) cdtl))
  121.                                (setq  nfl (cons (list (cadar  nfl) a)  nfl))
  122.                             )
  123.                          )
  124.                          
  125.                          (if (and (equal (car pol) (last pol) 0.001)
  126.                                   (> (length pol) 2)
  127.                                   (setq pol (distinct (mapcar '(lambda (a) (list (car a) (cadr a))) pol)))
  128.                                   (or (not (ssget "_WP" pol '((0 . "POINT"))))
  129.                                       (equal en *bounden*)
  130.                                   )    
  131.                                   (not (vl-position pol wpl))
  132.                              )
  133.                             (setq wpl (cons pol wpl)
  134.                                   ent (entmod (subst (cons 8 lay) (assoc 8 ent) ent))
  135.                                          
  136.                             )
  137.                          )
  138.                       )
  139.                       ((= etyp "LINE")
  140.                          (setq a (pos2d (cdr (assoc 10 ent)) pl fuzz)
  141.                                b (pos2d (cdr (assoc 11 ent)) pl fuzz)
  142.                          )      
  143.                          (if (and a b)
  144.                             (setq cdtl (cons (list a b) cdtl))
  145.                             (setq  nfl (cons (list a b)  nfl))
  146.                          )                       
  147.                       )                
  148.                    )
  149.                    (progress nil)
  150.                 )
  151.                
  152.               )
  153.             )
  154.             (setq cdtl (reverse cdtl))
  155.             (acet-ui-progress)
  156.  
  157.          (triangulate pl) ; Delaunay's Triangulation                          ;
  158.          
  159.          
  160.                
  161.          ;;                                                                   ;
  162.          ;; Insertion of Constraints                                          ;
  163.          ;;                                                                   ;
  164.  
  165.          (if cdtl
  166.             (progn
  167.                 (setq ti (time))
  168.                 (acet-ui-progress "Inserting Constraint:" (length cdtl))
  169.                 (foreach k cdtl
  170.                   (addedge (car k) (cadr k))
  171.                   (progress nil)
  172.                 )              
  173.                 (acet-ui-progress)
  174.                
  175.                 ;;                                                            ;
  176.                 ;; Erasing Triangles in Holes of Triangulation, and those     ;
  177.                 ;; Outside of the boundary. Adjusting Triangle List.          ;
  178.                 ;;                                                            ;
  179.                 ;; Notes: This is a fast hack where we select 3Dfaces with a  ;
  180.                 ;;        Crossing Polygon then Computes their Centroid and   ;
  181.                 ;;        remove those whose centroid is inside the poly.     ;
  182.                 ;;                                                            ;
  183.                 ;;        Will change it eventually to offset the polyline    ;
  184.                 ;;        to the outside by a few millimeters, and make the   ;
  185.                 ;;        Selection by Window Polygon.                        ;
  186.                 ;;                                                            ;
  187.                
  188.                 (vl-cmdf "_ZOOM" "_E")
  189.                 (if *bounden*
  190.                    (setq bp (distinct (mapcar '(lambda (a) (list (car a) (cadr a))) (listpol *bounden*))))
  191.                 )        
  192.                 (foreach wp wpl
  193.                    (setq  ss (ssget "_CP" wp '((0 . "3DFACE"))))
  194.                    (repeat (setq i (sslength ss))
  195.                       (setq  en (ssname ss (setq i (1- i)))
  196.                             ent (entget en)
  197.                              tp (list (cdr (assoc 11 ent))
  198.                                       (cdr (assoc 12 ent))
  199.                                       (cdr (assoc 13 ent))
  200.                                 )
  201.                              ct (centroid tp)
  202.                              in (ptinpoly_p ct (cons (last wp) wp))
  203.                       )
  204.                       (if (or
  205.                              (and in (not (equal wp bp)))
  206.                              (and (not in) (equal wp bp))
  207.                           )    
  208.                          (setq tr (list (vl-position  (car   tp) pl)
  209.                                         (vl-position  (cadr  tp) pl)
  210.                                         (vl-position  (caddr tp) pl)
  211.                                   )
  212.                                tl (vl-remove tr tl)
  213.                              3dfl (vl-remove en 3dfl)  
  214.                                ** (entdel en)
  215.                          )
  216.                       )                      
  217.                    )
  218.                    
  219.                    ;; Processing Boundary                                     ;
  220.                                      
  221.                 )    
  222.                 (vl-cmdf "_ZOOM" "_P")
  223.                 (vl-cmdf  "_DRAWORDER" ssb "" "_FRONT")
  224.                 (vl-cmdf "_regen")
  225.                 (princ (strcat "\n     CDT " version " - Elapsed time: " (rtos (- (time) ti) 2 3) " secs, " (itoa (length cdtl)) " Constraints"))
  226.                 (if nfl (princ (strcat "\nThere Were " (itoa (length nfl)) " Breakline Who Had An Endpoint Not In The Point Set.")))
  227.             )
  228.          )
  229.          
  230.          (if (= gocont "1")
  231.             (progn
  232.                (vla-endundomark *acdoc*)
  233.                (vla-startundomark *acdoc*)
  234.                (contour pl tl intv majcnt majcolor mincolor hfac)
  235.             )
  236.          )
  237.          (if (and (= gocont "1") (= golbl "1")) (c:lbl))
  238.        )    
  239.     )
  240.     (*error* nil)
  241.     (princ)
  242. )
  243.  
  244. (defun c:bound (/ sp tmp)
  245.    
  246.    (if (not csurf) (setq csurf "Natural Ground"))
  247.    (if (/= "" (setq tmp (getstring (strcat "\nCreates a Boundary for TIN <" csurf ">: "))))
  248.      (setq csurf tmp)
  249.    )  
  250.    (mk_layer (list "Boundary" 2))
  251.    (setq sp (butlast (cdr (assoc 10 (entget (car (entsel "\nSelect Start Point of Boundary: ")))))))
  252.    
  253.    (command "_3DPOLY" "NOD" sp)
  254.    (while (setq en (car (entsel "\nNext point on Boundary: ")))
  255.       (if (= (cdr (assoc 0 (setq ent (entget en)))) "POINT")
  256.         (command (cdr (assoc 10 ent)))
  257.       )
  258.    )  
  259.    (command "_c")
  260.    (setq *bounden* (entlast))
  261.    (princ)
  262. )
  263.  

Command c:bound will creates a 3dpoly and assign it to var *bounden*.

In processing the TIN the entity  *bounden* will be used as a breakline and
any external triangle will be deleted.

This might be slow as almost every triangle needs to be processed.

ymg


rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #498 on: December 02, 2015, 01:32:09 PM »
YMG,

Thanks for the new code... I didn't expect to see anything until after you have finished your standing project.

Unfortunately the code choked. It printed the following...

>>Command: tin
>>Select objects: Specify opposite corner: 418 found
>>Select objects:
>>Error: no function definition: PROGRESS

Maybe it refers to: (Progress nil). But that has always been in the code. I haven't known what it does. It looks like a function and a variable at the same time.

Rick


Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #499 on: December 02, 2015, 02:34:32 PM »
YMG,

I have tested it without creating a boundary...

>>Command: tin
>>Select objects: Specify opposite corner: 498 found
>>Select objects:
>>Error: no function definition: PROGRESS

It shows the same result.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #500 on: December 02, 2015, 02:43:45 PM »
YMG,

I restored the code to before the patch. It works as normal.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #501 on: December 02, 2015, 02:57:50 PM »
YMG,

I should mention that I have tried using 3dploy's as breaklines before and it hasn't worked.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #502 on: December 02, 2015, 03:18:49 PM »
Rick,

Sorry about that, this is a new routine to version 0.7.0 to be able
to have more than 32768 points.

Includes the following:

Code - Auto/Visual Lisp: [Select]
  1. (defun progress (div / **)
  2.    (cond
  3.       (div (if (zerop (setq count (1- count)))
  4.               (setq count div  ** (acet-ui-progress -1))
  5.            ))
  6.       (t (acet-ui-progress -1))
  7.    )    
  8. )
  9.  

Incidentally, I am making progress on c:flip, where contours will be
updated as you flip triangle.

ymg

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #503 on: December 02, 2015, 04:42:14 PM »
YMG,

Very good. It did it. But there were some exterior TIN's that were not contiguous with the boundary that it did not delete. As is, it cleaned up everything else with perfection.

As for operation... The use of "NOD" with 3dpoly does not elicit a snap. The cursor is in entity mode (just a square), and no snap can be activated.

Likewise a grdraw function would be good because the screen needs to be zoomed and panned many times before you finished the boundary. It can get confusing as to where the last point was.

Also you did not have the osnapz mode activated. I plugged it in to the code (using grdmod grdval as variables)...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:bound (/ sp tmp grdmod grdval) ;; could be changed to C:BND  for 3 letter convenience
  2.    (if (not csurf) (setq csurf "Natural Ground"))
  3.    (if (/= "" (setq tmp (getstring (strcat "\nCreates a Boundary for TIN <" csurf ">: "))))
  4.        (setq csurf tmp)
  5.        )  
  6.    (mk_layer (list "Boundary" 2))
  7.    
  8.    (setq grdval (getvar "elevation")) ; save preset elevation (normally 0.0)
  9.    (setq grdmod (getvar "OSNAPZ")) ; save elevation snap-mode
  10.    (setvar "OSNAPZ" 0) ; set snap to object-grade
  11.            
  12.    (setq sp (butlast (cdr (assoc 10 (entget (car (entsel "\nSelect Start Point of Boundary: ")))))))
  13.           ;; butlast, Returns the list with last item removed.                       ;
  14.    (command "_3DPOLY" sp) ;; was (command "_3DPOLY" "NOD" sp)
  15.    (while (setq en (car (entsel "\nNext point on Boundary: ")))
  16.           (if (= (cdr (assoc 0 (setq ent (entget en)))) "POINT")
  17.               (command (cdr (assoc 10 ent)))
  18.               )
  19.           )  
  20.    (command "_c")    
  21.    (setq *bounden* (entlast))
  22.    
  23.    (setvar "OSNAPZ" grdmod) ; restore elevation snap-mode
  24.    (setvar "elevation" grdval) ; restore preset-elevation (normally 0.0)
  25.    
  26.    (princ)
  27. ) ;; end BOUND

If the user messes up it would be nice to have a function for manually selecting multiple 3dpoly's, merge and close them, move it to the correct layer, and set the *bounden* variable... as if it had been done by BOUND. I can see people clicking a wrong thing and having to start over from the start (maybe several times).

It certainly got the job done. Thanks.


EDIT: Added Code tags. - John
« Last Edit: December 03, 2015, 02:52:22 PM by John Kaul (Se7en) »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #504 on: December 02, 2015, 04:56:48 PM »
Rick,

I do have a function to merge join 3dpoly, although it is not in the proggie.

Right now, it is a fast hack. Where we set global variable *bounden* to
the entity name of the external boundary.

This will most probably cause trouble if we want to have more than one TIN
in a drawing.

An alternate way, would be to draw external's boundary clockwise
and island's boundary counterclockwise.  Any other closed poly with
points inside would be a breaklines.

Not too enthusiastic on grdraw to pick the points.

Same feelings about non-contiguous TIN

ymg
« Last Edit: December 02, 2015, 05:21:15 PM by ymg »

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #505 on: December 03, 2015, 07:51:07 AM »
YMG,

I agree that the exterior island TIN's are a non issue. They can be handled manually. I got them in my selection because I was purposely being sloppy.

The clock and counter boundaries sound like a reasonable and beneficial addition.

But on the grdraw, implementing the same method as FLBL would be an advantage. The Undo option would keep a user from busting his poly and restarting. Furthermore there wouldn't be a need to patch broken poly's together, which I now think would not be a great idea. Drawing discipline is a better notion.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #506 on: December 03, 2015, 10:58:26 AM »
YMG,

Try the following. I have named it BND to differ from yours, and I have added (MK_BND) to facilitate a closed poly. It lets you snap to nodes, and it does the grdraw. It senses if the poly is closed, and closes if not. I haven't included an *error* routine however, and it might need some help. The errors were getting in my way.

Code - Auto/Visual Lisp: [Select]
  1. ;; begin patch
  2. (defun mk_bnd (L / x)
  3.    (if (equal (car L) (last L) 0.001)
  4.        () ;; do nothing
  5.        (setq L (append L (list (car L)))) ;; close the poly
  6.        )          
  7.    (en2obj
  8.       (if (and (> (length L) 1)
  9.                (entmakex (list '(0 . "POLYLINE") '(10 0. 0. 0.) '(70 . 8)))
  10.                (foreach x L (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32)))) ;; was (70 . 32)
  11.           )
  12.          (cdr (assoc 330 (entget (entmakex '((0 . "SEQEND"))))))
  13.       )
  14.    )
  15. )
  16.  
  17. (defun c:bnd (/ sp tmp grdmod grdval plst get_bnd) ;; was c:bound
  18.    (if (not csurf) (setq csurf "Natural Ground"))
  19.    (if (/= "" (setq tmp (getstring (strcat "\nCreate a Boundary for TIN <" csurf ">: "))))
  20.        (setq csurf tmp)
  21.        )  
  22.    (mk_layer (list "Boundary" 2))
  23.    
  24.    (setq grdval (getvar "elevation")) ; save preset elevation (normally 0.0)
  25.    (setq grdmod (getvar "OSNAPZ")) ; save elevation snap-mode
  26.    (setvar "OSNAPZ" 0) ; set snap to object-grade
  27.            
  28.    (defun get_bnd (/ lst pt)
  29.       (if (car (setq lst (list (getpoint "\nSpecify first Boundary point: ")))) ;; if test
  30.           (progn
  31.              (while (setq pt
  32.                                 (if (> (length lst) 1)
  33.                         (progn
  34.                                           (initget "Undo")
  35.                                           (getpoint (car lst) "\nSpecify next Boundary point [Undo]: ")
  36.                                       ) ;; end if=yes
  37.                         (getpoint (car lst) "\nSpecify next Boundary point: ")
  38.                         ) ;; end if length
  39.                     ) ;; end while test
  40.                     (redraw)
  41.                     (mapcar '(lambda (a b) (grdraw a b 1 1)) (setq lst (if (eq pt "Undo") (cdr lst) (cons pt lst))) (cdr lst))
  42.               ) ;; end while
  43.             (cond ((> (length lst) 1) lst))                    
  44.             ) ;; end progn if=yes
  45.            ) ; end if
  46.       ) ;; end _getpoints  
  47.  
  48.    (if (setq plst (get_bnd)) ;; use _getpoints
  49.        (progn (mk_bnd plst)
  50.                   (setq *bounden* (entlast))
  51.                           (redraw)
  52.                           )
  53.            )
  54.  
  55.    (setvar "OSNAPZ" grdmod) ; restore elevation snap-mode
  56.    (setvar "elevation" grdval) ; restore preset-elevation (normally 0.0)
  57.  
  58.    (princ)
  59. ) ;; end BND
  60. ;; end *upgrade patch*


EDIT: Added code tags. - John
« Last Edit: December 03, 2015, 02:53:22 PM by John Kaul (Se7en) »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #507 on: December 03, 2015, 11:02:28 AM »
YMG,

The smiley face in the above is an 8. I'm not smart about forum stuff.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #508 on: December 03, 2015, 02:41:40 PM »
YMG,

I think I found what was creating *errors*. I assume it was due to MK_BND trying to create VLAX objects.

This is my former code (renamed as mk_bnd_old)...

Code - Auto/Visual Lisp: [Select]
  1. (defun mk_bnd_old (L / x)
  2.    (if (equal (car L) (last L) 0.001)
  3.        () ;; do nothing
  4.            (setq L (append L (list (car L)))) ;; close the poly
  5.        )          
  6.    (en2obj
  7.       (if (and (> (length L) 1)
  8.                (entmakex (list '(0 . "POLYLINE") '(10 0. 0. 0.) '(70 . 8)))
  9.                (foreach x L (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32)))) ;; was (70 . 32)
  10.           )
  11.          (cdr (assoc 330 (entget (entmakex '((0 . "SEQEND"))))))
  12.       )
  13.    )
  14. )

This is with the VLAX functions removed...

Code - Auto/Visual Lisp: [Select]
  1. (defun mk_bnd (L / x)
  2.    (if (equal (car L) (last L) 0.001)
  3.        () ;; do nothing
  4.            (setq L (append L (list (car L)))) ;; close the poly
  5.        )          
  6.    (if (and (> (length L) 1)
  7.             (entmake (list '(0 . "POLYLINE") '(10 0. 0. 0.) '(70 . 8)))
  8.             (foreach x L (entmake (list '(0 . "VERTEX") (cons 10 x) '(70 . 32))))
  9.             )
  10.        (entmake '((0 . "SEQEND")))
  11.        )
  12. )

Both create the 3d polyline, but I am assuming the latter is better. Everything I have done is simply to refit your own codes to this situation.

Rick

EDIT: Added code tags. - John
« Last Edit: December 03, 2015, 02:54:32 PM by John Kaul (Se7en) »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ronjonp

  • Needs a day job
  • Posts: 7524
Re: Triangulation (re-visited)
« Reply #509 on: December 03, 2015, 02:44:23 PM »
RW2691,

Please read this thread about formatting code in your posts.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC