M76 Posted November 16, 2009 Share Posted November 16, 2009 What am I doing wrong? I'm trying to break all polylines where it has a greater angle than 120° (defun c:pro () (setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") ))) (if lof (progn (command "_layer" "_s" "_lay" "") (setq hlof (sslength lof)) (setq j 0) (while (< j hlof) (setq entx (ssname lof j)) (make-vert-list entx) (command "_zoom" "_o" "_si" entx) (setq vertex (length vert-list)) (setq i 0) (while (< (+ 2 i) vertex) (setq vertp1 (nth i vert-list)) (setq vertp2 (nth (1+ i) vert-list)) (setq vertp3 (nth (+ 2 i) vert-list)) (if (< (* 0.75 pi) (abs (- (angle vertp1 vertp2) (angle vertp2 vertp3)))) (command "point" vertp2) ;;debug (command "_break" vertp2 "@") ) (setq i (1+ i)) ) (setq j (1+ j)) (princ (strcat "\n " (itoa j) "/" (itoa hlof))) ) ) ) ) (defun make-vert-list (entli) (setq ent-pl (entget entli)) (setq ent-name (cdr (assoc 0 ent-pl))) (if (= ent-name "LWPOLYLINE") (progn (setq v-list nil) (foreach vert ent-pl (if (= 10 (car vert)) (setq v-list (cons (cdr vert) v-list)) ) ) ) ) ;if progn (setq vert-list v-list) ) ;make-vert-list But nothing happens, the line remains intact. Quote Link to comment Share on other sites More sharing options...
SteveK Posted November 17, 2009 Share Posted November 17, 2009 It made breaks for me (though not all breaks were over 120deg). Quote Link to comment Share on other sites More sharing options...
M76 Posted November 17, 2009 Author Share Posted November 17, 2009 It made breaks for me (though not all breaks were over 120deg). My mistake its 135, but then why does it do nothing for me? Quote Link to comment Share on other sites More sharing options...
SteveK Posted November 17, 2009 Share Posted November 17, 2009 The only part I commented out was the (command "_layer" ... line. Maybe there's something wrong in that..? Quote Link to comment Share on other sites More sharing options...
M76 Posted November 18, 2009 Author Share Posted November 18, 2009 its unrelated to the problem, I left it in the code by mistake. It works this way: (command "_.break" entx vertp2 "@") But in this case, its not possible to break the line in multiple places, because as soon as de first break occures the line becomes two separate entities, and it would ignore all except entx. Quote Link to comment Share on other sites More sharing options...
SteveK Posted November 18, 2009 Share Posted November 18, 2009 Hmm. I've just drawn in lwpolylines everywhere and run the lisp and it works fine. The only other thing different is we are using different products... Quote Link to comment Share on other sites More sharing options...
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.