Passing a polyline entity to extrim

Passing a polyline entity to extrim

SORONW
Advocate Advocate
910 Views
5 Replies
Message 1 of 6

Passing a polyline entity to extrim

SORONW
Advocate
Advocate
(setq cl (Polyline (list (list (car ap) (cadr ap) 0) (list (car ap) (+ (cadr ap) pr7) 0) (list (+ (car ap) pr6) (+ (cadr ap) pr7) 0) (list (+ (car ap) pr6) (cadr ap) 0))))
(trim cl (list (+ (car ap) (/ pr6 2)) (- (cadr ap) (/ pr7 2)) 0))

(defun TRIM ( et pt /)
	(if
		(cond
			(etrim)
		(T (load "extrim.lsp" "") etrim)
		)
		(etrim et pt)
	)
	(setvar "highlight" 1)
)

(defun Polyline (lst)
 (entmakex (list (cons 0 "POLYLINE")
                 (cons 10 '(0 0 0))))
 (mapcar
   (function (lambda (p)
               (entmake (list (cons 0 "VERTEX") (cons 10 (trans p 1 0)))))) lst)
 (entmakex (list (cons 0 "SEQEND"))))

I've got the above bit of code, using some functions found here https://www.cadtutor.net/forum/topic/18257-entmake-functions/#comments The goal is to draw an open polyline (in this case, a rectangle missing a side), then pass that polyline to the trim function to trim all lines on one side. The shape gets drawn as expected, and no error message appears but the lines will remain untrimmed.  I've been able to make a similar situation with regular lines work correctly, but it doesn't seem to like polylines. My best guess is that something with passing the entity name is wrong, but I haven't yet figured out what.

 

Anyone have any suggestions? Thanks. 

 

EDIT: Its also worth mentioning that using the extrim command outside of the lisp routine functions as expected in this situation.

0 Likes
Accepted solutions (1)
911 Views
5 Replies
Replies (5)
Message 2 of 6

devitg
Advisor
Advisor

Please upload your sample.dwg

 

0 Likes
Message 3 of 6

SORONW
Advocate
Advocate

Heres the sample. The shapes in question are the two squares in the middle of the upper view.

0 Likes
Message 4 of 6

devitg
Advisor
Advisor

The fact is that EXTRIM "cut all" inside or outside the poly so the green and the yellow  lines

0 Likes
Message 5 of 6

Sea-Haven
Mentor
Mentor
Accepted solution

Ok try this

 

remove (setq cl and last bracket )

change (trim (entlast) (getvar 'extmax)) if want all

(trim (entlast) pt)

 

Had to guess ap pr6 pr7 add to code as dummys next time.

0 Likes
Message 6 of 6

SORONW
Advocate
Advocate

Thank you Sea.haven, your suggestion got me closer to a solution. When generating a part, the bottom notch trims as expected, but the top notch only trims the outer solid line. The hidden dashed line remains untrimmed. Whats interesting is that If I change the layer of the dashed line to the obj layer, the trim works as expected. This can be replicated outside of my code using extrim, so I suspect its an issue on that end. I will start a seperate topic for that investigation though.

0 Likes