Jump to content

Recommended Posts

Posted

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.

Posted
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)
 )

Posted

@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)
   )
 )
)

Posted

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.

Posted
@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.

Posted

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)
)

Posted

Thank you all for help :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...