(vl-cmdf "_.pedit" e "_r" "")
(defun c:rt ( / oldsnap pt1 pt2 obj ana)
(setq oldsnap (getvar 'osmode))
(setvar "osmode" 0)
(while
(setq ss (ssget "+.E:S:" (list (cons 0 "*line"))))
(if (= ss nil)
(alert "You have not picked \nPline or \nLine")
(progn
(setq obj (vlax-ename->vla-object (ssname ss 0)))
(if (= (vla-get-ObjectName obj) "AcDbLine")
(progn
(vlax-put-property obj 'startpoint pt2)
(vlax-put-property obj 'endpoint pt1)
)
(command "pedit" (ssname ss 0) "R" "")
)
)
)
)
(setvar "osmode" oldsnap)
(princ)
)
Nobody understand what i ask for. I ask to include the autocad reverse command in the code of the first post .If the arrows is red then reverse the polyline.
Thanks
Nobody understand what i ask for. I ask to include the autocad reverse command in the code of the first post .If the arrows is red then reverse the polyline.Just as Mhupp just said it's easy, you just have to do this
Thanks
(defun c:pld2 (/ *error* VxV clockwise-p acDoc ms ss i e j p a c h s f r d)
(vl-load-com)
(setq acDoc (vla-get-activedocument (vlax-get-acad-object))
ms (if
(eq (getvar 'cvport) 1)
(vla-get-paperspace acDoc)
(vla-get-modelspace acDoc)
)
)
(vla-startundomark acDoc)
(defun *error* (m)
(and m (not (wcmatch (strcase m) "*CANCEL*,*EXIT*,*QUIT*")) (princ (strcat "\nError: " m)))
(vla-endundomark acDoc)
(princ)
)
(defun VxV (a b)
(list (- (* (cadr a) (caddr b)) (* (caddr a) (cadr b)))
(- (* (caddr a) (car b)) (* (car a) (caddr b)))
(- (* (car a) (cadr b)) (* (cadr a) (car b)))
)
)
;(clockwise-p ename) ;
;argument: ;
; e - ename of curve ;
; closed 2D curve in WCS ;
;return: T for clockwise curve ;
;----the pacman shape (and probably more) ;
; doesn't work in acad2011 ;
;A curve has the same orientation as an ;
;infinitesimal segment positioned around its ;
;minima or maxima ;
;Stefan M. 11.11.2013 ;
(defun clockwise-p (e / p1 p2 p a b d f1 f2)
(vla-getboundingbox (vlax-ename->vla-object e) 'p1 'p2)
(setq p (vlax-curve-getparamatpoint e
(vlax-curve-getclosestpointtoprojection e
(mapcar '- (vlax-safearray->list p1) '(1 1 0))
'(1 0 0)
)
)
a (vlax-curve-getstartparam e)
b (vlax-curve-getendparam e)
d (if
(eq (cdr (assoc 0 (entget e))) "SPLINE")
(* 0.01 (- b a))
0.1
)
f1 (vlax-curve-getfirstderiv e (+ a (rem (+ p d) (- b a))))
f2 (vlax-curve-getfirstderiv e (+ a (rem (+ (- p d) (- b a)) (- b a))))
)
(minusp (caddr (VxV f2 f1)))
)
;selfinters[ecting object] ;
;argument: ;
; o - vla-object ;
; CLOSED 2D curve in WCS ;
;return: T for selfintersecting curve ;
;Stefan M. 11.11.2013 ;
(defun selfinters (o / a)
(or
(vl-catch-all-error-p
(setq a (vl-catch-all-apply 'vlax-invoke (list ms 'addregion (list o))))
)
(vla-delete (car a))
)
)
(if
(setq ss (ssget '((0 . "*POLYLINE,SPLINE,LINE"))))
(progn
(setq h (* 0.05 (getvar 'viewsize)))
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i)))
c (cond ((and ;arrows color
(vlax-curve-isplanar e)
(vlax-curve-isclosed e)
(not (selfinters (vlax-ename->vla-object e)))
)
(if (clockwise-p e) 1 3) ;green if clocwise, red if not
)
((if (< (car (vlax-curve-getstartpoint e)) (car (vlax-curve-getendpoint e))) 1 3))
)
)
(if (= c 1)
(progn
(vl-cmdf "_.pedit" e "_r" "")
(setq c 3)
)
)
(if
(eq (cdr (assoc 0 (entget e))) "SPLINE")
(setq s (vlax-curve-getstartparam e) ;start curve
f (vlax-curve-getendparam e)
j 10 ;10 arrows on a single spline
d (/ (- f s) j) ;segment "length" (in paramter units)
)
(setq s 0.0
j (fix (vlax-curve-getendparam e)) ;1 arrow per segment for polylines
d 1.0
)
)
(repeat j
(setq j (1- j)
r (+ s (* j d) (* 0.5 d)) ;current parameter
p (vlax-curve-getpointatparam e r)
a ((lambda (d) (atan (cadr d) (car d))) (vlax-curve-getfirstderiv e r))
)
(grdraw p (polar p (+ a (* pi 0.9)) h) c)
(grdraw p (polar p (- a (* pi 0.9)) h) c)
)
)
)
)
(vla-endundomark acDoc)
(princ)
)
Now you won't see the Red arrows, and all of your polylines will be counter clockwise, you should try to modify your lisps.Just as Mhupp just said it's easy, you just have to do this
Nice Zak26 but was thinking more of a one line edit.I was thinking something similar but in that line c is been setup, so you can't do something like that and also if you do that you leave c without a value so becomes an error
(if (clockwise-p e) (vl-cmdf "_.pedit" e "_r" ""))
before
(if (clockwise-p e) 1 3)