View Full Version : Script for deleting lines or text
mairanta
28-06-2004, 10:36 AM
Hi!
I have lots of AutoCad-drawings and I need to delete certain texts and lines from them. The style of text or line is allways the same. For example I need to delete all lines that are ZC2 style. How can I make a script to do this?
YosSa
28-06-2004, 10:47 AM
on youre commandline :
<type> (setq sel1(ssget "X"(list(cons 1 "YOURE TEXT"))))
<type> Erase
<type> !sel1
This will erase all the text with the value of YOURE TEXT !!
Watch out, its case sensitive
For lines you have more options
On what option you want to select them ??
All lines in a specified layer ... or linetypes with the same linetypes
If you wanna select all lines in the same layer:
<type> (setq sel2(ssget "X"(list(cons 8 "LAYERNAME"))))
<type> Erase
<type> !sel2
If you wanna select all lines with the same lt:
<type> (setq sel3(ssget "X"(list(cons 6 "LT"))))
<type> Erase
<type> !sel3
If you wanna select all lines in the same layer and the same lt:
<type> (setq sel4(ssget "X"(list(cons 8 "LAYERNAME")(cons 6 "LT"))))
<type> Erase
<type> !sel4
Greetings
mairanta
28-06-2004, 11:19 AM
Hi and thanks for your help. Although it wasn't quite what I'm looking for.
At the moment I'm doing the erasing with "quick select" and then just deleting the selected lines or text. The case is, that I have lots of drawings from which I have to delete all the lines that are style ZC2 and text that are style ZSM, SGR or ZBO. It would be quicker if I had a lisp that would erase them all so I don't have to select them and then erase.
And also I have to change the scales for certain lines. I guess I could do that with the same lisp if I could just do it...
YosSa
28-06-2004, 11:38 AM
Open wordpad or notebook
Make new textfile
name it MyLisp.lsp
copy paste the next text:
(defun c:erasethe****()
(setq sel1(ssget "X"(list(cons 6 "ZC2"))))
(setq sel2(ssget "X"(list(cons 7 "ZSM"))))
(setq sel3(ssget "X"(list(cons 7 "SGR"))))
(setq sel4(ssget "X"(list(cons 7 "ZBO"))))
(if (/= nil sel1)
(progn
(command "erase" sel1 "")
)
)
(if (/= nil sel2)
(progn
(command "erase" sel2 "")
)
)
(if (/= nil sel3)
(progn
(command "erase" sel3 "")
)
)
(if (/= nil sel4)
(progn
(command "erase" sel4 "")
)
)
)
Now start a drawing and type
(load"MyLisp")
erasethe****
Should work
or download the attachment .....
mairanta
28-06-2004, 11:49 AM
Thank you very much!! It works perfectly!
And if you also know how to change the scale to, for example, 3 for all lines that are type SL3 with a lisp it would be even better...
Thank you!
YosSa
28-06-2004, 11:52 AM
thats possible ..
in VBA
if you want, i can look into it
Just arrange me some tickets to the semi final for Holland in portugal
haha
YosSa
28-06-2004, 12:18 PM
here it is:
(defun c:yieha()
(setq sel5(ssget "X"(list(cons 6 "SL3"))))
(command "_change" "sel5" "" "p" "ltscale" "3" "")
)
grtz YosSa
mairanta
29-06-2004, 04:39 AM
Dank U wel.
But the code isn't working :( And I don't get it why...
YosSa
29-06-2004, 06:02 AM
It should be like this:
(defun c:yieha()
(setq sel5(ssget "X"(list(cons 6 "SL3"))))
(command "_change" sel5 "" "p" "ltscale" "3" "")
)
so, without the " on sel5
mairanta
29-06-2004, 07:21 AM
Yeah, now it works!
Thank you! :D
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.