Jump to content

Recommended Posts

Posted

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.

Posted

It made breaks for me (though not all breaks were over 120deg).

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

Posted

The only part I commented out was the (command "_layer" ... line. Maybe there's something wrong in that..?

Posted

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.

Posted

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

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