TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DEVITG on September 17, 2006, 09:23:31 PM
-
For a given LightWeightPolyline , I have a point on it , that is not a vertex.
How could I get the coordinates af the 2 new polys , if I want it to be splited at such point.
Of course I have the coordinates of the poly ,and the point too.
Also i have the param at such point.
The task shall be done in VLISP , no command or VL-CMDF
So I will have the coordinates, as safearray, for the two new polys, as to build it by
(vla-addLightWeightPolyline modsp left-poly-saf )
Thanks in advance.
-
Well, I saw this request at the Adesk NG first, so my reponse is posted there, too......
There are a couple different methods you could use.
This is how I'd do it:
;;requires a LWPOLYLINE as a (vla-object) and a 2d or 3d point that lies on
the pline.
(defun break-pline (pline pt / coords1 coords2 endparam idx ms pline1 pline2
ptparam tmp)
(setq ptparam (vlax-curve-getparamatpoint pline pt)
endparam (vlax-curve-getendparam pline)
idx -1
)
(if (> (length pt) 2)
(setq pt (list (car pt) (cadr pt)))
)
(while (< (setq idx (1+ idx)) ptparam)
(setq coords1 (cons (vlax-get-property pline 'coordinate idx) coords1))
)
(setq tmp (mapcar '(lambda (x)
(vlax-safearray->list
(vlax-variant-value x)))
(reverse coords1)))
(setq coords1 (apply 'append tmp)
coords1 (append coords1 pt)
idx (1- idx))
(while (<= (setq idx (1+ idx)) endparam)
(setq coords2 (cons (vlax-get-property pline 'coordinate idx) coords2))
)
(setq tmp (mapcar '(lambda (x)
(vlax-safearray->list
(vlax-variant-value x)))
(reverse coords2)))
(setq coords2 (apply 'append tmp)
coords2 (append pt coords2))
(setq ms (vla-get-modelspace (vla-get-activedocument
(vlax-get-acad-object))))
(setq pline1 (vlax-invoke ms 'addlightweightpolyline coords1)
pline2 (vlax-invoke ms 'addlightweightpolyline coords2)
)
;;;add code here to allow for Bulges, widths, layers, etc.
;;;If you want the original pline deleted, do that here, too.
)
-
Hi Jeff, thanks for it