Erase within coordinates

Erase within coordinates

Anonymous
Not applicable
3,373 Views
13 Replies
Message 1 of 14

Erase within coordinates

Anonymous
Not applicable

Can anyone help me with this lisp?

 

It's supposed to erase text objects within an imaginary rectancle, coordinates 15,35 to 295,40 by window type select so only the text objects fully enclosed within the rectangle get erased.

 

The lisp I'm trying to create fails on the second line in Vlide but I cannot see the error(s)

 

- Simon

 

 

(defun C:DTTX (/ ss1)
  (if (setq ss1 (ssget '(15 35) '(295 40) '((0 . "TEXT")))
    (command "_.erase" ss1 "")
    (alert "TEXT Not Found")
  )
  (princ)
)

 

 

0 Likes
Accepted solutions (1)
3,374 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant

See this Lee Mac's cool page

http://www.lee-mac.com/ssget.html

 

...with this example...

(ssget "_C" '(0 0) '(2 1) '((0 . "CIRCLE")))

 

Edit:

Spoiler
Spoiler
(defun C:DTTX (/ ss1)
(if (setq ss1 (ssget "_C" '(15 35) '(295 40) '((0 . "TEXT")))) ;watch parenthesis
(command "_.erase" ss1 "")
(alert "TEXT Not Found")
)
(princ)
)

 

0 Likes
Message 3 of 14

Anonymous
Not applicable
Hi BeekeeCZ. That's where I got the idea from!

Thanks anyway
0 Likes
Message 4 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

It's supposed to erase text objects within an imaginary rectancle, coordinates 15,35 to 295,40 by window type select so only the text objects fully enclosed within the rectangle get erased.

.... 


Or, if you want the Window-type rather than the Crossing-type selection:

....

  (if (setq ss1 (ssget "_W" '(15 35) '(295 40) '((0 . "TEXT")))

....

 

If you give (ssget) two points without the "_C" or "_W" designation, it only picks at the two points, and will find anything that may be located at them, but if not, it doesn't automatically go into Window/Crossing mode, as it does when you do this manually.  So you need to specify that.

Kent Cooper, AIA
0 Likes
Message 5 of 14

Anonymous
Not applicable

Hello Kent

Unfortunately it still doesn't work, it say's 'error: syntax error'

 

It's driving me nuts

 

(defun C:DTTX (/ ss1)
  (if (setq ss1 (ssget "_W" '(15 35) '(295 40) '(0 . "TEXT"))))
    (command "_.erase" ss1 "")
    (alert "TEXT Not Found")
  );; End of if
  (princ)
)
0 Likes
Message 6 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

Watch parentheses...

 

(defun C:DTTX (/ ss1)
(if (setq ss1 (ssget "_W" '(15 35) '(295 40) '((0 . "TEXT"))))
(command "_.erase" ss1 "")
(alert "TEXT Not Found")
);; End of if
(princ)
) 

 

0 Likes
Message 7 of 14

Anonymous
Not applicable
Thank you BeekeeCZ
Works a treat. Thank you too Kent

Stoopid brackets !
0 Likes
Message 8 of 14

ВeekeeCZ
Consultant
Consultant

That's all about them...

 

In Visual LISP editor (command VLIDE from AutoCAD) you have some tools to better control of them.

If you type closing ) you get a visual cursor control with the pair bracket.

 

Then try:

CTRL + [

CTRL + ]

SHIFT + CTRL + [

SHIFT + CTRL + ]

 

More of them:

http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-CAD3B7DA-0295-4ABE-91A4-AA7617BA263C

0 Likes
Message 9 of 14

Anonymous
Not applicable

I didn't know that, very useful & quite easy too. Thank you

0 Likes
Message 10 of 14

Anonymous
Not applicable

Can someone please explain what '((0 . "TEXT")) does? I have been trying to use this LISP to delete everything contained within a rectangular coordinate system (1075874.0,-700742.0, 1075874.0,-262165.0, 1288360.0,-262165.0, 1288360.0,-700742.0) but nothing is removed. I have no idea what I am doing wrong. 

 

Any help is greatly appreciated. 

0 Likes
Message 11 of 14

ВeekeeCZ
Consultant
Consultant
It keeps only TEXT entities within the selection.
So if you want to select everything, remove that.
0 Likes
Message 12 of 14

Anonymous
Not applicable

it appears, or at least by dumb luck I discovered, that I needed to add

(command "_.ZOOM" "_E")

before the code as I assume it requires everything to be visible before it functions properly. 

0 Likes
Message 13 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

it appears, or at least by dumb luck I discovered, that I needed to add

(command "_.ZOOM" "_E")

before the code as I assume it requires everything to be visible before it functions properly. 


It shouldn't require everything to be visible -- only everything selected  by the routine.  You could just Zoom using the coordinates of the window you want things selected in, rather than to the Extents.  It would reduce the likelihood of a Regeneration being required, as well as presumably most of the time letting you see what's happening at larger screen size.

Kent Cooper, AIA
0 Likes
Message 14 of 14

Anonymous
Not applicable

AH! I will change my zoom from extents to window of the coordinates of the selection area. Thanks @Kent1Cooper! You guys are so helpful on here

0 Likes