(defun C:PL
-CW
()(Pl
-CW
-VVA
"_:L" t
));;;Clockwise (defun C:PL
-CCW
()(Pl
-CW
-VVA
"_:L" nil));;;CounterClockwise (defun C:PL
-CWA
()(Pl
-CW
-VVA
"_ALL" t
));;;Clockwise ALL (defun C:PL
-CCWA
()(Pl
-CW
-VVA
"_ALL" nil));;;CounterClockwise ALL (defun C:PLI
-CCW
()(Pl
-CW
-Irneb
"_:L" nil));;;CounterClockwise Irneb version (defun C:PLI
-CW
()(Pl
-CW
-Irneb
"_:L" t
));;;Clockwise Irneb version
(defun Pl
-CW
-Irneb
( mode what
/ int:i e1 res clk
+ ss
) ;;; posted Irneb
;;; url http://www.cadtutor.net/forum/showthread.php?59671-all-polylinienrichtungen-counterclockwise
;;; what - t Clockwise
;;; what - nil CounterClockwise
;;; mode - string for ssget "_:L" or "_ALL:
(princ (strcat "\n" (if what
"Clockwise mode" "CounterClockwise mode") " Select Polyline")) ss
(ssget mode '
((0 .
"*POLYLINE")))) ;;;Reverse CounterClockwise->Clockwise
(if (PL
-CounterClockWise
-p e1
) )
)
;;;Reverse Clockwise->CounterClockwise
(if (null (PL
-CounterClockWise
-p e1
)) )
)
)
)
)
(princ "\n\t")(princ clk
+)(princ (if what
" \tCounterClockwise (reverse)" " \tClockwise (reverse)")) (princ "\n\t")(princ (- int:i clk
+))(princ (if what
" \tClockwise" " \tCounterClockwise")) (defun Pl
-CW
-VVA
( mode what
/ int:i e1 res clk
+ ss
) ;;; Posted VVA
;;; Url http://www.cadtutor.net/forum/showthread.php?59671-all-polylinienrichtungen-counterclockwise
;;; what - t Clockwise
;;; what - nil CounterClockwise
(princ (strcat "\n" (if what
"Clockwise mode" "CounterClockwise mode") " Select Polyline")) ss
(ssget mode '
((0 .
"*POLYLINE")))) ;;;Reverse CounterClockwise->Clockwise
)
)
;;;Reverse Clockwise->CounterClockwise
)
)
)
)
(princ "\n\t")(princ clk
+)(princ (if what
" \tCounterClockwise (reverse)" " \tClockwise (reverse)")) (princ "\n\t")(princ (- int:i clk
+))(princ (if what
" \tClockwise" " \tCounterClockwise")) (setq pln
(vlax
-vla
-object
->ename pl
)) (setq ret
(pl:geom
-LWpolyline
-revers pln
))) ((= (pl:dxf
0 (entget pln
)) "POLYLINE") (setq ret
(pl:geom
-polyline
-revers pln
))) )
ret
)
(defun pl:geom
-LWpolyline
-revers
( lw
/ e x1 x2 x3 x4 x5 x6
) (setq lw
(vlax
-vla
-object
->ename lw
))) ) ;_ end of cond
)
) ;_ end of list
) ;_ end of cons
) ;_ end of apply
) ;_ end of apply
x6
) ;_ end of append
) ;_ end of append
) ;_ end of entmod
) ;_ end of defun
(defun pl:geom
-polyline
-revers
(ent_name /
_dxf-code-data tmp_ent
i poly_ent
vert_ent vertex_list
bulge_list start_width_list
end_width_list
)
(setq ent_name
(vlax
-vla
-object
->ename ent_name
))) ;; Reverse "POLYLINE"
i 0
) ;_ end of setq
(setq bulge_list
nil vertex_list
nil start_width_list
nil end_width_list
nil) (not (= "SEQEND" (pl:dxf
0 (setq tmp_ent
(entnext tmp_ent
))))) ;_ end of not (cons (pl:dxf
42 tmp_ent
) bulge_list
) vertex_list
start_width_list
(cons (pl:dxf
40 tmp_ent
) start_width_list
) ;_ end of cons
end_width_list
(cons (pl:dxf
41 tmp_ent
) end_width_list
) ) ;_ end of setq
) ;_ end of while
start_width_list
(append (cdr start_width_list
) ) ;_ end of append
) ;_ end of append
i 0
tmp_ent ent_name
poly_ent
(cdr (entget tmp_ent '
("*"))) ;;;Added to revers with XData poly_ent
) ;_ end of subst
poly_ent
) ;_ end of subst
) ;_ end of setq
) ;_ end of not
vert_ent
) ;_ end of subst
vert_ent
) ;_ end of subst
vert_ent
) ;_ end of subst
) ;_ end of setq
) ;_ end of progn
) ;_ end of while
) ;_ end of defun
)
;;; Function to test if polyline is counter-clock-wise
;;; obj= vla-object / ename of the polyline
;;; Result is nil if clockwise, T if counter-clockwise
(defun PL
-CounterClockWise
-p
(obj
/ ang ang1 ang2 angT param
) angT 0.0
)
(setq ang
(* (if (< ang
0.0) -1.0 1.0) (- (abs ang
) (* pi
2)))) )
ang1 ang2
)
)
(>= angT 0.0)
)
(defun pl:clockwise
-p
( lw
/ LST MAXP MINP
) minp
(vlax
-safearray
->list minp
)MaxP
(vlax
-safearray
->list MaxP
)(princ "\nType Pl-CW, PL-CWA (ClockWise) or PL-CCW, PL-CCWA (CounterClockWise) in command line") (princ "\nFor difficult cases with a polyline use PlI-CW (ClockWise) or PLI-CCW (CounterClockWise) in command line")