ziele_o2k Posted March 15, 2017 Posted March 15, 2017 Hi, I'm closing plines with this code: (vla-put-closed (vlax-ename->vla-object ent) :vlax-true) But some of my plines are closing with bulged segment, can someone help me, to write lisp where pline will be closing always with straight segment. Quote
BIGAL Posted March 15, 2017 Posted March 15, 2017 Works for me need an example that does not work. Quote
Tharwat Posted March 15, 2017 Posted March 15, 2017 Works for me need an example that does not work. Try to draw open LWpolyline with an arc as the last segment and use the codes from the OP above. (defun c:ClosePoly ( / ent fnd pnt get) ;; ---==={ Tharwat - Date: 15.Mar.2017 }===---;; ;; Close LWpolyline with straight segment ;; (and (setq ent (car (entsel "\nSelect polyline to close :"))) (= (cdr (assoc 0 (setq get (entget ent)))) "LWPOLYLINE") (setq pnt (cons 10 (mapcar '+ '(0. 0.) (vlax-curve-getendpoint ent)))) (setq fnd (member pnt get)) (entmod (append get (if (zerop (cdr (assoc 42 fnd))) '((70 . 1)) (list pnt '(70 . 1))))) ) (princ) ) Quote
Roy_043 Posted March 15, 2017 Posted March 15, 2017 @Tharwat: Keep in mind that the vlax-curve-getendpoint function returns a point in the WCS not the OCS. So your code will only work properly if the polyline is in a plane parallel to the XY plane of the WCS. (defun c:Test ( / enm obj) (if (and (setq enm (car (entsel))) (= "AcDbPolyline" (vla-get-objectname (setq obj (vlax-ename->vla-object enm)))) (= :vlax-false (vla-get-closed obj)) ) (progn (vla-setbulge obj (1- (/ (length (vlax-get obj 'coordinates)) 2)) 0.0) (vla-put-closed obj :vlax-true) ) ) ) Quote
BIGAL Posted March 15, 2017 Posted March 15, 2017 I did just that had an arc as last element, also tried two arcs one on each end, it may be something to do with the way I drew the arcs used lines + Arcs then a pedit and join to make a pline. Just tested again and if you draw a pline and use the arc option as last segment it draws a bulge as the closing connection, exploded the pline removed bulge and used pedit + Join adds a straight line ???? So way to go is join start point to end point. Quote
Tharwat Posted March 15, 2017 Posted March 15, 2017 @Tharwat:Keep in mind that the vlax-curve-getendpoint function returns a point in the WCS not the OCS. So your code will only work properly if the polyline is in a plane parallel to the XY plane of the WCS. Good point Roy, Thank you for paying my attention to this important issue. Quote
Lee Mac Posted March 15, 2017 Posted March 15, 2017 Another: (defun c:polyclose ( / b i s x ) (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "&=") (70 . 1) (-4 . "NOT>")))) (repeat (setq i (sslength s)) (setq x (reverse (entget (ssname s (setq i (1- i))))) b (assoc 70 x) ) (entmod (reverse (vl-list* (car x) (cadr x) '(42 . 0.0) (subst (cons 70 (logior 1 (cdr b))) b (cdddr x))))) ) ) (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.