Author Topic: Challenge - Distance between parallel lines  (Read 9009 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge - Distance between parallel lines
« Reply #15 on: November 01, 2006, 11:56:19 PM »
Dave, i like you code. You overcame the ssget  distance limit but that created a problem with the specifications.
Quote
a point and a maximum distance to search away from the initial point
Your code checks the spread between the lines, in the case in the picture it should return nil.
« Last Edit: November 01, 2006, 11:57:23 PM by CAB »
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge - Distance between parallel lines
« Reply #16 on: November 02, 2006, 12:14:46 AM »
Well the adjustment was easy, hope you don't mind me messing with your code.
Code: [Select]
(defun findparallel (ppoint     pdisttol   /          baseline   currang
                      currdist   current    ename      idx        DistList
                      ss         testang    testpoint
                     )
  (setq baseline  (vlax-ename->vla-object (car (nentselp ppoint)))
        testpoint (vlax-curve-getclosestpointto baseline ppoint)
        testang   (rem (vla-get-angle baseline) pi)
        ss        (ssget "X" (list (cons 0 "LINE")
                                   (cons 8 (vla-get-layer baseline))
                                   (cons 410 (getvar "ctab")))
                  )
        idx       -1
  )
  (ssdel (vlax-vla-object->ename baseline) ss)
  (while (setq ename (ssname ss (setq idx (1+ idx))))
    (setq current (ssname ss idx)
          currang (rem (vla-get-angle (vlax-ename->vla-object current)) pi)
    )
    (if (equal currang testang 0.001)
      (if (>= pdisttol (distance
                         (vlax-curve-getclosestpointto current testpoint) testpoint))
        (setq currdist (distance
                         (vlax-curve-getclosestpointto current testpoint t)
                         testpoint)
            DistList (cons CurrDist DistList)
        )
      )
    )
  )
  (if (and DistList
           (setq MinDist (apply 'min DistList))
           (<= mindist pdisttol))
    mindist
    nil
  )
)
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.

SomeCallMeDave

  • Guest
Re: Challenge - Distance between parallel lines
« Reply #17 on: November 02, 2006, 07:48:31 AM »
No CAB, I don't mind you changing my code.   And I see your point about my mis-reading the specs.

I was blinded by
Quote
indicating the offset distance of the parallel line
  :)

Also,  I didn't understand this requirement
Quote
Something extra would be to limit the search to only those items that intersect a perpendicular point to the original point.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge - Distance between parallel lines
« Reply #18 on: November 02, 2006, 08:33:21 AM »
Quote
Something extra would be to limit the search to only those items that intersect a perpendicular point to the original point.
I didn't understand that either.
Perhaps Keith will give us some more explanation.
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.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Challenge - Distance between parallel lines
« Reply #19 on: November 02, 2006, 09:03:20 AM »
Quote
Something extra would be to limit the search to only those items that intersect a perpendicular point to the original point.

I'll try (in my poor English) to explain what I understood and and the way I tried to answer it in my codes.

The way is to search only lines parallel, on same layer, offseted within the search distance, and wich cross the perpendicular line (2D) or plane (3D) to the original line at original point.

Example : original line is from 0,0 to 120,0 original point is 90,0 search distance 20.0 a line from 100,10 to 200,10 should return 10.0 without "extra", nil with. If original point is 120,0 both should return 10.0

I edited my last code this way : replacing nil by T in the (inters ...) expression will retain only lines crossing the perpendicular plane to original line at picked point..
« Last Edit: November 02, 2006, 09:19:46 AM by gile »
Speaking English as a French Frog

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Challenge - Distance between parallel lines
« Reply #20 on: November 02, 2006, 09:16:26 AM »
It was more like an "extra credit" thing ... not specifically required, but would show whether the object was parallel to the point picked as well.

I don't want to change the challenge midstream, but if the user had a way to return 2 parameters (list maybe) or send an additional configurable argument to the routine to specify the apposing line "must be located at a point perpendicular" to the point selected.

Example:
(isParallel frompoint maxdistance T)



Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge - Distance between parallel lines
« Reply #21 on: November 02, 2006, 09:32:16 AM »
It was more like an "extra credit" thing ... not specifically required, but would show whether the object was parallel to the point picked as well.

I don't want to change the challenge midstream, but if the user had a way to return 2 parameters (list maybe) or send an additional configurable argument to the routine to specify the apposing line "must be located at a point perpendicular" to the point selected.

Example:
(isParallel frompoint maxdistance T)

Forgive my ignorance. What is "perpendicular to a point"?
I thought a point did not have a direction, so how can there be perpendicular?
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.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Challenge - Distance between parallel lines
« Reply #22 on: November 02, 2006, 10:25:02 AM »
Quote
send an additional configurable argument to the routine

I edit (one more time) the routine I posted this way.
Speaking English as a French Frog

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Challenge - Distance between parallel lines
« Reply #23 on: November 02, 2006, 10:29:19 AM »
Ok .. let me see if I can explain it a bit better .. I know I have not done very well up to now, but give me a minute and I will try once again.

After several thoughts on how to best word this, I think the best way to explain it would be as follows:

The parallel line should be able to be selected within a radius of a circle located at the original point as is indicated in the pic below.

The top is to be understood that a parallel line must intersect an imaginary line drawn at 90 deg to the main line within the distance specified
The middle is that a parallel line may be located at any point within the specified distance
The bottom is the same as the top, but shows that it selects the second line and omits the middle line because it does not intersect the dashed line as indicated

I sure hope I was able to explain it a bit better now.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge - Distance between parallel lines
« Reply #24 on: November 02, 2006, 12:42:29 PM »
Keith,
Thanks for the clarification.
Here is a scenario where there are 3 lines within the search radius & all are the same distance from the target line.
Are there any rules in this condition? :)

Just kidding. :evil:
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Challenge - Distance between parallel lines
« Reply #25 on: November 02, 2006, 12:45:42 PM »
Uh .. well, since the objective is to determine the closest distance between 2 parallel lines, the result would be the same .. for example if the distance was 12 for each one the result would be 12
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge - Distance between parallel lines
« Reply #26 on: November 03, 2006, 10:33:50 AM »
Yea, slap me for ignoring with the obvious. :-o
I lost track of the challenge as I am upgrading my "2 pick wall hatch" routine to a "One Pick" thanks to you & the others who participated in this thread.
 :-) :-) :-)
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.