Fuzz factor in calculations

Fuzz factor in calculations

scadcam
Contributor Contributor
1,537 Views
6 Replies
Message 1 of 7

Fuzz factor in calculations

scadcam
Contributor
Contributor

Hi,

 

Hope somebody could help me.

 

I have some closed plines. Each pline vertex has an associated id text. This text has an insertion point "coincident" with the pline vertex, except they may differ in the 4th decimal.

I want to get the text associated with each vertex with the following:

 

(defun findTextWithInsertionPoint (pt  )
   (ssget "_X" (list (cons 0 "TEXT")(cons 10 pt) ))
)

 

But it doesn´t work because coordinates differ in the 4th decimal or less.

Is there a system variable or something else that specifies a fuzz factor, so that points are considered same if they differ less than fuzz factor?

 

For example:    (equal expr1 expr2 [fuzz])     would consider expr1 and expr2 the same if they differ up to fuzz value.



 

0 Likes
Accepted solutions (3)
1,538 Views
6 Replies
Replies (6)
Message 2 of 7

martti.halminen
Collaborator
Collaborator
Accepted solution

 

You could just collect all the potentially interesting texts with SSGET, and go through them to pick the correct one yourself using EQUAL.

- undocumented, but it also works for lists in additional to single numbers, so no need to compare each coordinate separately.

 

-- 

Message 3 of 7

SeeMSixty7
Advisor
Advisor
Accepted solution

If you know that it is within the ten thousandths place, you could just use a crossing selection instead of a point. use the polar function to calculate a square that the point of the pline vertex. Use something like half the expected text height as your distance. some thing like

 

;;assuming the myvertexpoint is a vertex point and

;;your text height is typically 1/2" in height

(setq rectpt1 (polar myvertexpoint (* PI 0.25) (* mytxtheight 0.5))

        rectpt2 (polar myvertextpoint (*PI 1.25) (* mytxtheight 0.5))

)

 

Then use those two points in your selection set that specifies "TEXT" and crossing selection filters.

 

Good luck,

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@SeeMSixty7 wrote:

.... use a crossing selection instead of a point. use the polar function to calculate a square that the point of the pline vertex. Use something like half the expected text height as your distance. some thing like

.... (polar myvertexpoint (* PI 0.25) (* mytxtheight 0.5))

....


I was thinking along the same lines, but the size you would need that crossing window to be would depend on the nature of the anticipated Text content and/or justification.  For example, if it might ever have spaces, a window sized in that way could miss selecting the Text [utterly arbitrary content here, just as an example -- blue is the Polyline, white is the crossing window whose corners are from a (polar) function like the above, red Text is middle-center justified around the vertex]:

 

FindText.PNG

Kent Cooper, AIA
0 Likes
Message 5 of 7

SeeMSixty7
Advisor
Advisor

Good point! Agreed. The OP would need to determine just how big the crossing needs to be and it might be better to use a rectangle to compensate for the space possibility like you mentioned. If all the text was at 0 angle that would be a bit easier to deal with.

0 Likes
Message 6 of 7

scadcam
Contributor
Contributor

Thanks for the replies.

I was in a hurry and had to do it the hard way using equal with fuzz factor to compare pline vertex with insertion point.

So, I assume there is no such "fuzz factor" for this, though it would be nice to have it.

 

Regards

0 Likes
Message 7 of 7

john.uhden
Mentor
Mentor

I like @martti.halminen's idea the best.

 

Create a selection set of the candidate plines, and another selection set of the candidate texts.

For each vertex of each pline, find the text that is closest to the vertex.  I am thinking that a draftsman might have moved any of the texts slightly for readability, so a small fuzz factor may not yield any finds.  In fact, you wouldn't know what size fuzz factor to use.

 

Do you need the code?

John F. Uhden

0 Likes