@Kent1Cooper wrote:
.... With a Block definition with the insertion point actually in the middle, I can picture an easy way to do what you're asking.
But it would also involve "plain" Insertions, using the lengths of the Polyline segments to calculate the X scale factor.....
Subject to that caveat, something like this [in simplest terms, lightly tested]:
(defun C:PL2PIPES (/ gpap ss n pl m)
(defun gpap (par) (vlax-curve-getPointAtParam pl par))
(setvar 'clayer "pipe")
(if (setq ss (ssget "_:L" '((0 . "*POLYLINE") (8 . "pipe root"))))
(repeat (setq n (sslength ss))
(setq pl (ssname ss (setq n (1- n))))
(repeat (setq m (fix (vlax-curve-getEndParam pl)))
(command "_.insert" "pipe"
"_X" (/ (distance (gpap m) (gpap (1- m))) 100)
"_non" (gpap (- m 0.5)); insertion point
"_non" (gpap m); rotation
); command
(setq m (1- m))
); repeat
(entdel pl)
); repeat
); if
(command "_.layerp")
(prin1)
); defun
It works on open or closed Polylines, "heavy" or "lightweight." Of course, it's suitable only to Polylines made up of only line segments -- your Block approach to pipe segments couldn't handle arc segments no matter what, anyway.
And it can use all the usual bells and whistles [*error* handling, creating the Layer if needed, Undo begin/end wrapping, etc.) and maybe some specialized ones [e.g. verify only line segments].
Kent Cooper, AIA