Jump to content

Erase specified length of lines in by Script/Lisp


Recommended Posts

Posted

Good Afternoon All,

 

i was wondering if someone here could help me, i have done a search on the web and here trying to find what i am after but have had no luck.

 

I need to erase a whole heap of lines ranging from about 1.25 to 3 in length, i need to do this in multiple xrefs, just realised you can't use QSELECT in script, and the SSX command does not do the trick either,

 

does anyone out there have a script/lisp routine that erases the specified length of lines in multiple drawings?

 

i hope this enough information.

 

cheers

 

Emily

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • Emily_83

    11

  • Tharwat

    7

  • Lee Mac

    5

  • Dadgad

    5

Top Posters In This Topic

Posted Images

Posted

Are you able to use the FILTER command instead?

Once you have described it sufficiently, make sure you SAVE the filter for

subsequent use. :)

Posted
Are you able to use the FILTER command instead?

Once you have described it sufficiently, make sure you SAVE the filter for

subsequent use. :)

 

hi Dadgad,

 

i have not really used the Filter command before, i tried using it earlier, but when i select one of the lines to add in the filter, it does not list it's length, and stince i am unfamiliar with the filter command, i am unsure weather it's going to work or not.

Posted

Try this ...

 

(defun c:Test (/ ss i sn l)
 (if (setq ss (ssget "_:L" '((0 . "LINE"))))
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i))))
     (setq l (distance (cdr (assoc 10 (entget sn))) (cdr (assoc 11 (entget sn)))))
     (if (or (eq l 1.25) (eq l 3.0) (and (> l 1.25) (< l 3.0)))
       (entdel sn)
       )
     )
   )
 (princ)
 )

Posted

Hi Tharwat,

 

when i run the lisp, prompts me to select objects, and when i click on the line, it does not find it, i even windowed everything in my drawing and it still doesn't select anything,

 

could it have something to do with the lines being polylines?

Posted

It is a great tool, very helpful, unfortunately I have been trying to set it up for you too, and failed.

It sounds like a very simple lisp, no doubt someone will soon help you sort it out. :)

Posted
Polylines don't have LENGTH.

If you explode a few of them, into LINES, as a test,

no doubt Tharwat's lisp will work. :)

 

thanks Dadgad,

 

the lisp works, however now that i have to explode the Plines, they explode into tiny lines, and also the routine erases other lines that are now the same length since exploding that i don't want erased, if it helps, i really only need all vertical lines erased of the length i specify.

Posted

Emily I made a huge mistake in my earlier post POLYLINES do have length.

I am guessing (I do not write lisp) that you need to change the "LINE" in Tharwat's

code to "PLINE" . :)

pline length.JPG

Posted

hehe thanks Dadgad, i had a look before using QSELECT, then selecting polyline and saw that it does have the length, i thought it did as i usually use the QSELECT this way

 

i also changed the "LINE" part of the lisp to "PLINE" but it did not work, might try "PL"

 

thankyou for helping me i greatly appreciate it. :)

Posted

just changed it to "PL" and that does not work either:unsure:

Posted

You're welcome, Tharwat is offline now, but I'm sure he will be back, or else one of the

other lisperati will pick up on your thread and help you sort it out. :)

Posted

You have mentioned into your first post that the objects are lines , and that 's why I included lines entities only . ;)

 

Anyway try this updated one to include Polylines as well .

 

(defun c:Test (/ ss i sn l) (vl-load-com)
 (if (setq ss (ssget "_:L" '((0 . "LINE,*POLYLINE"))))
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i))))
     (if (eq (cdr (assoc 0 (entget sn))) "LINE")
       (setq l (distance (cdr (assoc 10 (entget sn)))
                         (cdr (assoc 11 (entget sn)))
               )
       )
       (setq
         l (vlax-curve-getdistatparam
             sn
             (fix (vlax-curve-getendparam sn))
           )
       )
     )
     (if (or (eq l 1.25) (eq l 3.0) (and (> l 1.25) (< l 3.0)))
       (entdel sn)
     )
   )
 )
 (princ)
)

Posted

Another variation:

 

(defun c:eraselines ( / s )
   (if (ssget "_:L" '((0 . "LINE,*POLYLINE")))
       (progn
           (vlax-for o
               (setq s
                   (vla-get-activeselectionset
                       (vla-get-activedocument (vlax-get-acad-object))
                   )
               )
               (if (<= 1.25 (vla-get-length o) 3.0) (vla-delete o))
           )
           (vla-delete s)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Posted

Good morning Tharwat and Lee Mac,

 

sorry Tharwat about giving you the wrong information :oops:

both those routines work now .......however is there any chance to modify anyone of those Lips to erase strictly only 0.5, 1.25, 1.5 and 3 length PLINES?? hopefully if the image is clear enough below, the lines i need deleted are those of the viertical lines you see in the image, which are the specified lengths i have listed above.

Capture.JPG

thankyou both very much for you help.

 

Emily

Posted

however is there any chance to modify anyone of those Lips to erase strictly only 0.5, 1.25, 1.5 and 3 length PLINES??

 

(defun c:Test (/ ss i sn l)
 (vl-load-com)
 (if (setq ss (ssget "_:L" '((0 . "LINE,*POLYLINE"))))
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i))))
     (if (eq (cdr (assoc 0 (entget sn))) "LINE")
       (setq l (distance (cdr (assoc 10 (entget sn))) (cdr (assoc 11 (entget sn)))))
       (setq l (vlax-curve-getdistatparam sn (fix (vlax-curve-getendparam sn))))
       )
     (if (or (eq l 0.5) (eq l 1.25) (eq l 1.5) (eq l 3.0))
       (entdel sn)
       )
     )
   )
 (princ)
 )

Posted
(defun c:eraselines ( / l s )
   (if (ssget "_:L" '((0 . "LINE,*POLYLINE")))
       (progn
           (vlax-for o
               (setq s (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
               (setq l (vla-get-length o))
               (if (vl-some '(lambda ( x ) (equal l x 1e-) '(0.5 1.25 1.5 3.0))
                   (vla-delete o)
               )
           )
           (vla-delete s)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Posted (edited)

Tharwat, Lee Mac,

 

your both brilliant, thankyou so much both routines work perfectly, ........however!!!....i know i am sorry i have one more problem, :unsure:

in the image attached, the lisps do not erase these lines.....they are the 3.0 length but seem to be an un-closed/joined polyline type of ellipse looking thing, with an area, it does not matter if i close them and disable linetype, the lisp still does not erase these polylines (when i select the objects it does tell me they are polylines in the properties box).

 

would you have any idea why that is?

if not, not to worry you both and Dadgad, have been more than helpful.

 

Cheers

Emily

[ATTACH=CONFIG]37068[/ATTACH]

Edited by Emily_83
added the image
Posted

I can't view the image for some reason Emily, I receive the following message when clicking on your attachment:

 

invalid.png

 

Are you able to attach a sample drawing?

Posted
I can't view the image for some reason Emily, I receive the following message when clicking on your attachment:

 

Same thing here .

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