Author Topic: Select text with integer string only  (Read 1404 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Select text with integer string only
« on: May 08, 2018, 03:27:39 PM »
Hello guys,

Is it possible to use ssget function with filter to select single text objects with different quantity of integers strings?

Example: 2 45 535 7588 and many more.

Thanks in advance.

ribarm

  • Gator
  • Posts: 3304
  • Marko Ribar, architect
Re: Select text with integer string only
« Reply #1 on: May 08, 2018, 05:19:05 PM »
Sample DWG would be nice with explanation of your goal...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Select text with integer string only
« Reply #2 on: May 08, 2018, 06:05:44 PM »
I don't think so. Some post processing would be required.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Select text with integer string only
« Reply #3 on: May 08, 2018, 06:46:47 PM »
Code: [Select]
(ssget "_X" (list (cons 0 "TEXT") (cons 1 "##")));2 digits
(ssget "_X" (list (cons 0 "TEXT") (cons 1 "###")));3 digits
(ssget "_X" (list (cons 0 "TEXT") (cons 1 "##,###")));2 or 3 digits

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: Select text with integer string only
« Reply #4 on: May 08, 2018, 07:06:06 PM »
Code: [Select]
(ssget "_X" '((0 . "TEXT") (1 . "~*[~0-9]*"))) ; only digits

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2149
  • class keyThumper<T>:ILazy<T>
Re: Select text with integer string only
« Reply #5 on: May 08, 2018, 07:45:18 PM »

If you want control over your selections (ie only filter selected, not ALL ):

I'd try either
Code - Auto/Visual Lisp: [Select]
  1. (ssget  '((0 . "TEXT") (1 . "~*[~0-9] *")))
  2. (ssget  "+.:S" '((0 . "TEXT") (1 . "~*[~0-9] *")))
  3.  

or for Text OR MText
Code - Auto/Visual Lisp: [Select]
  1. (ssget  '((0 . "*TEXT") (1 . "~*[~0-9] *")))
  2. (ssget  "+.:S" '((0 . "*TEXT") (1 . "~*[~0-9] *")))
  3.  
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Select text with integer string only
« Reply #6 on: May 08, 2018, 08:20:06 PM »
Don't we need to include negative integers?
The Op did not include them in his examples but.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2149
  • class keyThumper<T>:ILazy<T>
Re: Select text with integer string only
« Reply #7 on: May 08, 2018, 08:46:21 PM »
Hi CAB

I just realised that my code is incorrect ... it allows in characters.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Coder

  • Swamp Rat
  • Posts: 827
Re: Select text with integer string only
« Reply #8 on: May 09, 2018, 02:37:10 AM »
Thank you guys for your kind replies, that was very helpful.