Author Topic: ssget problem  (Read 4451 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
ssget problem
« on: March 10, 2006, 01:34:04 PM »
Here is the problem.  I have this routine that I'm working on that is supposed to grab text near another text (post in "Show off your stuff").  t-bear was telling me that it won't select some text, so I figured that the ucs must be rotated, so I started trouble shooting that.  I get a point list to use as a crossing polygon (I have a test where it will draw a polyline from those points so I know where the points are).  The points are around the text object, but it won't select it.  I looked into the help, and I didn't see any place that says you have to use points relative to the WCS.

I dumb founded as to why it won't select the text object.  Here was my test.  I drew a text object, and then rotated the ucs (around any axis) and it won't select the text object, but will drawing the polyline correctly.  Now rotate the ucs back to world, and it will select the text object now.  Here is how I'm selecting the text object.
Code: [Select]
(findtextnear (vlax-ename->vla-object (car (entsel))))

And here is the code to get the selection set of selected text object.
Code: [Select]
(progn
(defun MovePt- (Pt BasePt)
(mapcar '(lambda (a b) (- a b)) Pt BasePt)
)
;-----------------------------------------------------------------------------------------
(defun RotateZ (Pt Ang)
(list
 (+ (* (car Pt) (cos Ang)) (* (cadr Pt) (- (sin Ang))))
 (+ (* (car Pt) (sin Ang)) (* (cadr Pt) (cos Ang)))
 (caddr Pt)
)
)

;-----------------------------------------------------------------------------------------
(defun MovePt+ (Pt BasePt)
(mapcar '(lambda (a b) (+ a b)) Pt BasePt)
)

;-----------------------------------------------------------------------------------------
(defun FindTextNear (Obj / Obj tmpObj ll ur Dist Ang BsPt BsAng lr ul PtList ss tmpAng)

(setq tmpObj (vlax-invoke Obj 'Copy))
(vla-put-Rotation tmpObj 0.0)
(vla-GetBoundingBox tmpObj 'll 'ur)
(setq ll (safearray-value ll))
(setq ur (safearray-value ur))
(setq Dist (* (vla-get-Height tmpObj) 1.5))
(setq Ang (vla-get-Rotation tmpObj))
(setq BsPt
 (vlax-get
  Obj
  (if (equal (vla-get-Alignment Obj) 0)
   'InsertionPoint
   'TextAlignmentPoint
  )
 )
)
(vla-Delete tmpObj)
(setq BsAng (vla-get-Rotation Obj))
(setq lr (append (list (car ur)) (cdr ll)))
(setq ul (append (list (car ll)) (cdr ur)))
(setq ll (polar ll (+ Ang (DTR 270)) Dist))
(setq lr (polar lr (+ Ang (DTR 270)) Dist))
(setq ur (polar ur (+ Ang (DTR 90)) Dist))
(setq ul (polar ul (+ Ang (DTR 90)) Dist))
(setq PtList
 (mapcar
  '(lambda (x)
   (trans (MovePt+ (RotateZ (MovePt- x BsPt) BsAng) BsPt) 0 1)
  )
  (list ll lr ur ul)
 )
)
(command "_.pline") (foreach pt PtList (command pt)) (command "_c")
(setq ss
 (ssget
  "cp"
  (list ll lr ur ul)
  (list
   '(0 . "TEXT")
   '(-4 . "<AND")
    '(-4 . "<=")
     (cons 50 (+ BsAng 0.001))
    '(-4 . ">=")
     (cons 50
      (if (< (setq tmpAng (- BsAng 0.001)) 0.0)
       0.0
       tmpAng
      )
     )
   '(-4 . "AND>")
  )
 )
)
)
); end progn

Any help/insight is appreciated.
Thanks in advance.


Edit: Added the main code into a (progn... for easy copy/paste'ing into Acad.
« Last Edit: March 10, 2006, 01:49:52 PM by T.Willey »
Tim

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

Please think about donating if this post helped you.

LE

  • Guest
Re: ssget problem
« Reply #1 on: March 10, 2006, 01:43:44 PM »
I have not tested your routine, will do later...

Have you consider to have the texts inside of a dictionary and use their handle and then, just grab them from there?...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ssget problem
« Reply #2 on: March 10, 2006, 01:48:37 PM »
I have not tested your routine, will do later...
Thanks.

Have you consider to have the texts inside of a dictionary and use their handle and then, just grab them from there?...

I don't see how I could do this.  All the text is existing in the drawing.  When you select one, it will see what is around it, and add it to a select set, so you can treat it as one group.  If you want to scale it, or rotate it, then you can do it by selection set, and not have it over lapping with each other, as if you did it one by one with entmod.

Maybe I don't understand what you are thinking, but this is how I was thinking.
Tim

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

Please think about donating if this post helped you.

LE

  • Guest
Re: ssget problem
« Reply #3 on: March 10, 2006, 01:50:36 PM »
I am about to test your routine, sorry... have not tried as I mentioned.

 :-(

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ssget problem
« Reply #4 on: March 10, 2006, 01:51:33 PM »
I am about to test your routine, sorry... have not tried as I mentioned.

 :-(
No problem. :-)  Maybe a little back ground will help others understand why I did it.
Tim

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

Please think about donating if this post helped you.

LE

  • Guest
Re: ssget problem
« Reply #5 on: March 10, 2006, 01:59:13 PM »
Tim,

I downloaded your lisp, and type some DTEXT on a new drawing from scratch... and is not doing nothing....  :-(

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ssget problem
« Reply #6 on: March 10, 2006, 02:06:18 PM »
Man....

Do you have (vl-load-com) in any lisp files that load?  If not try that, and then try the code.  I just opened a new drawing, drew a text entity, copied the code from my first post, then the select method, and boom.. there way a polyline, and a selection set.  Then I rotated my ucs around the z axis, 90 degrees, ran the selection part again, and the polyline is drawn but no selection set.
Tim

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

Please think about donating if this post helped you.

LE

  • Guest
Re: ssget problem
« Reply #7 on: March 10, 2006, 02:11:50 PM »
Tim;

I am aware of the loading of visual lisp activex extensions.... you have that call by the way in your routine code..

I'll look more closely into your code... and see what is doing... so far is not selecting anything.

I type some DTEXT run the command ROTEXT and does not work.... or maybe is just me.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ssget problem
« Reply #8 on: March 10, 2006, 02:15:58 PM »
Oh sorry about that.  Don't use that command.  It will only rotate text that is rotated 180 degrees back to zero degrees.  My mistake.  I just want people to know where the rest of the code was at, but you can use the one posted in my first post here, and it will do what I'm talking about.

Sorry about that Luis.
Tim

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

Please think about donating if this post helped you.

LE

  • Guest
Re: ssget problem
« Reply #9 on: March 10, 2006, 02:26:43 PM »
No problem Tim;

No I understand what your routine does... something I noticed it does not place the text in the original location... that was the intention?

Thanks.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ssget problem
« Reply #10 on: March 10, 2006, 02:30:21 PM »
That one was done fast, so I just picked the first text object in the select set, and rotated it around that insertion point.
Tim

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

Please think about donating if this post helped you.

LE

  • Guest
Re: ssget problem
« Reply #11 on: March 10, 2006, 02:34:21 PM »
Tim;

Have you thinking of changing the use vla-GetBoundingBox for the textbox instead?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget problem
« Reply #12 on: March 10, 2006, 02:35:05 PM »
Tim,
No time to test but did you try to rotate the ucs back to world just before the ssget. Of course you will have to alter the cp points, but I was wondering if the ssget was looking at the rotation as world & not ucs.
Now that i think about it if you rotate ucs 180 deg & then test for + or - .001 from zero in your ssget  that will tell you if the ssget filter is using world rotation & not usc.
just a guess. Hope that made sense.
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: ssget problem
« Reply #13 on: March 10, 2006, 02:47:14 PM »
Alan,

This is from my last post in other thread about the routine.
Quote from: Me.
So you canceled it t-bear?  The file I posted will only select text (dtext and mtext) that has a rotation of 180 degrees.  If you have text like that, and it won't grab them, then something is wrong.  Was your text created in a different UCS?  I see in some quick little tests, is that when it is, the rotation is still relative to the WCS, so that the rotation won't work correctly.  I will look into this and see what I can come up with if the routine is something you think you would use.
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ssget problem
« Reply #14 on: March 10, 2006, 03:01:13 PM »
I found the answer.  I did something really, and I mean really stupid.  I trans the points to the current ucs, but then I used the old points to get the selection set.  Once I supplied the translated points it worked.
Code: [Select]
(setq PtList
(mapcar
  '(lambda (x)
   (trans (MovePt+ (RotateZ (MovePt- x BsPt) BsAng) BsPt) 0 1)
  )
  (list ll lr ur ul)
)
)
(command "_.pline") (foreach pt PtList (command pt)) (command "_c")
(setq ss
(ssget
  "cp"
  (list ll lr ur ul)
  (list
   '(0 . "TEXT")
   '(-4 . "<AND")
    '(-4 . "<=")
     (cons 50 (+ BsAng 0.001))
    '(-4 . ">=")
     (cons 50
      (if (< (setq tmpAng (- BsAng 0.001)) 0.0)
       0.0
       tmpAng
      )
     )
   '(-4 . "AND>")
  )
)
Should have been.

Quote
(setq PtList
(mapcar
  '(lambda (x)
   (trans (MovePt+ (RotateZ (MovePt- x BsPt) BsAng) BsPt) 0 1)
  )
  (list ll lr ur ul)
)
)
(command "_.pline") (foreach pt PtList (command pt)) (command "_c")
(setq ss
(ssget
  "cp"
  PtList ; Line that needed to be changed.
  (list
   '(0 . "TEXT")
   '(-4 . "<AND")
    '(-4 . "<=")
     (cons 50 (+ BsAng 0.001))
    '(-4 . ">=")
     (cons 50
      (if (< (setq tmpAng (- BsAng 0.001)) 0.0)
       0.0
       tmpAng
      )
     )
   '(-4 . "AND>")
  )
)

The color didn't work on my preview, but I will leave it in because maybe it will work for others.

Edit:  Thanks Alan for making the color show correctly.
« Last Edit: March 10, 2006, 06:41:16 PM by T.Willey »
Tim

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

Please think about donating if this post helped you.