Jump to content

Erase specified length of lines in by Script/Lisp


Emily_83

Recommended Posts

  • 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

Hi guys,

 

sorry the image didn't work, i have attached an example drawing of what i need, i have outlined what i need within the drawing, i really hope i haven't over explained and confused you when you take a look, but sometimes more info is better that less.

 

please note that there were one or 2 lengths i didn't provide you with earlier which i think was 1.0 and 2.5, and i just added those lengths into the lisp myself.

 

once again i really appreciate your time and help you have provided.

 

kind regards

 

Emily

example.dwg

Link to comment
Share on other sites

Try this .... :)

 

(defun c:Test (/ *error* dim ss i sn l)
 (vl-load-com)
 (defun *error* (x)
   (if dim
     (setvar 'dimzin dim)
   )
   (princ "\n *Cancel*")
 )
 (setq dim (getvar 'dimzin))
 (setvar 'dimzin 0)
 (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 (member (rtos l 2 2) '("0.50" "1.25" "1.50" "3.00"))
       (entdel sn)
     )
   )
 )
 (setvar 'dimzin dim)
 (princ)
)

Link to comment
Share on other sites

Hi Emily,

 

Simply change the tolerance in my code from 1e-8 to say, 1e-3 (0.001); the polylines in your file aren't exactly 1.25, 3.0 etc in length, but rather 1.25001.

 

@Tharwat, consider the equal function :thumbsup:

 

Lee

Link to comment
Share on other sites

You guys are the best!:D

 

Tharwat,

 

your lisp worked, it erased some horizontal lines also, and i tried to edit the lisp to stop that from happening but from my limited knowledge i wasn't successful. ...would love to know for future what to edit, i thought it was something in the rtos 1 2 2 part

 

Lee Mac,

 

yours did the same but when you told me to change the 1e-8 to 1e-3, i changed it again to 1e-4 and it worked perfectly,

 

Once again thankyou so much for your help and time, it's saved me going through each longsection and doing it manually.

 

Cheers

 

Emily:D

Link to comment
Share on other sites

yours did the same but when you told me to change the 1e-8 to 1e-3, i changed it again to 1e-4 and it worked perfectly

 

It sounds as though much of your geometry is of very similar length since my suggestion of a tolerance of 1e-3 (0.001) and your use of 1e-4 (0.0001) was the difference between various objects being erased - though, I see that you appear to have understood the purpose of the tolerance figure in the code, and am glad you could tweak the program to your needs!

 

Thank you for your gratitude and appreciation Emily! :beer:

Link to comment
Share on other sites

  • 1 year later...
thank sir

but i want first to ask me which length you want to erase so example i enter 30

so outmatically erase all line have same length

thanks sir

 

Try this .

 

(defun c:Test (/ ss i sn l)
 (if (and (setq l (getdist "\n Specify length :")) (setq ss (ssget "_X" '((0 . "LINE,*POLYLINE")))))
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i))))
     (if (equal l (vlax-curve-getdistatpoint sn (vlax-curve-getendpoint sn)) 1e-
       (entdel sn)
     )
   )
 )
 (princ)
)(vl-load-com)

Link to comment
Share on other sites

  • 6 months later...

Hi,

 

I know I'm jumping on an old thread but I've looking for help to delete 2 lines in particular from a few hundred drawings. Haven't been able to write/find a lisp code that deletes particular lines from a drawing. The lines are always in the same spot. This was the closest lisp I found that could do it. I was going to use this then use a script to call in all drawings.

 

Only problem is it prompts me to select objects before starting each drawing. Anyway I could tweak the code to not have to select the area/objects? There are only two lines of this length in all drawings.

 

 

Thanks in advance

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