TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: subbup on September 03, 2004, 12:20:27 AM
-
Hello all,
I need to modify existing pline according to new point_list.
For existing pline data in the form of Xdata and objectdata.
when we changed pline according to new point_list properties should be same.
Any Ideas
-
Do you have any code written? Do you want to use ActiveX or dxf code? What's the Xdata for?
-
As Daron points out, it can be done by manipulating the pline through the entity list or by updating the coordinates through ActiveX.
Changing the entity list requires a bit more work (or a least some more complex methods) than using ActiveX so I'd go for the latter.
If your point_list is a lisp list in the form of ((x1 y1 z1)(x2 y2 z2) ...), you'll need to weed out z's (if LWPOLY's) and assemble it into one long list. Below is a basic example of doing that.
If your pline is a 3Dpoly - or your point_list consists of 2D points only, you can just append all coordinates like (apply 'append point_list).
The other routine below simply builds the ActiveX data type required for coordinates and replaces the existing coordinates.
Note: These are not complete routines but might provide you with a starting point.
(defun make_coords (lst / new_lst)
(foreach pt lst
(setq new_lst (append (list (car pt) (cadr pt)) new_lst))
)
new_lst
)
(defun chpoly (pline point_list / pt_lst)
(and (not (= (type pline) 'vla-object))
(setq pline (vlax-ename->vla-object pline))
)
(cond ((setq point_list (make_coords point_list)
pt_lst (vlax-make-safearray
vlax-vbDouble
(cons 0 (1- (length point_list)))
)
)
(vlax-safearray-fill pt_lst point_list)
(vla-put-coordinates pline (vlax-make-variant pt_lst))
)
)
)