Message 1 of 8
2D (heavy) Polyline to LW Polyline
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I found some code that converts 2D Polyline to LW Polyline. It works great, but it is based on the Entmakex function. I would like to transform polylines using the ActiveX method with function AddLightWeightPolyline.
Below I post two routines.
The first converts 2D Polyline to LW Polyline using the Entmakex method. The second routine converts Circle to LW Polyline, which is based on the AddLightWeightPolyline function and is shown as an example. Thanks in advance for any help.
2D (heavy) Polyline to LW Polyline (Entmakex based)
(defun c:OldStyle2LwPolyline ( / pl plst xdata vtx vlst elst)
(setq pl (car (entsel))
plst (entget pl '("*"))
xdata (assoc -3 plst)
vtx (entnext pl)
)
(while (= (cdr (assoc 0 (setq vlst (entget vtx)))) "VERTEX")
(if (zerop (logand (cdr (assoc 70 vlst)) 16))
(setq elst (cons (vl-remove-if-not
(function
(lambda (x)
(member (car x) '(10 40 41 42))
)
)
vlst
)
elst
)
)
)
(setq vtx (entnext vtx))
)
(if (setq new
(entmakex
(append
(list
'(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
(assoc 410 plst)
(assoc 8 plst)
(cond
((assoc 39 plst))
(T '(39 . 0))
)
'(100 . "AcDbPolyline")
(cons 90 (length elst))
(cons 70 (logand 129 (cdr (assoc 70 plst))))
(cons 38 (last (caar elst)))
(assoc 210 plst)
)
(apply 'append (reverse elst))
(if xdata
(list xdata)
)
)
)
)
(entdel pl)
)
new
)
Circle to LW Polyline (ActiveX based)
(defun c:2p ( / ent spc obj)
(setq ent (car (entsel))
spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
obj (vlax-invoke spc 'addlightweightpolyline (apply 'append (list (reverse (cdr (reverse (vlax-curve-getstartpoint ent)))) (reverse (cdr (reverse (vlax-curve-getpointatparam ent pi)))))))
)
(vlax-put-property obj 'closed :vlax-true)
(foreach x '(0 1) (vla-setbulge obj x -1.0))
(vla-delete (vlax-ename->vla-object ent))
)