Author Topic: ssget filter list  (Read 4039 times)

0 Members and 1 Guest are viewing this topic.

ssbp

  • Mosquito
  • Posts: 11
Re: ssget filter list
« Reply #15 on: July 20, 2012, 10:04:40 am »
Thanks CAB,

I understand that, this happens to most upper right text i.e. - (A2)
But what about texts marked together with red rectangle i.e. - ENABLE RELAY & 3243,3243,3248
It happens to these texts also. And I don't think its ACAD rounding error.
Please help.


Thanks for code ronjonp.

I need ssget function with extended filter list like (cons 10 (OR (*.00000000) (*.25000000) (*.50000000) (*.75000000))) or with any other idea to select text entities with above insertion condition.

I hope this will give clear idea what I want

Thanks to both of you.
Awaiting for your positive reply.

CAB

  • Global Moderator
  • Needs a day job
  • Posts: 9881
Re: ssget filter list
« Reply #16 on: July 20, 2012, 10:25:39 am »
My last routine ignores these as correct in my test.
I did have to convert the DWG to ACAD2006 for my test.
Did you try my last revision? Did it flagged the
ENABLE RELAY
3243,3243,3248

in the red rectangle?
I've reached the age where the happy hour is a nap. ()
Windows 7 core i7 870 2.93 12GB
Please support this web site.

CAB

  • Global Moderator
  • Needs a day job
  • Posts: 9881
Re: ssget filter list
« Reply #17 on: July 20, 2012, 10:55:56 am »
Use the fuzz to adjust tolerance.
How close to a perfect match do you need?
0.2500000  +/- .01  ?

