@Anonymous wrote:
....
1. Select the splines I want to convert.
2. Enter origin and n1, n2 values.
3. Convert to Polyline
(yellow/green lines: polylines that do not intersect splines;
Red line : Polyline crossing with splines) ....
Here's a start on a crossing-the-path [your red] version. It works on any kind of path object [anything in the (vlax-curve...) class -- Line, Polyline, Arc, Circle, Spline, Ellipse], one at a time. But it doesn't yet do a lot of things it could [verify selection of valid path object including forbidding Xline/Ray, do multiple paths, remember 'n1' & 'n2' values, error handling, etc.], and so far it always uses 0,0 for the origin. It can be made to ask for an origin, and have those other features, all with additional code, but see what you think of it so far.
(vl-load-com); if needed
(defun C:SPC ; = Stepped-Polyline Conversion
(/ round roundXY pathsel path pathlen closed stepH stepV
steps pathinc step lastpt plv1 roundpt roundX roundY)
(defun round (value to) ; modified from Joe Burke [no 'to' value of 0]
(* (atoi (rtos (/ (float value) to) 2 0)) to)
); defun -- round
(defun roundXY (pt)
(list (round (car pt) stepH) (round (cadr pt) stepV))
); defun -- roundXY
(setq
pathsel (entsel "\nPath to convert to stepped Polyline: ")
path (car pathsel)
pathlen (vlax-curve-getDistAtParam path (vlax-curve-getEndParam path))
closed (vlax-curve-isClosed path)
stepH (getdist "\nHorizontal stepping increment: ")
stepV (getdist "\nVertical stepping increment: ")
steps
(fix (/ pathlen (/ (min stepH stepV) 4))); arbitrary -- 1/4 of smaller step size
pathinc (/ pathlen steps)
step 0
); setq
(command "_.pline" "_none" (setq plv1 (roundXY (vlax-curve-getStartPoint path))))
(setq lastpt plv1)
(repeat (- steps (if closed 1 0))
(setq roundpt (roundXY (vlax-curve-getPointAtDist path (* pathinc (setq step (1+ step))))))
(if (not (or (equal roundpt lastpt 1e-4) (equal roundpt plv1 1e-4)))
(progn
(if
(or ; orthogonal from previous?
(equal (car roundpt) (car lastpt) 1e-4); same X
(equal (cadr roundpt) (cadr lastpt) 1e-4); same Y
); or
(command "_none" roundpt); then -- add it to Polyline
(progn ; else -- find nearer orthogonal next point
(setq
roundX (list (car lastpt) (cadr roundpt)); above or below previous
roundY (list (cadr lastpt) (car roundpt)); left or right of previous
roundpt ; replace
(if ; which is closer to path?
(<
(distance roundX (vlax-curve-getClosestPointTo path roundX))
(distance roundY (vlax-curve-getClosestPointTo path roundY))
); <
roundX ; then
roundY ; else
); if & roundpt
); setq
(command "_none" roundpt); add it to Polyline
); progn
); if
(setq lastpt roundpt)
); progn
); if
); if
(command (if closed "_close" ""))
); defun
EDIT:
Its initially calculated rounded locations at first sometimes resulted in diagonal segments, and I had worked out how to prevent that along the way, but it still needs some work to prevent that possibility at the Closing end of a closed path object:

I'll have to think about how to fix that one....
Kent Cooper, AIA