@zasanil wrote:
I tried the routine that you listed, but it doesn't seem to generate the correct output. ....
[I had mis-read your intent, exacerbated by assuming some things about what you meant from the Subject line, and not opening your sample drawing before....]
Your mention of Apparent Intersections got me thinking about another way of going about this, in process of which I found some interesting things that I had to account for. For instance, Osnapping to the Apparent Intersection always results in the location on the object that's "in front" in the drawing order [not based on something like elevation]. And I thought it shouldn't be necessary to limit yourself to Polylines -- it ought to work with Lines, and maybe even other things.
This works [in limited testing] in your sample drawing, even if some Polylines [red and/or green] are Exploded into Lines, and with the introduction of other object types for what you have as either the red or the green elements. It lacks an error handler and some other little tid-bits, so far, and it could also be made to prevent selection of Xlines or Mlines if there's any risk of those, return to the original view, etc. But it asks you only to select the red parts in your sample drawing -- you don't need to select the green ones.
(defun C:TEST (/ ss n ent len inc dist ptlist)
(command "_.ucs" "_world" "_.plan" "")
(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(alert "Select the non-3D crossing objects\n(not the different-level objects).")
(if (setq ss (ssget '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
(progn ; then
(command "_.draworder" ss "" "_back"); because Osnap AppInt goes to "front" object
(repeat (setq n (sslength ss))
(setq
ent (ssname ss (setq n (1- n)))
len (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
inc (/ len 20);;; edit for reasonable number to ensure hitting all app. ints.
dist (- inc)
ptlist nil ; [to clear previous one if any]
); setq
(repeat 21 ;;; edit if 'inc' divisor edited above [one more than divisor]
(setq pt
(osnap
(cond ; [sometimes calculated dist overshoots end, returns nil]
((vlax-curve-getPointAtDist ent (setq dist (+ dist inc))))
((vlax-curve-getEndPoint ent))
); cond
"_app"
); osnap
); setq
(if (not (member pt ptlist)) (setq ptlist (cons pt ptlist))); found different point
); repeat
(command "_3dpoly")
(apply 'command ptlist); trace along found apparent intersections
(command "")
); repeat
); progn
); if
(setvar 'osmode osm)
(princ)
); defun
Kent Cooper, AIA