Jump to content

Recommended Posts

Posted

The land measure company just sended me a file of a field they marked on the site.

As you can see in the picture below the yellow polyline contains many grips.

Because of all the grips my whole drawing is very slow and when i want to hatch the polyline and trim in it it takes minutes to load.

My question is how can i change the polyline so i can easily hatch and trim it without waiting that long.

Im using autocad 2014 and still learning it.

 

igxo5h.png

dbi78n.png

Posted

i assume you cannot trace over it easily? the problem is that if you want fewer grips, you have to lose accuracy in the drawing. i do not know a way to tell autocad to just 'reduce number of grips', but if you trace roughly over it you can choose how accurate you want it

Posted

You could try to use the Express Tools command OVERKILL on the polyline to simplify it.

 

If that doesn't work here's a LISP routine I found a while ago:

 

;;;  PLDIET.lsp [command name: PLD]
;;;  To put lightweight PolyLines on a DIET (remove excess vertices); usually
;;;    used for contours with too many too-closely-spaced vertices.
;;;  Concept from PVD routine [posted on AutoCAD Customization Discussion
;;;    Group by oompa_l, July 2009] by Brian Hailey, added to by CAB, and
;;;    WEED and WEED2 routines by Skyler Mills at Cadalyst CAD Tips [older
;;;    routines for "heavy" Polylines that won't work on newer lightweight ones];
;;;    simplified in entity data list processing, and enhanced in other ways [error
;;;    handling, default values, join collinear segments beyond max. distance,
;;;    limit to current space/tab, account for change in direction across 0 degrees,
;;;    option to keep or eliminate arc segments] by Kent Cooper, August 2009.
;
(defun C:PLD
 (/ *error* cmde disttemp cidtemp arctemp plinc plsel pldata
 ucschanged front 10to42 vinc verts vert1 vert2 vert3)
;
 (defun *error* (errmsg)
   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort"))
     (princ (strcat "\nError: " errmsg))
   ); end if
   (if ucschanged (command "_.ucs" "_prev"))
     ; ^ i.e. don't go back unless routine reached UCS change but didn't change back
   (command "_.undo" "_end")
   (setvar 'cmdecho cmde)
 ); end defun - *error*
;
 (setq cmde (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (command "_.undo" "_begin")
 (setq
   disttemp
     (getdist
       (strcat
         "\nMaximum distance between non-collinear vertices to straighten"
         (if *distmax* (strcat " <" (rtos *distmax* 2 2) ">") ""); default only if not first use
         ": "
       ); end strcat
     ); end getdist & disttemp
   *distmax*
     (cond
       (disttemp); user entered number or picked distance
       (T *distmax*); otherwise, user hit Enter - keep value
     ); end cond & *distmax*
   cidtemp
     (getangle
       (strcat
         "\nMaximum change in direction to straighten"
         (strcat ; offer prior choice if not first use; otherwise 15 degrees
           " <"
           (if *cidmax* (angtos *cidmax*) (angtos (/ pi 12)))
           ">"
         ); end strcat
         ": "
       ); end strcat
     ); end getdist & cidtemp
   *cidmax*
     (cond
       (cidtemp); user entered number or picked angle
       (*cidmax*); Enter with prior value set - use that
       (T (/ pi 12)); otherwise [Enter on first use] - 15 degrees
     ); end cond & *cidmax*
   plinc 0 ; incrementer through selection set of Polylines
 ); end setq
 (initget "Retain Straighten")
 (setq
   arctemp
     (getkword
       (strcat
         "\nRetain or Straighten arc segments [R/S] <"
         (if *arcstr* (substr *arcstr* 1 1) "S"); at first use, S default; otherwise, prior choice
         ">: "
       ); end strcat
     ); end getkword
   *arcstr*
     (cond
       (arctemp); if User typed something, use it
       (*arcstr*); if Enter and there's a prior choice, keep that
       (T "Straighten"); otherwise [Enter on first use], Straighten
     ); end cond & *arcstr*
 ); end setq
;
 (prompt "\nSelect LWPolylines to put on a diet, or press Enter to select all: ")
 (cond
   ((setq plsel (ssget '((0 . "LWPOLYLINE"))))); user-selected Polylines
   ((setq plsel (ssget "X" (list '(0 . "LWPOLYLINE") (cons 410 (getvar 'ctab))))))
     ; all Polylines [in current space/tab only]
 ); end cond
;
 (repeat (sslength plsel)
   (setq pldata (entget (ssname plsel plinc)))
   (if (/= (cdr (last pldata)) (trans '(0 0 1) 1 0)); extr. direction not parallel current CS
       ; for correct angle & distance calculations [projected onto current construction
       ; plane], since 10-code entries for LWPolylines are only 2D points:
     (progn
       (command "_.ucs" "_new" "_object" (ssname plsel plinc)) ; set UCS to match object
       (setq ucschanged T) ; marker for *error* to reset UCS if routine doesn't
     ); end progn
   ); end if
   (setq
     front ; list of "front end" [pre-vertices] entries, minus entity names & handle
       (vl-remove-if
         '(lambda (x)
           (member (car x) '(-1 330 5 10 40 41 42 210))
         ); end lambda
         pldata
       ); end removal & front
     10to42 ; list of all code 10, 40, 41, 42 entries only
       (vl-remove-if-not
         '(lambda (x)
           (member (car x) '(10 40 41 42))
         ); end lambda
         pldata
       ); end removal & 10to42
     vinc (/ (length 10to42) 4); incrementer for vertices within each Polyline
     verts nil ; eliminate from previous Polyline [if any]
   ); end setq
   (if (= *arcstr* "Straighten")
     (progn
       (setq bulges ; find any bulge factors
         (vl-remove-if-not
           '(lambda (x)
             (and
               (= (car x) 42)
               (/= (cdr x) 0.0)
             ); end and
           ); end lambda
           10to42
         ); end removal & bulges
       ); end setq
       (foreach x bulges (setq 10to42 (subst '(42 . 0.0) x 10to42)))
         ; straighten all arc segments to line segments
     ); end progn
   ); end if
   (repeat vinc
     (setq
       verts ; sub-group list: separate list of four entries for each vertex
         (cons
           (list
             (nth (- (* vinc 4) 4) 10to42)
             (nth (- (* vinc 4) 3) 10to42)
             (nth (- (* vinc 4) 2) 10to42)
             (nth (1- (* vinc 4)) 10to42)
           ); end list
           verts
         ); end cons & verts
       vinc (1- vinc) ; will be 0 at end
     ); end setq
   ); end repeat
   (while (nth (+ vinc 2) verts); still at least 2 more vertices
     (if
       (or ; only possible if chose to Retain arc segments
         (/= (cdr (assoc 42 (nth vinc verts))) 0.0); next segment is arc
         (/= (cdr (assoc 42 (nth (1+ vinc) verts))) 0.0); following segment is arc
       ); end or
       (setq vinc (1+ vinc)); then - don't straighten from here; move to next
       (progn ; else - analyze from current vertex
         (setq
           vert1 (cdar (nth vinc verts)) ; point-list location of current vertex
           vert2 (cdar (nth (1+ vinc) verts)); of next one
           vert3 (cdar (nth (+ vinc 2) verts)); of one after that
           ang1 (angle vert1 vert2)
           ang2 (angle vert2 vert3)
         ); end setq
         (if
           (or
             (equal ang1 ang2 0.0001); collinear, ignoring distance
             (and
               (<= (distance vert1 vert3) *distmax*)
                 ; straightens if direct distance from current vertex to two vertices later is
                 ; less than or equal to maximum; if preferred to compare distance along
                 ; Polyline through intermediate vertex, replace above line with this:
                 ; (<= (+ (distance vert1 vert2) (distance vert2 vert3)) *distmax*)
               (<=
                 (if (> (abs (- ang1 ang2)) pi); if difference > 180 degrees
                   (+ (min ang1 ang2) (- (* pi 2) (max ang1 ang2)))
                     ; then - compensate for change in direction crossing 0 degrees
                   (abs (- ang1 ang2)); else - size of difference
                 ); end if
                 *cidmax*
               ); end <=
             ); end and
           ); end or
           (setq verts (vl-remove (nth (1+ vinc) verts) verts))
             ; then - remove next vertext, stay at current vertex for next comparison
           (setq vinc (1+ vinc)); else - leave next vertex, move to it as new base
         ); end if - distance & change in direction analysis
       ); end progn - line segments
     ); end if - arc segment check
   ); end while - working through vertices
   (setq
     front (subst (cons 90 (length verts)) (assoc 90 front) front)
       ; update quantity of vertices for front end
     10to42 nil ; clear original set
   ); end setq
   (foreach x verts (setq 10to42 (append 10to42 x)))
     ; un-group four-list vertex sub-lists back to one list of all 10, 40, 41, 42 entries
   (setq pldata (append front 10to42 (list (last pldata))))
     ; put front end, vertex entries and extrusion direction back together
   (entmake pldata)
   (entdel (ssname plsel plinc)); remove original
   (setq plinc (1+ plinc)); go on to next Polyline
   (if ucschanged
     (progn
       (command "_.ucs" "_prev")
       (setq ucschanged nil) ; eliminate UCS reset in *error* since routine did it already
     ); end progn
   ); end if - UCS reset
 ); end repeat - stepping through set of Polylines
 (command "_.undo" "_end")
 (setvar 'cmdecho cmde)
 (princ)
); end defun - PLD
(prompt "\nType PLD to put PolyLines on a Diet.")

Posted

I don't believe that OVERKILL will help (although I use it all the time, and really like it),

because this appears to be a single polyline.

 

But, since I like the command, and you suggested it, I thought it worth checking out,

but on my example it deleted nothing. I always enjoy when I use it and see that it has deleted

hundreds of redundant lines.

 

The lisp that you have provided though looks like the perfect solution. :beer:

Posted
The lisp that you have provided though looks like the perfect solution. :beer:

 

I've not tested it, but it looked like it could one day come in useful.

Posted (edited)

Thanks for the reactions. I tried the command OVERKILL it removed a lot of things but the polyline is still slow and has many grips:

Command: OVERKILL

Select objects: 1 found

Select objects:

0 duplicate(s) deleted

535 overlapping object(s) or segment(s) deleted

 

I tried the lisp, it works for a normal polyline. But not at the ones where it needs to work.

Maybe because the normal polyline is named "Polyline" and the ones that dont work are "2D Polyline"

Edited by roykes001
Posted (edited)

Thanks for the link. Its how i received the drawing. Tried that lisp from the link too: 1619 verticies removed out of 1620 tested (99.94) percent

But i dont see any grips removed.

 

This is the download link for my drawing:

http://we.tl/swrnbwYc50

Edited by roykes001
Posted
and the ones that dont work are "2D Polyline"

 

You can convert a 2D polyline into a normal polyline (LWPOLY) by entering the commmand in the command line "CONVERTPOLY" (without the quotation marks) and selecting the "thin" option. Once you have done that run the LISP routine again. To convert LWPolylines to 2D polylines select the "thick" option.

Posted (edited)

i changed the 2dpolyline to a Lwpolyline. Tried the lisp that you gave me tyke. It removed my Lwpolyline.

Than i tried the lisp that is in the link that nestly gave me, that lisp says: That's not a LINE or POLYLINE, it's a LWPOLYLINE.

 

EDIT: It worked. i got less grips now, had to try a little bit more with the numbers i have to fill in your lisp.

 

So the answer is:

Convertpoly->light

Load lisp->PLD->number->number->S

Edited by roykes001

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...