Mohamed_Essam_2000 Posted November 23 Posted November 23 (edited) I need a LISP to make a number of cuts of a particular length along the selected line. The first cut will be at the start point of the selected line, the second cut will be at the end point of the line, and the rest of the cuts will be distributed equally along the line. It will be better if the LISP allows multi-selection and entering the number & length of cut. The attached picture indicates the drawing required. Edited November 24 by Mohamed_Essam_2000 Quote
Steven P Posted November 23 Posted November 23 You could look at chainage LISPs to put a circle at the correct interval, and use these to trim the line? Quote
fuccaro Posted November 25 Posted November 25 (defun c:pp() (setq lines (ssget '((0 . "LINE"))) n (sslength lines)) (setq gaps (getint "how many gaps? ") gap (getdist "\ngap length? ")) (repeat n (setq line1 (ssname lines (setq n (1- n))) l1 (entget line1) pa (cdr (assoc 10 l1)) pb (cdr (assoc 11 l1)) lay (assoc 8 l1) len (distance pa pb) len1 (/ (- len (* gaps gap)) (1- gaps)) pd pb ) (repeat (1- gaps) (setq pc (mapcar '(lambda (b a c) (+ c (* (- b a) (/ gap len)))) pa pb pd)) (setq pd (mapcar '(lambda (b a c) (+ c (* (- b a) (/ len1 len)))) pa pb pc)) (entmake (list (cons 0 "LINE") (cons 10 pc) (cons 11 pd) lay)) ) (entdel line1) ) (setq lines nil) ) @Mohamed_Essam_2000 Please post your question *only* in the public area of the Forum. Are you sure you don't wish to learn coding? 1 Quote
fuccaro Posted November 25 Posted November 25 Some fun with colors (defun c:ii() (setq lines (ssget '((0 . "LINE"))) n (sslength lines)) (setq gaps (getint "how many gaps? ") gap (getdist "\ngap length? ")) (repeat n (setq line1 (ssname lines (setq n (1- n))) l1 (entget line1) pa (cdr (assoc 10 l1)) pb (cdr (assoc 11 l1)) lay (assoc 8 l1) len (distance pa pb) len1 (/ (- len (* gaps gap)) (1- gaps)) pd pb cl 0 ) (repeat (1- gaps) (setq pc (mapcar '(lambda (b a c) (+ c (* (- b a) (/ gap len)))) pa pb pd)) (setq pd (mapcar '(lambda (b a c) (+ c (* (- b a) (/ len1 len)))) pa pb pc)) (entmake (list (cons 0 "LINE") (cons 10 pc) (cons 11 pd) lay (cons 62 (setq cl (rem (1+ cl) 10))))) ) (entdel line1) ) ) 1 Quote
Mohamed_Essam_2000 Posted November 25 Author Posted November 25 (edited) Very nice. Thank you, bro. But I need all the lines yellow colored. Edited November 25 by Mohamed_Essam_2000 Quote
BIGAL Posted November 25 Posted November 25 (edited) Your home work and good time to start learning look into DXF code 62 which is color, and a hint yellow is 2. Look at what 1+ is doing also. Just use Google "dxf code 62 color Autocad" (cons 62 (setq cl (rem (1+ cl) 10))) Look at entmake examples here they should give you the answer. Edited November 25 by BIGAL 1 Quote
Mohamed_Essam_2000 Posted November 25 Author Posted November 25 7 minutes ago, BIGAL said: Your home work and good time to start learning look into DXF code 62 which is color, and a hint yellow is 2. Look at what 1+ is doing also. Just use Google "dxf code 62 color Autocad" (cons 62 (setq cl (rem (1+ cl) 10))) Look at entmake examples here they should give you the answer. Ok, I will try to do it. 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.