Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FILTER SPECIFIC TEXTS between a range of numbers

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
NESSEL
1025 Views, 9 Replies

FILTER SPECIFIC TEXTS between a range of numbers

Hello All,

 

there are texts and mtexts which are used for numbering the equipments in my drawing. each equipment has its own number within the range of 1 to 999, shown with a seperate text . I want to delete the texts which are between 200 to  350. The rest texts will remain the same.

 

How can I handle this? Any idea?

 

Thanx for all!

9 REPLIES 9
Message 2 of 10
Kent1Cooper
in reply to: NESSEL


@NESSEL wrote:

..... each equipment has its own number within the range of 1 to 999, shown with a seperate text . I want to delete the texts which are between 200 to  350. The rest texts will remain the same.

....


I will assume the content of those Text/Mtext entities is only the integer value, without prefix or suffix, etc., and that you mean between 200 and 350 inclusive.  If you can get them into a selection set [textss below], you can do something like this:

 

(repeat (sslength textss)

  (setq tent (ssname textss 0))

  (if (< 199 (atoi (cdr (assoc 1 (entget tent)))) 351)

    (entdel tent)

  )

  (ssdel tent textss)

)

 

If you meant between 200 and 350 not including those two numbers, substitute them in place of the 199 and 351.

Kent Cooper, AIA
Message 3 of 10
NESSEL
in reply to: Kent1Cooper

Dear Kent,

 

thank you for your kind help. Actually I tested as below but it selected something completely diferent.

 

(defun c:QLL ()
  (prompt "\nSelect objects to change.")
  (SETQ textss (ssget (list (cons 0 "*TEXT"))))
 
(repeat (sslength textss)

  (setq tent (ssname textss 0))

  (if (< 209 (atoi (cdr (assoc 1 (entget tent)))) 211)

    (entdel tent)

  )

  (ssdel tent textss)

)
  (command "CHPROP" TEXTSS "")
     (command "c")
     (command "6" "")
  )
 

 

any help??

 

thanks...

Message 4 of 10
Kent1Cooper
in reply to: NESSEL


@NESSEL wrote:

....it selected something completely diferent.

....


Can you be more specific?

Kent Cooper, AIA
Message 5 of 10
NESSEL
in reply to: Kent1Cooper

ok, NOW İT WORKS GREAT LİKE THE FOLLOWİNG AS YOU WROTE:) DELETES ALL THE TEXT CONTAINING 210 TO 212 (INCLUDING) 🙂

THANK YOU FOR YOUR EFFORT. wHAT IF I WANT TO CHANGE THE PROPERTIES OF THESE TEXTS INSTEAD OF DELETING THEM LIKE COLOUR CHANGING?? THANK YOU 🙂

 

(defun c:QQLL ()
  (prompt "\nSelect objects to change.")
  (SETQ textss (ssget (list (cons 0 "*TEXT"))))
 
(repeat (sslength textss)

  (setq tent (ssname textss 0))
  (if (< 209 (atoi (cdr (assoc 1 (entget tent)))) 213)
    (entdel tent)

  )

  (ssdel tent textss)

 )

)

 

Message 6 of 10
Kent1Cooper
in reply to: NESSEL


@NESSEL wrote:

ok, NOW İT WORKS GREAT.... wHAT IF I WANT TO CHANGE THE PROPERTIES OF THESE TEXTS INSTEAD OF DELETING THEM LIKE COLOUR CHANGING?? THANK YOU 🙂

...
    (entdel tent)

...


Just replace that (entdel tent) line with something like:

 

(command "_.chprop" tent "" "_color" yourcolor "_linetype" yourlinetype "_layer" yourlayer "")

 

or whatever property option(s) you need.

Kent Cooper, AIA
Message 7 of 10
Kent1Cooper
in reply to: NESSEL

Another thing you might consider....  Since you apparently come at this with different numbers, you could make one routine that would ask the User for those numbers, rather than having to make a separate one for every combination.

 

(defun c:QQLL (/ lo hi textss tent)
....

  (initget 5); no Enter, no negative

  (setq lo (getint "\nLow end integer (inclusive) to do whatever with: "))

  (initget 5)

  (setq hi (getint "\nHigh end integer: "))

....

  (if (< (1- lo) (atoi (cdr (assoc 1 (entget tent)))) (1+ hi))

....

 

Or it could be done as a non-C: function with arguments:

 

(defun QQLL (lo hi / textss tent)

....

  (if (< (1- lo) (atoi (cdr (assoc 1 (entget tent)))) (1+ hi))

....

 

which would be used this way:

 

(QQLL 210 212)

Kent Cooper, AIA
Message 8 of 10
NESSEL
in reply to: Kent1Cooper

THANK YOU VERY VERY MUCH!!! GREAT HELP:) REALLY GREAT:)

Message 9 of 10
Kent1Cooper
in reply to: NESSEL


@NESSEL wrote:

THANK YOU VERY VERY MUCH!!! GREAT HELP:) REALLY GREAT:)


You're welcome.  One other thing that occurs to me is that if you might be dealing with large numbers of Text objects, you might see a bit of a reduction in processing time if you either:

 

A. put the "offending" ones into a selection set with (ssadd), and then did the changing of properties on all of them at once, instead of one at a time; or

 

B. used vla-put-... or perhaps (subst)/(entmod) functions on them to change their properties, instead of CHPROP.

 

I understand that (command) functions, though they usually require less code, take [very slightly but measurably] longer than other ways of doing most things, which is why A. suggests a way to use one only once.  But in B., vla-put-... would require converting each entity to a vla-object, and (subst)/(entmod) would require digging out their entity data, and both would require assigning the properties to them individually.  I'm not sure -- that "extra work" might take as much time as the (command) function's overhead.

 

In any case, if the quantities are relatively small, you'd never notice whatever time difference there might be, so you could leave it alone.

Kent Cooper, AIA
Message 10 of 10
marlance
in reply to: Kent1Cooper

hello

 

How if i want to change the layer of all text divisible by 5?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost