Author Topic: greater than or equal to ssget filter  (Read 4722 times)

0 Members and 1 Guest are viewing this topic.

diarmuid

  • Bull Frog
  • Posts: 417
greater than or equal to ssget filter
« on: December 15, 2010, 03:36:13 PM »
I am trying to tidy up CAD files received from an outside source.

The text heights fro whatever reason are in various sizes.  These sizes range considerably.  However many of these sizes are similar but not the same.  For instance I have text heights that are 249.88, 249.995, 250, 250.00035. (Don’t ask!)

Now its pretty obvious that all of these heights should be 250mm in height.  I want to do a selection set to pick text that is between the heights 249 and 251.  (I can apply this for the other ranges, just tweaking accordingly)


(setq txt1 (ssget "x" ' ((-4 . "<and")(0 . "text") (40 . 249.999975)  (-4 . "and>") )))

Is there a way I can modify above to select greater than 249 but less than 251?

Any help would be greatly appreciated

Regards

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon

T.Willey

  • Needs a day job
  • Posts: 5251
Re: greater than or equal to ssget filter
« Reply #1 on: December 15, 2010, 03:43:50 PM »
Here you go.  Two ways, that are really the same.

Code: [Select]
(setq ss
    (ssget
        "_x"
        (list
            (cons 0 "text")
            (cons -4 "<AND")
                (cons -4 ">=" 249)
                (cons -4 "<=" 251)
            (cons -4 "AND>")
        )
    )
)

Code: [Select]
(setq Num 250)
(setq Rng 1)
(setq ss
    (ssget
        "_x"
        (list
            (cons 0 "text")
            (cons -4 "<AND")
                (cons -4 ">=" (- Num Rng))
                (cons -4 "<=" (+ Num Rng))
            (cons -4 "AND>")
        )
    )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

diarmuid

  • Bull Frog
  • Posts: 417
Re: greater than or equal to ssget filter
« Reply #2 on: December 15, 2010, 03:45:38 PM »
Boom!

thank you.

very much appreciated.

Happy Christmas from the emerald Isle!
If you want to win something run the 100m, if you want to experience something run a marathon

T.Willey

  • Needs a day job
  • Posts: 5251
Re: greater than or equal to ssget filter
« Reply #3 on: December 15, 2010, 03:49:28 PM »
Boom!

thank you.

very much appreciated.

Happy Christmas from the emerald Isle!

You're very welcome.

Happy Christmas from Cali, USA.

You guys hiring?  Been once to Ireland, can't wait to get back there.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

diarmuid

  • Bull Frog
  • Posts: 417
Re: greater than or equal to ssget filter
« Reply #4 on: December 15, 2010, 03:53:45 PM »
nah,

we've been screwed by the recession.   more so than most countries because or economy is so small. The IMF are lending ireland 80bn euro (about 80bn usd).  Irish banks were rife with corruption and one of the smaller banks went to the wall bringing the other main banks with it.

So its us the tax payers are coughing up to repay this.  so we have bottomed out in the recession much deeper in the trough.

If you want to win something run the 100m, if you want to experience something run a marathon

T.Willey

  • Needs a day job
  • Posts: 5251
Re: greater than or equal to ssget filter
« Reply #5 on: December 15, 2010, 03:57:01 PM »
Sorry to hear that.  Hope the worlds economy starts a more upward trend.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: greater than or equal to ssget filter
« Reply #6 on: December 15, 2010, 04:28:47 PM »
I think it should take this form.
Code: [Select]
(setq ss  (ssget  "_x" '((0 . "text")(-4 . ">") (40 . 249)(-4 . "<") (40 . 251))))
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: greater than or equal to ssget filter
« Reply #7 on: December 15, 2010, 04:32:14 PM »
I think it should take this form.
Code: [Select]
(setq ss  (ssget  "_x" '((0 . "text")(-4 . ">") (40 . 249)(-4 . "<") (40 . 251))))

Good call Alan...  :oops:

I forget sometimes that the ' and ' is implied in the ssget filter list.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

diarmuid

  • Bull Frog
  • Posts: 417
Re: greater than or equal to ssget filter
« Reply #8 on: December 16, 2010, 04:03:35 AM »
Once again,

I am extremly gratedfull for your assistance.  Since i started surfing this web site (way back when it was in cadalog) i new nothing about lisp at all.  now at least i'm appling filters etc to personal lisp that i have written saving me hundred upon hundreds of hours.

 :-)

thanks a mil

Regards

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon

diarmuid

  • Bull Frog
  • Posts: 417
Re: greater than or equal to ssget filter
« Reply #9 on: December 16, 2010, 05:58:36 AM »
With your input, i have created the following to select test and mtext.  I'll repeat for the standard sizes.



(if (setq txt1  (ssget  "x" '((-4 . "<or")(0 . "text") (0 . "mtext") (-4 . "or>")(-4 . ">") (40 . 194)(-4 . "<") (40 . 204))))
       (progn
            (command "-layer" "m" "200_TEXT" "COLOR" "white" "" "")
            (command "change" txt1 "" "properties" "layer" "200_text" "")
            (setq txt1 nil)
        )
    )

I suppose its nice to see your help bieng put to good use.....

Cheers!
If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: greater than or equal to ssget filter
« Reply #10 on: December 16, 2010, 09:26:32 AM »
Code: [Select]
(cons -4 ">=" 249)

Surely that fails by definition of 'cons'   :?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: greater than or equal to ssget filter
« Reply #11 on: December 16, 2010, 09:46:28 AM »
Dirmuid,
Glad you shared your code. It has potential flaws.
Using (ssget "X") will collect all items in all layouts while the (command "change"
will only work on items in current space. So if your intent was to change all text items throughout
the entire drawing this will be needed.
Code: [Select]
(defun c:TextFix (/ ss ll ul lyr clr ent err)
  (vl-load-com) ; needed when a vlax- function is used, once per session
 
  (setq ll  194                         ; Lower Limit
        ul  204                         ; Upper Limit
        lyr "200_TEXT"
        clr "WHITE"
  )

  (if (setq ss (ssget "_X"
                      (list '(0 . "text,mtext")
                            '(-4 . ">")
                            (cons 40 ll)
                            '(-4 . "<")
                            (cons 40 ul)
                      )
               )
      )
    (progn
      ;;  create the layer or make sure it is current
      (if (tblsearch "LAYER" lyr) ; layer already exist
        (command "._Layer" "_Thaw" lyr "_On" lyr "_UnLock" lyr "_Set" lyr "")
        (command "._Layer" "_M" lyr "_COLOR" clr "" "")
      )
      ;; does not work for objects not in current space
      ;;(command "change" ss "" "properties" "layer" lyr "")

      ;;  Step through the selection set & change the layer
      (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        (setq err (vl-catch-all-apply 'vla-put-layer
                    (list (vlax-ename->vla-object ent) lyr)))
        (if (vl-catch-all-error-p err) ; yes, error
          (print (vl-catch-all-error-message err))
        )
      )
    )
  )
  (princ)
)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: greater than or equal to ssget filter
« Reply #12 on: December 16, 2010, 09:49:58 AM »
Code: [Select]
(cons -4 ">=" 249)

Surely that fails by definition of 'cons'   :?
I was sure Tim forgot the dxf 40 in his haste. :-)
Code: [Select]
(cons -4 ">=") (cons 40 249)
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.

diarmuid

  • Bull Frog
  • Posts: 417
Re: greater than or equal to ssget filter
« Reply #13 on: December 16, 2010, 09:54:51 AM »
thanks for the heads up!!!
If you want to win something run the 100m, if you want to experience something run a marathon

T.Willey

  • Needs a day job
  • Posts: 5251
Re: greater than or equal to ssget filter
« Reply #14 on: December 16, 2010, 11:04:39 AM »
Code: [Select]
(cons -4 ">=" 249)

Surely that fails by definition of 'cons'   :?
I was sure Tim forgot the dxf 40 in his haste. :-)
Code: [Select]
(cons -4 ">=") (cons 40 249)

Yes I did Alan, but good catch Lee.  Man I wasn't really that helpful this thread was I..  :oops:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: greater than or equal to ssget filter
« Reply #15 on: December 16, 2010, 11:08:50 AM »
Code: [Select]
(cons -4 ">=" 249)

Surely that fails by definition of 'cons'   :?
I was sure Tim forgot the dxf 40 in his haste. :-)
Code: [Select]
(cons -4 ">=") (cons 40 249)

Yes I did Alan, but good catch Lee.  Man I wasn't really that helpful this thread was I..  :oops:

Reading my post back, I sound a little douche'y - apologies, we've all been there.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: greater than or equal to ssget filter
« Reply #16 on: December 16, 2010, 11:13:12 AM »
Code: [Select]
(cons -4 ">=" 249)

Surely that fails by definition of 'cons'   :?
I was sure Tim forgot the dxf 40 in his haste. :-)
Code: [Select]
(cons -4 ">=") (cons 40 249)

Yes I did Alan, but good catch Lee.  Man I wasn't really that helpful this thread was I..  :oops:

Reading my post back, I sound a little douche'y - apologies, we've all been there.

No problem Lee.  I read most all posts with a air of humor first, so I took no offense.  Sometimes the simple responses, which are quick, just come off sounding different than intended.  Nature of the inet.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

diarmuid

  • Bull Frog
  • Posts: 417
Re: greater than or equal to ssget filter
« Reply #17 on: December 16, 2010, 11:24:32 AM »
its also a cultural thing.  I from Cork city in ireland where the humor is very dead pan and sarcastic.  No problem when you are dealing with local people.  but very tricky when you are dealing with non-cork people. (espcially the french, they do not get Irish humour AT ALL).  So, i need to be extra carefull incase i sound a bit smart arsed.  Also, because of the inet, people cannot see a cheeky grin, then they wont realise its meant as humour.

If you want to win something run the 100m, if you want to experience something run a marathon