Select & Delete Lines/Text

Select & Delete Lines/Text

Anonymous
Not applicable
1,619 Views
2 Replies
Message 1 of 3

Select & Delete Lines/Text

Anonymous
Not applicable

Hello,

 

I'm still very new at LISP and was wondering if anyone could help me understand the syntax/code for selecting and deleting lines and text.

 

I would like a function that simply selects a line in a known location and deletes it. Then a similar one for text.

I've had a go and came up with this mess :S I'd like to know what I'm doing wrong so I can improve, so looking at the code below what's out of place?

 

(setq to_be_deleted (ssget "_F" pt1(list 732.6 264.075)pt2(list 829.626 259.55)))
(if ss (command "_.Erase" to_be_deleted ""))

 

The idea was it would select everything in a box then delete it, but I just get a bunch of errors as I don't fully understand the syntax. If this is the wrong approach I'm happy to go with deleting 1 line/text at a time.

 

(Sorry if this ends up as a repeat post, this post wasn't appearing for me after creating it.)

 

0 Likes
Accepted solutions (1)
1,620 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Don't worry I managed to work it out myself, here is the code for other people:

 

(setq pt1 '(827.162 264.702) pt2 '(734.042 259.941))			;Set Selection Points
(setq sstbd (ssget "C" pt1 pt2))					;Select Objects in Box and create selection set
(if sstbd (command "_.Erase" sstbd ""))					;Delete selection set "sstbd"
Message 3 of 3

CodeDing
Advisor
Advisor

@Anonymous ,

 

Good work coming to your own solution.

Here is a little insight for future knowledge, if you do not already know.

;set points
(setq pt1 '(827.162 264.702) pt2 '(734.042 259.941))
;if objects found in sel set
(if (setq sstbd (ssget "C" pt1 pt2 '((0 . "LINE")))) ;you can add more filters to be sure you only select your LINE or LWPOLYLINE
  ;delete sel set items
  (command "_.Erase" sstbd "")
);if

Best,

~DD

0 Likes