Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Please help! A line is failing my parallel test lisp that I want to pass

Anonymous

Please help! A line is failing my parallel test lisp that I want to pass

Anonymous
No aplicable

Hello all!

 

I am having trouble with a few lines that are failing my Parallel line test lisp that I want to be passing. I pulled one of the lines into a new drawing and attached it. I have noticed that if I mirror the line, the new line will pass. However if I draw a completely new line and mirror that, both will pass. So I am stumped, please if anyone has any insight as to what is different about this line (its the yellow one on the top right) or can help me correct me lisp please let me know.

 

Thanks

 

toreyrueschhoff_0-1600264382514.png

 

0 Me gusta
Responder
Soluciones aceptadas (1)
674 Vistas
9 Respuestas
Respuestas (9)

Kent1Cooper
Consultant
Consultant
Solución aceptada

My guess is that this happens only with lines that are horizontal  within your tolerance value.  Some [considering those drawn from left to right] are going to be just barely over  0, at angles such as 0.OOOOOOOOOOO371 radians, and some are going to be just barely under  2pi, at angles such as 6.283185307179426 radians [instead of 2pi to the same number of decimal places = 6.283185307179587].  Those just barely under are going to remain just barely under pi after your

  (rem (vla-get-angle vlaEnt...) pi)

functions, so the comparison to barely over 0 will fail.

 

I think you need some kind of  (or)  situation to cover that possibility.  EDIT:  There may be a more concise way, but this should do it [untested]:

 

 

;if angle is equal to reference, turn to color red
  (if
    (or
      (equal refangle comangle 1e-12); basic same-direction check
      (and ; straddling horizontal?
        (or (equal refangle 0 1e-12) (equal refangle pi 1e-12))
        (or (equal comangle 0 1e-12) (equal comangle pi 1e-12))
      ); and
    ); or
    (vlax-put-property vlaEntcom 'Color 1); then
    (vlax-put-property vlaEntcom 'Color 2); else
  ); if

 

Kent Cooper, AIA

Anonymous
No aplicable

That makes a ton of sense, thank you! I am going to try to write that in and I'll get back to you.

0 Me gusta

dbroad
Mentor
Mentor

Seems like your test is acting correctly. The yellow line is non-parallel. See command log. The bottom right line is off but not enough to trigger your parallel test.

 

Command: (rtos (vla-get-angle(vlax-ename->vla-object(car(entsel)))) 2 14)
Select object: "0.00000000000000" ;reference line
Command: (rtos (vla-get-angle(vlax-ename->vla-object(car(entsel)))) 2 14)
Select object: "3.14159265358979" ;top left red test line
Command: (rtos (vla-get-angle(vlax-ename->vla-object(car(entsel)))) 2 14)
Select object: "3.14159265358975" ;top right yellow test line
Command: (rtos (vla-get-angle(vlax-ename->vla-object(car(entsel)))) 2 14)
Select object: "3.14159265358979" ;bottom left red test line
Command: (rtos (vla-get-angle(vlax-ename->vla-object(car(entsel)))) 2 14)
Select object: "3.14159265358984" ;bottom right red test line

 

Architect, Registered NC, VA, SC, & GA.
0 Me gusta

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... I am going to try to write that in ....


I edited my reply to include something, if it saves you the trouble [and if it actually works].

Kent Cooper, AIA
0 Me gusta

Anonymous
No aplicable

Yes thank you! Wrote it as a condition but it worked all the same. Cheers!

 

toreyrueschhoff_0-1600267534244.png

 And ignore the fuzz on that clips now I'm seeing how precise I can get it :cara_con_una_leve_sonrisa:

0 Me gusta

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Yes thank you! Wrote it as a condition but it worked all the same. Cheers!

toreyrueschhoff_0-1600267534244.png

 And ignore the fuzz on that clips now I'm seeing how precise I can get it :cara_con_una_leve_sonrisa:


That doesn't look right to me.  First condition: their directions are close enough to equal -- fine.  Second condition: the direction to be compared is close enough to pi no matter what the reference direction is!   Third condition: the direction to be compared is close enough to 0 no matter what the reference direction is!   You would get things considered parallel even with wildly different directions, as long as the 'comangle' line is horizontal.  I assume that's not what you want, but that you need to include consideration of both the reference and compared directions within each condition.

 

As to the precision:  Just use scientific notation, instead of all those strung-out zeros.  0.001 can be expressed as 1e-3 [the e is for the exponent on 10, so it = 1 x 10 to the minus-3rd power, or 1 divided by 10 to the 3rd power], and you can go with 1e-12 as in my earlier suggestion [equivalent to your initial decimal], and crank that up to 1e-13, 1e-14, etc.  But understand what you're asking:  1e-14 in radians is one hundred-trillionth of a radian, which [if my calculation is right] in degress/minutes/seconds comes to roughly a five-hundred-millionth of an arc second.  At some point it becomes meaningless....  An arc through that sweep angle with a radius of 1000  drawing units is about one hundred-billionth  of a drawing unit long.  And AutoCAD can keep track of only 16 significant figures, so you'll soon hit the limit of its ability to distinguish, and may as well leave out the fuzz factor entirely, and just ask for "exact" equality -- that's your maximum precision.

Kent Cooper, AIA

Anonymous
No aplicable

Ahh I see you have a good point

0 Me gusta

Anonymous
No aplicable

You are correct, thanks again. I got focused on passing my horizontal lines so much that I forgot to consider my design intent. And thank you for the tip of scientific notation!

0 Me gusta

Anonymous
No aplicable

This code has been tested and works.

0 Me gusta