Jump to content

Q. Trimming multiple polylines


SteveK

Recommended Posts

I have to draw grey lines in a profile and trim them as shown in the first attached jpeg.

 

The different coloured lines are polylines. Basically EXTRIM does half a job because it won't let you select multiple polylines.

 

Using modified code posted in the thread "Polyline Vertices" I've had a go at making something for a single horizontal line.

 

Basically this code finds all the intersections along a single selected horizontal line then draws new lines every 2 intersections, then deletes old line.

 

    ;; NOTE: to work you must select all PLINES in order from left to right...

(defun massoc (key alist / nlist)
 (foreach x alist
   (if (eq key (car x))
       (setq nlist (cons (cdr x) nlist))))
 (reverse nlist))

;;;MAIN PROGRAM

(defun c:int (/ ss en ed pl fl ln_ent ln ln_pt1 ln_pt2 int_list int_pt1 int_pt2 new_line)

;;;SPECIFY HORIZONTAL LINE
 (setq ln_ent (car (entsel "\nSelect Horizontal Line"))
       ln (entget ln_ent)
       ln_pt1 (cdr (assoc 10 ln))
   ln_pt2 (cdr (assoc 11 ln)))
 
;;;SELECT 1 LWPOLYINE
 (princ "\nSelect A LWPOLYLINE To Work With:  ")
 (setq ss (ssget '((0 . "LWPOLYLINE"))))

;;;GET ENTITY DEFINITION
 (setq i -1)
 (while (setq en (ssname ss (setq i (1+ i))))
   (progn
     (setq ed (entget en)
               pl (append pl (massoc 10 ed)))
   ))

;;;SETUP POINT LISTS FOR CAMPARISION
 (setq fl (list (car pl))
       pl (cdr pl))

;;;GET INTERSECTIONS AND MAKE NEW LINE
 (while pl
     (if (not (equal (car fl) (car pl)))
   (progn
     (Cond ((inters (car fl) (car pl) ln_pt1 ln_pt2)
        (setq int_list (cons (inters (car fl) (car pl) ln_pt1 ln_pt2) int_list)) ;Create Intersections List
        )
       )
         (setq fl (cons (car pl) fl))
   ))
     (setq pl (cdr pl))
   )

 (setq fl (reverse fl))
 (setq int_list (reverse int_list))

;;;CLEANUP THE DRAWING
 (redraw (entlast))

;;;MAKE NEW LINES
 (while int_list
   (setq int_pt1 (car int_list)
     int_pt2 (cadr int_list))
   ; Make new line
   (if (AND int_pt1 int_pt2)
     (progn
       (setq new_line (list (cons 0 "LINE") ; type
                (cons 8 "Profile") ; layer
                (cons 10 int_pt1) ; first point
                (cons 11 int_pt2) ; second point
                (cons 62  ; text color - yellow = 2, white = 7
            )
       )
       (entmake new_line)
     )) ; End If
   (setq int_list (cddr int_list))
   )

;;;DELETE OLD LINE
(entdel ln_ent)

(princ)) 

When the code is correct I was going to have the program create the horizontal lines and apply this code to each one.

 

Problems at the moment:

  • I have to select the polylines in order. This is a problem because eventually I want to automatically select these plines filtering layer "Ground Line".
  • If the initial line in the first polyline goes from top-let to bottom-right the lines drawn will be the opposite of what I want (see second image (Profile2)).

Is this the best solution to this problem do you think?

Thanks guys for any help.

Attached Images attachment.php?attachmentid=12827&stc=1&d=1246245669 attachment.php?attachmentid=12828&stc=1&d=1246245678

Link to comment
Share on other sites

  • Replies 34
  • Created
  • Last Reply

Top Posters In This Topic

  • SteveK

    15

  • Lee Mac

    14

  • brawleyman

    4

  • fuqua

    2

Top Posters In This Topic

Posted Images

Try this mate ~ a different approach :)

 

(defun c:Int  (/ lne lObj ss int Objlst par lst ang)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (while
   (progn
     (setq lne (car (entsel "\nSelect Horizontal Line: ")))
     (cond ((eq 'ENAME (type lne))
            (if (eq "LINE" (dxf 0 lne))
              (if (zerop (- (cadr (dxf 11 lne)) (cadr (dxf 10 lne))))
                (progn
                  (setq lObj (vlax-ename->vla-object lne))
                  nil)
                (princ "\n** Line is not Horizontal **"))
              (princ "\n** Object is not a Line **")))
           (t (princ "\n** Nothing Selected **")))))

 (princ "\nSelect Polylines: ")
 (while (not ss)
   (setq ss (ssget '((0 . "LWPOLYLINE")))))

 (setq int
   (vl-sort
     (apply 'append
       (vl-remove-if 'null
         (mapcar
           (function
             (lambda (Obj)
               (vlax-lst->3D-point
                 (vlax-invoke lObj
                   'Intersectwith Obj acExtendNone))))
                      (setq Objlst
                        (mapcar 'vlax-ename->vla-object
                          (vl-remove-if 'listp
                            (mapcar 'cadr (ssnamex ss))))))))
             (function
               (lambda (a b)
                 (< (car a) (car b))))) lst Objlst)

 (while
   (and (setq Obj (car lst))
        (not
          (setq par
            (vlax-curve-getParamatPoint Obj (car int)))))
    (setq lst (cdr lst)))
 (setq ang
   (angle '(0 0 0)
     (vlax-curve-getFirstDeriv Obj par)))
 (if (or (< (/ pi 2.) ang pi)
         (< (/ (* 3 pi) 2.) ang))
   (setq int (cdr int)))

 (setq lst Objlst)
 (while
   (and (setq Obj (car lst))
        (not
          (setq par
            (vlax-curve-getParamatPoint Obj (last int)))))
    (setq lst (cdr lst)))
 (setq ang
   (angle '(0 0 0)
     (vlax-curve-getFirstDeriv Obj par)))
 (if (or (> (/ pi 2.) ang 0.)
         (< pi ang (/ (* 3 pi) 2.)))
   (setq int
     (reverse
       (cdr
         (reverse int)))))
 (setq int
   (mapcar 'vlax-3D-point int))

 (while (cadr int)
   (vla-addLine spc
     (car int) (cadr int))
   (setq int (cddr int)))

 (vla-delete lObj)
 (princ))


(defun dxf  (code ent)
 (cdr (assoc code (entget ent))))

(defun vlax-lst->3D-point  (lst)
 (if lst
   (cons (list (car lst) (cadr lst) (caddr lst))
         (vlax-lst->3D-point (cdddr lst)))))


 

Polylines don't have to be selected in order :P

Link to comment
Share on other sites

As expected it works great. Thanks mate ;)

If only I understood vlisp! well I downloaded the "The VLISP Developer's Bible" so maybe one day I will...

Now here's hoping with all this vlisp it won't matter if I plug it into autolisp code.

Link to comment
Share on other sites

As expected it works great. Thanks mate ;)

If only I understood vlisp! well I downloaded the "The VLISP Developer's Bible" so maybe one day I will...

Now here's hoping with all this vlisp it won't matter if I plug it into autolisp code.

 

Yay :) I'm glad it works for you.

 

Lee

Link to comment
Share on other sites

Ok so it was fairly easy to use the code and apply it to selection sets. Here it is if anyone else is interested:

 

(defun c:Int2  (/ i lne lObj ss_GL ss_grey_lines int Objlst par lst ang)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (If (setq ss_grey_lines (ssget "X" (list (cons 0 "LINE") (cons 8 "Profile") (cons 62 )))
   (Progn
     (If (setq ss_GL (ssget "X" (list (cons 0 "POLYLINE") (cons 8 "Ground Line Profile"))))
   (Progn

 (setq i -1)
     (while (setq lne (ssname ss_grey_lines (setq i (1+ i))))
   (setq lObj (vlax-ename->vla-object lne))
   
;;;  (while
;;;    (progn
;;;      (setq lne (car (entsel "\nSelect Horizontal Line: ")))
;;;      (cond ((eq 'ENAME (type lne))
;;;             (if (eq "LINE" (dxf 0 lne))
;;;               (if (zerop (- (cadr (dxf 11 lne)) (cadr (dxf 10 lne))))
;;;                 (progn
;;;                   (setq lObj (vlax-ename->vla-object lne))
;;;                   nil)
;;;                 (princ "\n** Line is not Horizontal **"))
;;;               (princ "\n** Object is not a Line **")))
;;;            (t (princ "\n** Nothing Selected **")))))

 (setq int
   (vl-sort
     (apply 'append
       (vl-remove-if 'null
         (mapcar
           (function
             (lambda (Obj)
               (vlax-lst->3D-point
                 (vlax-invoke lObj
                   'Intersectwith Obj acExtendNone))))
                      (setq Objlst
                        (mapcar 'vlax-ename->vla-object
                          (vl-remove-if 'listp
                            (mapcar 'cadr (ssnamex ss_GL))))))))
             (function
               (lambda (a b)
                 (< (car a) (car b))))) lst Objlst)

 (while
   (and (setq Obj (car lst))
        (not
          (setq par
            (vlax-curve-getParamatPoint Obj (car int)))))
    (setq lst (cdr lst)))
 (setq ang
   (angle '(0 0 0)
     (vlax-curve-getFirstDeriv Obj par)))
 (if (or (< (/ pi 2.) ang pi)
         (< (/ (* 3 pi) 2.) ang))
   (setq int (cdr int)))

 (setq lst Objlst)
 (while
   (and (setq Obj (car lst))
        (not
          (setq par
            (vlax-curve-getParamatPoint Obj (last int)))))
    (setq lst (cdr lst)))
 (setq ang
   (angle '(0 0 0)
     (vlax-curve-getFirstDeriv Obj par)))
 (if (or (> (/ pi 2.) ang 0.)
         (< pi ang (/ (* 3 pi) 2.)))
   (setq int
     (reverse
       (cdr
         (reverse int)))))
 (setq int
   (mapcar 'vlax-3D-point int))

 (while (cadr int)
   (vla-addLine spc
     (car int) (cadr int))
   (setq int (cddr int)))

 (vla-delete lObj)

   ) ; End While

 )(Princ "Layer \"Ground Line Profile\" not found"))
     )(Princ "Grey Lines not found"))
 (princ))


(defun dxf  (code ent)
 (cdr (assoc code (entget ent))))

(defun vlax-lst->3D-point  (lst)
 (if lst
   (cons (list (car lst) (cadr lst) (caddr lst))
         (vlax-lst->3D-point (cdddr lst)))))

 

The one thing I've noticed is it changes the horizontal lines to whatever is the current layer and color. I've yet to get around to deciphering visualLisp so can you show me the quick fix? I'm wanting the lines to remain in the colour they are, which is "Profile" layer, color 8.

Thanks

Link to comment
Share on other sites

Ok so it was fairly easy to use the code and apply it to selection sets. Here it is if anyone else is interested:

 

(defun c:Int2  (/ i lne lObj ss_GL ss_grey_lines int Objlst par lst ang)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (If (setq ss_grey_lines (ssget "X" (list (cons 0 "LINE") (cons 8 "Profile") (cons 62 )))
   (Progn
     (If (setq ss_GL (ssget "X" (list (cons 0 "POLYLINE") (cons 8 "Ground Line Profile"))))
   (Progn

 (setq i -1)
     (while (setq lne (ssname ss_grey_lines (setq i (1+ i))))
   (setq lObj (vlax-ename->vla-object lne))
   
;;;  (while
;;;    (progn
;;;      (setq lne (car (entsel "\nSelect Horizontal Line: ")))
;;;      (cond ((eq 'ENAME (type lne))
;;;             (if (eq "LINE" (dxf 0 lne))
;;;               (if (zerop (- (cadr (dxf 11 lne)) (cadr (dxf 10 lne))))
;;;                 (progn
;;;                   (setq lObj (vlax-ename->vla-object lne))
;;;                   nil)
;;;                 (princ "\n** Line is not Horizontal **"))
;;;               (princ "\n** Object is not a Line **")))
;;;            (t (princ "\n** Nothing Selected **")))))

 (setq int
   (vl-sort
     (apply 'append
       (vl-remove-if 'null
         (mapcar
           (function
             (lambda (Obj)
               (vlax-lst->3D-point
                 (vlax-invoke lObj
                   'Intersectwith Obj acExtendNone))))
                      (setq Objlst
                        (mapcar 'vlax-ename->vla-object
                          (vl-remove-if 'listp
                            (mapcar 'cadr (ssnamex ss_GL))))))))
             (function
               (lambda (a b)
                 (< (car a) (car b))))) lst Objlst)

 (while
   (and (setq Obj (car lst))
        (not
          (setq par
            (vlax-curve-getParamatPoint Obj (car int)))))
    (setq lst (cdr lst)))
 (setq ang
   (angle '(0 0 0)
     (vlax-curve-getFirstDeriv Obj par)))
 (if (or (< (/ pi 2.) ang pi)
         (< (/ (* 3 pi) 2.) ang))
   (setq int (cdr int)))

 (setq lst Objlst)
 (while
   (and (setq Obj (car lst))
        (not
          (setq par
            (vlax-curve-getParamatPoint Obj (last int)))))
    (setq lst (cdr lst)))
 (setq ang
   (angle '(0 0 0)
     (vlax-curve-getFirstDeriv Obj par)))
 (if (or (> (/ pi 2.) ang 0.)
         (< pi ang (/ (* 3 pi) 2.)))
   (setq int
     (reverse
       (cdr
         (reverse int)))))
 (setq int
   (mapcar 'vlax-3D-point int))

 (while (cadr int)
   (vla-addLine spc
     (car int) (cadr int))
   (setq int (cddr int)))

 (vla-delete lObj)

   ) ; End While

 )(Princ "Layer \"Ground Line Profile\" not found"))
     )(Princ "Grey Lines not found"))
 (princ))


(defun dxf  (code ent)
 (cdr (assoc code (entget ent))))

(defun vlax-lst->3D-point  (lst)
 (if lst
   (cons (list (car lst) (cadr lst) (caddr lst))
         (vlax-lst->3D-point (cdddr lst)))))

The one thing I've noticed is it changes the horizontal lines to whatever is the current layer and color. I've yet to get around to deciphering visualLisp so can you show me the quick fix? I'm wanting the lines to remain in the colour they are, which is "Profile" layer, color 8.

Thanks

 

Nice one Steve for having a shot at modifying it yourself :thumbsup:

 

I'll help you out with it :)

Link to comment
Share on other sites

This should work Steve, although it doesn't have much in the way of error trapping (like checking that the lines are horizontal etc..), this can be added if necessary.

 

Also, bear in mind you are only collecting POLYLINES, and not LWPOLYLINES also, just wanted to make you aware of this as I was not sure if this was your intention or not.

 

(defun c:Int  (/ doc spc ss_grey ss_gl lne
                lObj ss int Objlst par lst ang)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (if (setq ss_grey
       (ssget "_X" '((0 . "LINE") (8 . "Profile") (62 . )))
   (if (setq ss_gl
         (ssget "_X" '((0 . "POLYLINE") (8 . "Ground Line Profile"))))
     (foreach lObj (mapcar 'vlax-ename->vla-object
                     (mapcar 'cadr (ssnamex ss_grey)))  

;;;  (while
;;;    (progn
;;;      (setq lne (car (entsel "\nSelect Horizontal Line: ")))
;;;      (cond ((eq 'ENAME (type lne))
;;;             (if (eq "LINE" (dxf 0 lne))
;;;               (if (zerop (- (cadr (dxf 11 lne)) (cadr (dxf 10 lne))))
;;;                 (progn
;;;                   (setq lObj (vlax-ename->vla-object lne))
;;;                   nil)
;;;                 (princ "\n** Line is not Horizontal **"))
;;;               (princ "\n** Object is not a Line **")))
;;;            (t (princ "\n** Nothing Selected **")))))
;;;
;;;  (princ "\nSelect Polylines: ")
;;;  (while (not ss)
;;;    (setq ss (ssget '((0 . "LWPOLYLINE")))))

       (setq int
         (vl-sort
           (apply 'append
             (vl-remove-if 'null
               (mapcar
                 (function
                   (lambda (Obj)
                     (vlax-lst->3D-point
                       (vlax-invoke lObj
                         'Intersectwith Obj acExtendNone))))
                            (setq Objlst
                              (mapcar 'vlax-ename->vla-object
                                (vl-remove-if 'listp
                                  (mapcar 'cadr (ssnamex ss))))))))
                   (function
                     (lambda (a b)
                       (< (car a) (car b))))) lst Objlst)

       (while
         (and (setq Obj (car lst))
              (not
                (setq par
                  (vlax-curve-getParamatPoint Obj (car int)))))
          (setq lst (cdr lst)))
       (setq ang
         (angle '(0 0 0)
           (vlax-curve-getFirstDeriv Obj par)))
       (if (or (< (/ pi 2.) ang pi)
               (< (/ (* 3 pi) 2.) ang))
         (setq int (cdr int)))

       (setq lst Objlst)
       (while
         (and (setq Obj (car lst))
              (not
                (setq par
                  (vlax-curve-getParamatPoint Obj (last int)))))
          (setq lst (cdr lst)))
       (setq ang
         (angle '(0 0 0)
           (vlax-curve-getFirstDeriv Obj par)))
       (if (or (> (/ pi 2.) ang 0.)
               (< pi ang (/ (* 3 pi) 2.)))
         (setq int
           (reverse
             (cdr
               (reverse int)))))
       (setq int
         (mapcar 'vlax-3D-point int))

       (while (cadr int)
         (setq nLne
           (vla-addLine spc
             (car int) (cadr int)))
         (vla-put-layer nLne "Profile")
           (vla-put-color nLne 
         (setq int (cddr int)))

       (vla-delete lObj))
     (princ "\n<< No Polylines Found >>"))
   (princ "\n<< No Lines Found >>"))
 (princ))


(defun dxf  (code ent)
 (cdr (assoc code (entget ent))))

(defun vlax-lst->3D-point  (lst)
 (if lst
   (cons (list (car lst) (cadr lst) (caddr lst))
         (vlax-lst->3D-point (cdddr lst)))))

 

Lee

Link to comment
Share on other sites

While you're there :geek: There are times when the horizontal lines in the selection set won't intersect a polyline at all. I can't think of a way to ignore those lines...

Link to comment
Share on other sites

Ahh, of course, I hadn't allowed for that - this should account for it:

 

(defun c:Int  (/ doc spc ss_grey ss_gl lne
                lObj ss int Objlst par lst ang)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (if (setq ss_grey
       (ssget "_X" '((0 . "LINE") (8 . "Profile") (62 . )))
   (if (setq ss_gl
         (ssget "_X" '((0 . "POLYLINE") (8 . "Ground Line Profile"))))
     (foreach lObj (mapcar 'vlax-ename->vla-object
                     (mapcar 'cadr (ssnamex ss_grey)))  

;;;  (while
;;;    (progn
;;;      (setq lne (car (entsel "\nSelect Horizontal Line: ")))
;;;      (cond ((eq 'ENAME (type lne))
;;;             (if (eq "LINE" (dxf 0 lne))
;;;               (if (zerop (- (cadr (dxf 11 lne)) (cadr (dxf 10 lne))))
;;;                 (progn
;;;                   (setq lObj (vlax-ename->vla-object lne))
;;;                   nil)
;;;                 (princ "\n** Line is not Horizontal **"))
;;;               (princ "\n** Object is not a Line **")))
;;;            (t (princ "\n** Nothing Selected **")))))
;;;
;;;  (princ "\nSelect Polylines: ")
;;;  (while (not ss)
;;;    (setq ss (ssget '((0 . "LWPOLYLINE")))))

       (setq int
         (vl-sort
           (apply 'append
             (vl-remove-if 'null
               (mapcar
                 (function
                   (lambda (Obj)
                     (vlax-lst->3D-point
                       (vlax-invoke lObj
                         'Intersectwith Obj acExtendNone))))
                            (setq Objlst
                              (mapcar 'vlax-ename->vla-object
                                (vl-remove-if 'listp
                                  (mapcar 'cadr (ssnamex ss))))))))
                   (function
                     (lambda (a b)
                       (< (car a) (car b))))) lst Objlst)

       (if int
         (progn

           (while
             (and (setq Obj (car lst))
                  (not
                    (setq par
                      (vlax-curve-getParamatPoint Obj (car int)))))
              (setq lst (cdr lst)))
           (setq ang
             (angle '(0 0 0)
               (vlax-curve-getFirstDeriv Obj par)))
           (if (or (< (/ pi 2.) ang pi)
                   (< (/ (* 3 pi) 2.) ang))
             (setq int (cdr int)))

           (setq lst Objlst)
           (while
             (and (setq Obj (car lst))
                  (not
                    (setq par
                      (vlax-curve-getParamatPoint Obj (last int)))))
              (setq lst (cdr lst)))
           (setq ang
             (angle '(0 0 0)
               (vlax-curve-getFirstDeriv Obj par)))
           (if (or (> (/ pi 2.) ang 0.)
                   (< pi ang (/ (* 3 pi) 2.)))
             (setq int
               (reverse
                 (cdr
                   (reverse int)))))
           (setq int
             (mapcar 'vlax-3D-point int))

           (while (cadr int)
             (setq nLne
               (vla-addLine spc
                 (car int) (cadr int)))
             (vla-put-layer nLne "Profile")
               (vla-put-color nLne 
             (setq int (cddr int)))

           (vla-delete lObj))))
     (princ "\n<< No Polylines Found >>"))
   (princ "\n<< No Lines Found >>"))
 (princ))


(defun dxf  (code ent)
 (cdr (assoc code (entget ent))))

(defun vlax-lst->3D-point  (lst)
 (if lst
   (cons (list (car lst) (cadr lst) (caddr lst))
         (vlax-lst->3D-point (cdddr lst)))))

Link to comment
Share on other sites

Thanks

 

Yeah I'm aware they are not LWPolylines.

Because I'm making the horizontal lines right before running this I won't need to check if they're horizontal.

 

Btw. This code gave me an error but it was just cause I changed the selection set name from ss to ss_GL.

All good now though, that's another big problem solved, big thanks Lee!

Link to comment
Share on other sites

Thanks

 

Yeah I'm aware they are not LWPolylines.

Because I'm making the horizontal lines right before running this I won't need to check if they're horizontal.

 

Btw. This code gave me an error but it was just cause I changed the selection set name from ss to ss_GL.

All good now though, that's another big problem solved, big thanks Lee!

 

Ahh of course, in my haste, I overlooked that variable change :oops:

 

I'm glad it all works for you now Steve, I'm sure it'll save you a lot of time :D

 

Lee

Link to comment
Share on other sites

One thing I didn't pick up on: whenever the first or last sections of the first and last polylines don't intersect the horizontal line a line won't be drawn (see first two attached jpegs to see what I mean - first image is what it does, second is what I'd like it to do).

I tried making lines either side of the profile but then I get other problems (see third jpeg).

Can you help?

Lines.jpg

Lines2.jpg

Lines3.jpg

Link to comment
Share on other sites

I should add: I noticed that this program does work when the added vertical line at the start of the profile ends on the point where the polyline begins (as is logical I guess), so I probably don't need this to be solved if it's too much effort.

 

An aside: when using Entmake can you "setq x" to the entity so that when finished with the line you can just "Entdel x"? Thanks

 

And Lee, out of interest, cause I'm struggling to understand your vlisp code, what was your method for trimming the lines? Was it finding intersections and drawing lines from those intersections? (obviously it was a bit more than that, but just generally)

Link to comment
Share on other sites

so this nice tool does not work with "normal" polylines ?

 

does autocad 2009 and/or 2010 even use lwpolylines ? cause ive never found them, only have normal lines and polylines in the basicbars

Link to comment
Share on other sites

so this nice tool does not work with "normal" polylines ?

 

does autocad 2009 and/or 2010 even use lwpolylines ? cause ive never found them, only have normal lines and polylines in the basicbars

 

Yes, my original posted code works with ALL forms of Polyline - and will also work with Arcs, Ellipses, Circles... you name it.

 

I should add: I noticed that this program does work when the added vertical line at the start of the profile ends on the point where the polyline begins (as is logical I guess), so I probably don't need this to be solved if it's too much effort.

 

Yes, well, this is a bit of a tough one to account for, as the program does not really "know" which side of the polyline it is dealing with anyway.

 

An aside: when using Entmake can you "setq x" to the entity so that when finished with the line you can just "Entdel x"? Thanks

 

I am assuming this is not to do with this particular LISP?

 

You can use Entmakex to create an entity and will return the entity name which you can then use as normal. Deleting/Recreating it with Entdel if necessary.

 

 

And Lee, out of interest, cause I'm struggling to understand your vlisp code, what was your method for trimming the lines? Was it finding intersections and drawing lines from those intersections? (obviously it was a bit more than that, but just generally)

 

I didn't "trim" the lines, I made new lines at every other intersection and deleted the old line. I looked at the First Derivative at the first and last intersection to determine which side of the polyline was "up" and "down".

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I've got a strange problem Lee with the program you wrote cutting lines at multiple polyines. Using your program in the dxf I receive with the groundline in it works mostly without a hitch, but whenever I copy the groundline from the dxf to a populated drawing (with lots of other survey points, layouts, viewports etc) it will replace the lines on the wrong side of the polylines. Why would that be? :? It's obviously not something wrong with the trimming formula used (since it works fine in the dxf), but rather with a difference between the dxf and the crowded drawing. I'm not sure what difference to look for though...

I notice at the start of your code it mentions paperspace and modelspace. Does it help if I say I will always be using this program in modelspace? Could the multiple layouts be the problem? (just thinking out loud)

Link to comment
Share on other sites

Hmmm.. I can't see what could go wrong.

 

I have engineered the code to work in both ModelSpace and PaperSpace, and OSnaps shouldn't cause a problem.

 

The only thing that comes to mind is if you have any Z-coord in your drawing, but I am a bit stumped as to why it works in the DXF but not in the main drawing.

 

I tested it in a normal drawing and all works fine, so not sure whats up :huh:

Link to comment
Share on other sites

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...