SSGET: May I use a text object as a fence

SSGET: May I use a text object as a fence

Anonymous
Not applicable
1,257 Views
8 Replies
Message 1 of 9

SSGET: May I use a text object as a fence

Anonymous
Not applicable

Hello!

I have a selection Fence that find texts over a line (this is working fine)

(setq ssTXT (ssget "_F" (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget (ssname ssE1 Econt)) ))
                                          (list (cons 8 "TEXTO") (cons 0 "TEXT") (cons 410 "Model") )))

Next step I would like to find all lines over each text found 

(setq enR (ssname ssTXT 0)) ; (just using 0 as example)
(setq objR (vlax-ename->vla-object enR))

(setq p1 (cdr (assoc 10 (entget enR))))
(setq p2 (cdr (assoc 11 (entget enR))) )

(setq ssE1 (ssget "F" (list p1 p2) ; could not make this work out
                                     (list (cons 8 "LINES") (cons 0 "LWPOLYLINE,POLYLINE,LINE") (cons 410 "Model")) ))

 

I want to find out if those found ssE1 Lines do intersect with the ORIGIN FENCE Line

that was obtain in (entget (ssname ssE1 Econt)) 

If they do not intersect the text found should be ignored.

 

Check the attached image: My result should ignore R GEN PORTINHO text because the line behind it was not intersecting with the green Fence line over square 51. The intersect command was not listed in this post.

 

Can a text object be used as a FENCE argument?

 

Thanks in advance + regards,

Lzucco

 

0 Likes
Accepted solutions (1)
1,258 Views
8 Replies
Replies (8)
Message 2 of 9

marko_ribar
Advisor
Advisor

I suppose your ssE1 contains only LWPOLYLINE entities as you are obtaining only group 10 DXF - vertices data - LINES have both DXF10 and DXF11... Then if you are working with only LWPOLYLINES, then your green fence line will cross LWPOLYLINE in your picture and that LWPOLYLINE depending how long it is may and may not cross your described TEXT entity representing name of the street on other part of region you want to exclude in your findings... If you are searching for TEXT entities as fence, I suppose it could be done by finding bounding box of TEXT and checking intersections of that bounding box with LINES/LWPOLYLINES - CURVES in general...

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 3 of 9

ВeekeeCZ
Consultant
Consultant

Sure you can, this works:

(sslength (ssget "_F" (list (cdr (assoc 10 (entget (Car (entsel))))) (cdr (assoc 11 (entget (Car (entsel)))))) '((0 . "LINE"))))

But using code 11 of text if kinda tricky. It can be '(0 0 0)........

 

I would think that using (textbox) or (vla-getboundingbox) functions would be better.


0 Likes
Message 4 of 9

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

.... But using code 11 of text if kinda tricky. It can be '(0 0 0)......  (textbox) or (vla-getboundingbox) functions ....



 

Absolutely.  It's always 0,0,0 for ordinary left-justified Text.  For other justifications, it's the insertion point [which can be in 9 different places], and the code-10 entry is the left end of the baseline.  In many justifications the two of them as a Fence line would cover only a limited part of the extent of the Text, as here [the two blue grips, in Middle-Center-justified Text]:

TextGripsBB.PNG

With Top-Left/Middle-Left/Bottom-Left justifications, the 10 & 11 entries would "cover" almost no territory.

 

And the bounding box is a problem with Text at other-than-orthogonal angles, since it doesn't "follow the angle" of the Text, but is orthogonal [the red above].  The (textbox) result would require some translation to be usable, because [from the AutoLisp Reference]:
The points returned by textbox describe the bounding box of the text object as if its insertion point is located at (0,0,0) and its rotation angle is 0.

i.e. the green here:

TextBox.PNG

 

Kent Cooper, AIA
0 Likes
Message 5 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... My result should ignore R GEN PORTINHO text because the line behind it was not intersecting with the green Fence line over square 51. ....


 

And yet, another  Line that is also behind it  [the  R  SETE DE SETEMBRO  center-line] does  intersect the green fence line.  Would a routine need to be able to differentiate between more than one Line that it finds crossing the Text?  Presumably by considering only one that is at the same angle  [or the opposite direction]?

Kent Cooper, AIA
0 Likes
Message 6 of 9

Anonymous
Not applicable

Thanks for the hints so far.

 

About you question

Presumably by considering only one that is at the same angle  [or the opposite direction]?

 
I am afraid that I can find different directions and angles on that, specially because the green line is not always orthogonal.
I was hoping find a solution using text or his boundaries once I am pretty sure this logic can handle the issue. Probably I need to find another solution.
 
I wonder if a fence line can find a small piece of text over it should have a reverse engeneering to do the opposite.
??
 
Maybe using this... 
0 Likes
Message 7 of 9

Anonymous
Not applicable

It works, now I can use the polyline box created.

Thanks #Lee-Mac

 

just minor modifications... see adapted lisp file

 

In fact I just need this result 

(setq bt_list (mapcar '(lambda ( x ) (cons 10 x)) lst))

after

(setq lst (text-box-off enx (* off (cdr (assoc 40 enx)))))

 

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... I can use the polyline box created. ....


 

If:

A:  your Text is always Text [not Mtext or an Attribute];

and if as it seems for your purposes:

B:  you don't need the offset option [just the raw extents of the Text]; and

C:  you don't need the box to match the Text's various properties, but want it only for its geometry;

then this is all you really need to draw a Polyline box around it:

(defun C:BoxText (/ txt tdata tbox)
  (setq
    txt (car (entsel "\Text to draw box around: "))
    tdata (entget txt)
    tbox (textbox tdata)
  )
  (command
    "_.rectang" "_none" (car tbox) "_none" (cadr tbox)
    "_.move" (entlast) "" "_none" '(0 0 0) "_none" (cdr (assoc 10 tdata))
    "_.rotate" "_previous" "" "@" (angtos (cdr (assoc 50 tdata)) (getvar 'aunits) 8)
  )
)

It can be enhanced with the usual stuff, confirm appropriate selection, account for different UCS if that's a possibility, and all that, easily enough, if it does what you need otherwise.

Kent Cooper, AIA
Message 9 of 9

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... this is all you really need to draw a Polyline box around it:  ....


TCIRCLE can also do it [it doesn't make only Circles, but has a Rectangle option], and will do multiple objects, including also Mtext and AttDef's.  But curiously, it requires some  degree of offset outboard of the object's extents [it won't accept 0].

Kent Cooper, AIA
0 Likes