WPerciful Posted January 12, 2015 Posted January 12, 2015 (edited) I have a series of blocks that I am replacing via lisp routine. But the new blocks are wider than the old ones. So I wrote the routine below to trim the lines that extend into a block. It works intermittently when the block is horizontal. I haven’t added the code to trim the lines if it’s vertical yet because I can’t figure out why the code doesn’t consistently work. The code is below and the attached drawing files has the blocks I’m using as an example. (defun trimblocklines ( ent / e d ins ero bw bh pt1 pt2 ss1 cnt sslen ) (setvar "cmdecho" 0) (setq e ent d (entget e) ins (cdr (assoc 10 d)) ero (* (dxf 50 d) (/ 180 pi)) bw 0.25 bh 0.125 pt1 (list (- (nth 0 ins) (/ bw 2)) (- (nth 1 ins) (/ bh 2)) (nth 2 ins)) pt2 (list (+ (nth 0 ins) (/ bw 2)) (+ (nth 1 ins) (/ bh 2)) (nth 2 ins)) ss1 (ssget "_C" pt1 pt2 '((0 . "line"))) cnt 0 sslen (sslength ss1) ln_ents (list ) ) (command "circle" ins (list (+ (nth 0 ins) (/ bw 2)) (nth 1 ins))) (setq cent (entlast)) (while (< cnt sslen) (setq ln_ents (append ln_ents (list (ssname ss1 cnt))) cnt (1+ cnt) ) ) (command "trim" cent ss1 "" (list (- (nth 0 ins) (- (/ bw 2) 0.01)) (nth 1 ins) 0.0) "") (command "trim" cent ss1 "" (list (+ (nth 0 ins) (- (/ bw 2) 0.01)) (nth 1 ins) 0.0) "") (entdel cent) (setvar "cmdecho" 0) (princ) ) trimlines.dwg Thank you Edited January 12, 2015 by WPerciful Fixed some code / removed a note in the code Quote
BIGAL Posted January 12, 2015 Posted January 12, 2015 Try Cookie cutter.lsp it has lots of options rather than try to get code to work. Quote
JamCAD Posted January 12, 2015 Posted January 12, 2015 Edit... Oops posted to wrong thread [emoji1] Quote
WPerciful Posted January 12, 2015 Author Posted January 12, 2015 I think the extrim command might get the job done but it's a lisp so I cann't use it. Is there a way to use the extrim command using vlisp? (defun trimblocklines ( ent / e d ins ero bw bh pt1 pt2 ss1 cnt sslen ) (setvar "cmdecho" 0) (setq e ent d (entget e) ins (cdr (assoc 10 d)) ero (* (cdr (assoc 50 d))(/ 180 pi)) bw 0.25 bh 0.125 pt1 (list (- (nth 0 ins) (/ bw 2)) (- (nth 1 ins) (/ bh 2)) (nth 2 ins)) pt2 (list (+ (nth 0 ins) (/ bw 2)) (+ (nth 1 ins) (/ bh 2)) (nth 2 ins)) ss1 (ssget "_C" pt1 pt2 '((0 . "line"))) cnt 0 sslen (sslength ss1) ln_ents (list ) ) (command "circle" ins (list (+ (nth 0 ins) (/ bw 2)) (nth 1 ins))) (setq cent (entlast)) (while (< cnt sslen) (setq ln_ents (append ln_ents (list (ssname ss1 cnt))) cnt (1+ cnt) ) ) (command "extrim" cent "" (list (- (nth 0 ins) (- (/ bw 2) 0.01)) (nth 1 ins) 0.0) "") (entdel cent) (setvar "cmdecho" 0) (princ) ) Quote
WPerciful Posted January 12, 2015 Author Posted January 12, 2015 Looking to see if I can modify this routine here, which is an amazing routine by Marko Ribar. I think the EXTRIM command works better than the TRIM command. Quote
Lee Mac Posted January 12, 2015 Posted January 12, 2015 The TRIM command can be very temperamental when evaluated from a LISP program - I would personally suggest using the BREAK command instead. Also, you should be aware that any active Object Snaps will affect the point supplied to the command - you should hence either temporarily disable Object Snap, or submit the "_non" or "_none" command modifier before supplying your points. Perhaps my Automatic Block Break program can help you with the task. Lee Quote
WPerciful Posted January 12, 2015 Author Posted January 12, 2015 The TRIM command can be very temperamental when evaluated from a LISP program - I would personally suggest using the BREAK command instead. Also, you should be aware that any active Object Snaps will affect the point supplied to the command - you should hence either temporarily disable Object Snap, or submit the "_non" or "_none" command modifier before supplying your points. Perhaps my Automatic Block Break program can help you with the task. Lee Lee, your “Automatic Block Break” program is AWESOME. It does everything I need. I have been working to replace many of our old blocks with new ones. The new blocks are wider. The only code I have left is the breaking of the lines. I am going to rewrite my routine to use the break command and add the “_non” command modifier before inputting the points. I'll post the new code once I have it. Thank you for all of the help! Quote
BIGAL Posted January 13, 2015 Posted January 13, 2015 You can use extrim with lisp a bit of a gotcha though about using it. (load "Extrim") (etrim obj pt1) ; need to use etrim to pick cut obj and then a pt inside or out etc Quote
Begde Posted March 10, 2015 Posted March 10, 2015 Lee you are a brilliant mind thank you for your help Quote
Lee Mac Posted March 10, 2015 Posted March 10, 2015 Lee you are a brilliant mind thank you for your help You are too kind Begde - thank you Quote
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.