Code: [Select]
(defun c:fe (/ ss i ent elst dxf10 dxf11 dxfx dxfy fuzz)
  (setq fuzz 0.01)
  (if (setq ss (ssget (list '(0 . "TEXT"))))
    (progn
      (setq i -1)
      (while (setq ent (ssname ss (setq i (1+ i))))
        (setq elst  (entget ent)
              dxf10 (cdr (assoc 10 elst))
              dxfx  (rem (car dxf10) 1) ; get fraction only, remove hole number
              dxfy  (rem (cadr dxf10) 1)
              dxf11 (cdr (assoc 11 elst)) ; this if text is not LEFT justified
        )
        (if (not (equal '(0.0 0.0 0.0) dxf11))
          (setq dxfx (rem (car dxf11) 1)
                dxfy (rem (cadr dxf11) 1)
          )
        )
        (if (or (not(vl-some (function (lambda (x) (equal x dxfx fuzz))) '(0.0 0.25 0.5 0.75 1.0)))
                (not(vl-some (function (lambda (x) (equal x dxfy fuzz))) '(0.0 0.25 0.5 0.75 1.0))))
          (entmakex
            (list (cons 0 "CIRCLE")
                  (cons 6 "BYLAYER")
                  (cons 8 "0") ; layer
                  (assoc 10 elst)
                  (cons 39 0.0)
                  (cons 40 0.75) ; radius
                  (cons 62 256)
                  (cons 210 (list 0.0 0.0 1.0))
            )
          )
        )
      )
    )
    (princ "There are no text entity containing your search !")
  )
)
I've reached the age where the happy hour is a nap. ()
Windows 7 core i7 870 2.93 12GB
Please support this web site.

ssbp

  • Mosquito
  • Posts: 11
Re: ssget filter list
« Reply #18 on: July 20, 2012, 01:56:05 pm »
Thanks you

Yes! I have tried all possibilities. Everything! Still pursuing problem  :-(

CAB

  • Global Moderator
  • Needs a day job
  • Posts: 9881
Re: ssget filter list
« Reply #19 on: July 20, 2012, 02:41:35 pm »
How close to a perfect match do you need?
0.2500000  +/- .005  ?

0.245
0.255
I've reached the age where the happy hour is a nap. ()
Windows 7 core i7 870 2.93 12GB
Please support this web site.

ssbp

  • Mosquito
  • Posts: 11
Re: ssget filter list
« Reply #20 on: July 20, 2012, 04:07:25 pm »
0.00000000

I have also tried by changing value of fuzz i.e. - 0.00000000

CAB

  • Global Moderator
  • Needs a day job
  • Posts: 9881
Re: ssget filter list
« Reply #21 on: July 20, 2012, 04:23:35 pm »
0.0 will not work, object insertion points can vary. You need 0.00001 or something like that.
See for your self, try this on the text objects you think are in the correct position.
This is what I get 628.9996190536 258 0
You see it should be 629 but it is off by 0.000380946
Code: [Select]
(defun c:test()
  (setq ent (car(entsel))
        elst (entget ent)
        dxf10 (assoc 10 elst))
  (princ (strcat(rtos (cadr dxf10) 2 10)" "(rtos (caddr dxf10) 2 10)" "(rtos (cadddr dxf10) 2 10)))
  (princ)
)
Are you wanting to move the text to the exact location if they are not perfect?
« Last Edit: July 20, 2012, 04:27:57 pm by CAB »
I've reached the age where the happy hour is a nap. ()
Windows 7 core i7 870 2.93 12GB
Please support this web site.

CAB

  • Global Moderator
  • Needs a day job
  • Posts: 9881
Re: ssget filter list
« Reply #22 on: July 20, 2012, 06:15:21 pm »
OK try this for fixing the text.
Code: [Select]
(defun c:fe (/ ss i ent elst dxf10 dxf11 dxfx dxfy fuzz)
  (setq fuzz 0.00001)

  ; By MP
  (defun round (number by)
    (if (zerop by)
      number
      (+ (* (fix (/ number (setq by (abs by)))) by)
         (if (< (* 0.5 by) (rem number by))
           by
           0
         )
      )
    )
  )
  (defun myround (r) (* (round (/ r 0.25) 1.) 0.25))

  (if (setq ss (ssget (list '(0 . "TEXT") '(72 . 0))))
    (progn
      (setq i -1)
      (while (setq ent (ssname ss (setq i (1+ i))))
        (setq elst  (entget ent)
              dxf10 (assoc 10 elst)
              dxfx  (rem (cadr dxf10) 1) ; get fraction only, remove hole number
              dxfy  (rem (caddr dxf10) 1)
        )

        (if (or (not (vl-some (function (lambda (x) (equal x dxfx fuzz))) '(0.0 0.25 0.5 0.75 1.0)))
                (not (vl-some (function (lambda (x) (equal x dxfy fuzz))) '(0.0 0.25 0.5 0.75 1.0)))
            )
          (progn
            (setq newpoint (list 10 (myround (cadr dxf10)) (myround (caddr dxf10)) 0.0))
            (entmod (subst newpoint dxf10 elst))
            (entmakex
              (list (cons 0 "CIRCLE")
                    (cons 6 "BYLAYER")
                    (cons 8 "0") ; layer
                    (assoc 10 elst)
                    (cons 39 0.0)
                    (cons 40 0.75) ; radius
                    (cons 62 256)
                    (cons 210 (list 0.0 0.0 1.0))
              )
            )
          )
        )
      )
    )
    (princ "There are no text entity containing your search !")
  )
)
I've reached the age where the happy hour is a nap. ()
Windows 7 core i7 870 2.93 12GB
Please support this web site.

CAB

  • Global Moderator
  • Needs a day job
  • Posts: 9881
Re: ssget filter list
« Reply #23 on: July 25, 2012, 08:42:25 am »
Where did you go???
I've reached the age where the happy hour is a nap. ()
Windows 7 core i7 870 2.93 12GB
Please support this web site.

ssbp

  • Mosquito
  • Posts: 11
Re: ssget filter list
« Reply #24 on: September 07, 2012, 12:54:30 am »
Sorry guys,
I was busy with some urgent job on site.
I will be back within 2/3 days regarding this.

Thanks for reply.