Jump to content

Delete AutoCAD Points Outside of Multiple Polylines (Speed Problem?)


Kablamtron

Recommended Posts

Hey Everyone,

 

I have slapped together a lisp (some of my work some from other lisps) that deletes AutoCAD points outside of multiple Polylines (see thread title :lol:).

 

Anywho, It works very well for small number of points say 1000.

 

The problem occurs when you have larger point clouds which I want to work with.

 

If someone more knowledgeable than me can take a look and see where the speed problem is (I am guessing one of the loops?) that would be greatly appreciated!

 

If you do look at the code you will guess I hardly know what I am doing half the time hah!

 

(princ"\n<<< type dompl to run>>> ")
(defun c:dompl(/ plSet ss3 plSetall ptLst file points c file1 points1 c1 ent1 ct ct1 ct2)

 (princ"\n<<< Select polylines to delete points outside>>> ")
 (and

(setq ct2 0)
(setq ss2 0)
   (setq ss2 (ssget "X" '((0 . "POINT"))))

   (setq plSetall
  (ssget '((0 . "LWPOLYLINE"))))
(repeat (sslength plSetall)

 (princ"\nc")

  (setq ptLst

      (mapcar
 '(lambda(x)(trans x 0 1))
(mapcar 'cdr
  (vl-remove-if-not
    '(lambda(x)(= 10(car x)))
      (entget
        (ssname plsetall ct2))))))
 (princ"\nd")
    (setq ss3(ssget "_CP" ptLst))
  (sssetfirst nil
    (setq ss1 (ssget "P" '((0 . "POINT")))))

(setq ct 0)

(repeat (sslength ss1)
   (ssdel (ssname ss1 ct) ss2)
   (setq ct (1+ ct)))
(setq ct2 (1+ ct2))
 );repeat loop end

(setq ent1 0)
(setq ct1 0)

(repeat (sslength ss2)
   (setq ent1 (ssname ss2 ct1))
   (entdel ent1) 
   (setq ct1 (1+ ct1)))

 (close file)       
  ); end and
 ); end of c:plset

 

 

Thanks again for reading.

 

Kablam

Link to comment
Share on other sites

Not sure if this would be any quicker?

 

(defun c:test ( / e h i j s1 s2 s3 )
   (if
       (and
           (setq s1 (ssget "_X" '((0 . "POINT"))))
           (setq s2 (ssget '((0 . "LWPOLYLINE"))))
       )
       (progn
           (vla-zoomextents (vlax-get-acad-object))
           (repeat (setq i (sslength s2))
               (if (setq s3
                       (ssget "_CP"
                           (apply 'append
                               (mapcar
                                   (function
                                       (lambda ( x ) (if (= 10 (car x)) (list (cdr x))))
                                   )
                                   (entget (ssname s2 (setq i (1- i))))
                               )
                           )
                          '((0 . "POINT"))
                       )
                   )
                   (repeat (setq j (sslength s3))
                       (setq h (cons (cdr (assoc 5 (entget (ssname s3 (setq j (1- j)))))) h))
                   )
               )
           )
           (repeat (setq i (sslength s1))
               (setq e (ssname s1 (setq i (1- i))))
               (if (not (member (cdr (assoc 5 (entget e))) h))
                   (entdel e)
               )
           )
           (vla-zoomprevious (vlax-get-acad-object))
       )
   )
   (princ)
)

Link to comment
Share on other sites

Hey Lee Mac,

 

As usual you know wayyy more about this stuff than me.

 

Your lisp works a lot better than mine and I am still trying to read through some of it hah!

 

I ran the lisp and it is faster but still seems slow around the deleting portion of the lisp everything else is quick.

 

I was thinking is it possible to reselect the end filtered selection set and just use the autocad erase command?

Link to comment
Share on other sites

GOT IT! SORTA!

 

I think I will use your window zoom that is a good idea,

 

Thanks Lee :D

 

Changed it to just reselect the selection set.

 

(princ"\n<<< type dompl to run>>> ")
(defun c:dompl(/ plSet ss3 plSetall ptLst file points c file1 points1 c1 ent1 ct ct1 ct2)

 (princ"\n<<< Select polylines to delete points outside>>> ")
 (and

(setq ct2 0)
(setq ss2 0)
   (setq ss2 (ssget "X" '((0 . "POINT"))))

   (setq plSetall
  (ssget '((0 . "LWPOLYLINE"))))
(repeat (sslength plSetall)

 (princ"\nc")

  (setq ptLst

      (mapcar
 '(lambda(x)(trans x 0 1))
(mapcar 'cdr
  (vl-remove-if-not
    '(lambda(x)(= 10(car x)))
      (entget
        (ssname plsetall ct2))))))
 (princ"\nd")
    (setq ss3(ssget "_CP" ptLst))
  (sssetfirst nil
    (setq ss1 (ssget "P" '((0 . "POINT")))))

(setq ct 0)

(repeat (sslength ss1)
   (ssdel (ssname ss1 ct) ss2)
   (setq ct (1+ ct)))
(setq ct2 (1+ ct2))
 );repeat loop end

(setq ent1 0)
(setq ct1 0)
(sssetfirst nil ss2)
(sssetfirst nil ss2) 
(command "._ERASE")

 (close file)       
  ); end and
 ); end of c:plset

 

And it is wayyyyy faster yay!

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