;; Save and restore variables on your own
;; A short & sweet method to break polylines
;; let me know if further updates can be done
(defun vrtxcnt ( / ent e v p vrtxpnts turns)
(setq ent (entget (setq e (car (entsel "Select a Path: ")))) v 0)
(cond
((eq (cdr (assoc 0 ent)) "LWPOLYLINE")
(setq v (cdr (assoc 90 ent)))
)
((eq (cdr (assoc 0 ent)) "POLYLINE")
(while (eq (cdr (assoc 0 (entget (setq e (entnext e))))) "VERTEX")
(setq vrtxpnts (cons (cdr (assoc 10 (entget e) )) vrtxpnts))
(setq v (1+ v))
)
)
)
(setq turns (cdr (vl-remove (last vrtxpnts) vrtxpnts)))
(princ (list ent vrtxpnts turns))
)
(defun c:b@v ( / vinfo ent vp vt)
(setq vinfo (vrtxcnt))
(setq vt (caddr vinfo))
(foreach X vt
( command "_break" (cdr (assoc -1 (car vinfo))) X "@" )
)
)
Here's the way I came up with to do that, a few years back. You can pick as many Polylines of any type(s) as you want in one running of the command and it will do it to all of them, it saves and restores System Variables for you, it works in different UCS's, and it does it in a way that doesn't need to figure out which type each one is nor pre-determine a count of how many places to Break each one. If you use AutoCAD 2015+, change the (command function name in the *error* handler near the top to (command-s .
@BillZ wrote:
You would be beter off just exploding the pline, setting a selection set of the "Previous" and then looping through the entities and making them back into polylines with width and so on. ....
..
[I know this is Replying to a very old Post, but for future generations....]
That may be relatively easy if the Polyline you started with has a constant width. But it would be impossible if the width varies. That's the main reason, in my opinion, that single-point-Breaking them at every vertex is the better way to go.
Not sure why this topic is zombified.
@Anonymous
If you use AutoCAD 2015+, change the (command function name in the *error* handler near the top to (command-s .
Hope you don't mind giving us more info of command-s,
i encountered an error i've never seen before that refers to vl.crx and more arx files when running programs on Autocad 14 using command-s on programs written for Autocad 2017, specifically (command-s "_Reverse" e). It took me a while to realize to whats going on.
pBe
@pbejse wrote:
....
Hope you don't mind giving us more info of command-s,
i encountered an error i've never seen before that refers to vl.crx and more arx files when running programs on Autocad 14 using command-s on programs written for Autocad 2017, specifically (command-s "_Reverse" e). It took me a while to realize to whats going on.
pBe
Here is Help [for 2016] on (command-s). Partway down it discusses differences from the (command) function. You can't use (command) inside an *error* handler [it's still perfectly acceptable elsewhere] in 2015+ unless you go through some other shenanigans to make it allowable. But too-early versions don't recognize (command-s) at all [there may be some overlap, perhaps a version or two in which (command-s) had been introduced but you could still use (command) in *error* handlers -- I'm not sure]. So since the main thing I've typically wanted to do with a command in an *error* handler is Undo End, I've taken to using (vl... methods for Undo begin and end, because they work in all versions, so the same code can be used anywhere, without making separate files for older and newer versions of AutoCAD.