suriwaits Posted September 3, 2014 Posted September 3, 2014 (edited) Hi, Attached is the planting boundary i have to create. if anybody has lisp to draw similar lines and willing to share , please share your code. Linetype wont work with as i need to hatch later if required. Thanks.. PS: I tried mkltype and used wmfout and wmfin. there is gap between shape and curved lines. planting.dwg Edited September 3, 2014 by suriwaits Quote
BIGAL Posted September 4, 2014 Posted September 4, 2014 Express has a break routine built in you may be able to call it somehow from a lisp to automate. Quote
suriwaits Posted September 4, 2014 Author Posted September 4, 2014 Thanks Bigal for your valuable suggestion, Quote
Tharwat Posted September 4, 2014 Posted September 4, 2014 Try this routine and it should do the trick as needed . NOTE: do not use the routine on arc segment of a polyline , cause you'd have unexpected result . (defun c:Test (/ s gr o p a b c d e ang prm pt l f lst) ;; Author : Tharwat Al Shoufi ;; ;; Date : 04. Sep. 2014 ;; (if (and (setq s (entsel "\n Select polyline :")) (eq (cdr (assoc 0 (entget (setq o (car s))))) "LWPOLYLINE") ) (progn (while (and (eq (car (setq gr (grread t 15 0))) 5) (not (redraw)) (setq p (vlax-curve-getclosestpointto o (cadr gr)) a (vlax-curve-getpointatdist o (- (vlax-curve-getdistatpoint o p) (/ 0.1709 2.))) b (vlax-curve-getpointatdist o (+ (vlax-curve-getdistatpoint o p) (/ 0.1709 2.))) ) (if (minusp (sin (- (angle a b) (angle b (cadr gr))))) (setq ang (angle b a)) (setq ang (angle a b)) ) (setq c (polar (polar a (+ ang (* pi 0.5)) 0.2103) (angle a b) 0.0341) d (polar p (+ ang (* pi 1.5)) 0.1823) e (polar c (angle a b) 0.1028) ) ) (grvecs (list -2 a c c d d e e b)) ) (if (and a b c d e) (progn (setq lst nil prm (fix (vlax-curve-getparamatpoint o a)) pt (vlax-curve-getpointatparam o prm) ) (foreach itm (entget o) (if (equal itm (setq f (list 10 (car pt) (cadr pt))) 0.0001) (setq lst (cons f lst) lst (cons (list 10 (car a) (cadr a)) lst) lst (cons (list 10 (car c) (cadr c)) lst) lst (cons (list 10 (car d) (cadr d)) lst) lst (cons (list 10 (car e) (cadr e)) lst) lst (cons (list 10 (car b) (cadr b)) lst) ) (setq lst (cons itm lst)) ) (if (eq (car itm) 90) (setq lst (cons (cons 90 (+ (cdr itm) 5)) lst)) ) ) (entmod (reverse lst)) (entupd o) ) ) ) ) (redraw) (princ) )(vl-load-com) Quote
suriwaits Posted September 6, 2014 Author Posted September 6, 2014 (edited) Try this routine and it should do the trick as needed . NOTE: do not use the routine on arc segment of a polyline , cause you'd have unexpected result . (defun c:Test (/ s gr o p a b c d e ang prm pt l f lst) ;; Author : Tharwat Al Shoufi ;; Hi Tharwat, Thank you very much for your code. Currently the code creates desired shape on each pick. Is there any other way to code it so that it could create desired shapes in one shot with input of shape size and spacinng. Also for curved segments, draw segmented poly line and incorporate shape in it. Edited September 6, 2014 by suriwaits Quote
anupmadhu Posted August 23, 2015 Posted August 23, 2015 Try this routine and it should do the trick as needed . NOTE: do not use the routine on arc segment of a polyline , cause you'd have unexpected result . (defun c:Test (/ s gr o p a b c d e ang prm pt l f lst) ;; Author : Tharwat Al Shoufi ;; ;; Date : 04. Sep. 2014 ;; (if (and (setq s (entsel "\n Select polyline :")) (eq (cdr (assoc 0 (entget (setq o (car s))))) "LWPOLYLINE") ) (progn (while (and (eq (car (setq gr (grread t 15 0))) 5) (not (redraw)) (setq p (vlax-curve-getclosestpointto o (cadr gr)) a (vlax-curve-getpointatdist o (- (vlax-curve-getdistatpoint o p) (/ 0.1709 2.))) b (vlax-curve-getpointatdist o (+ (vlax-curve-getdistatpoint o p) (/ 0.1709 2.))) ) (if (minusp (sin (- (angle a b) (angle b (cadr gr))))) (setq ang (angle b a)) (setq ang (angle a b)) ) (setq c (polar (polar a (+ ang (* pi 0.5)) 0.2103) (angle a b) 0.0341) d (polar p (+ ang (* pi 1.5)) 0.1823) e (polar c (angle a b) 0.1028) ) ) (grvecs (list -2 a c c d d e e b)) ) (if (and a b c d e) (progn (setq lst nil prm (fix (vlax-curve-getparamatpoint o a)) pt (vlax-curve-getpointatparam o prm) ) (foreach itm (entget o) (if (equal itm (setq f (list 10 (car pt) (cadr pt))) 0.0001) (setq lst (cons f lst) lst (cons (list 10 (car a) (cadr a)) lst) lst (cons (list 10 (car c) (cadr c)) lst) lst (cons (list 10 (car d) (cadr d)) lst) lst (cons (list 10 (car e) (cadr e)) lst) lst (cons (list 10 (car b) (cadr b)) lst) ) (setq lst (cons itm lst)) ) (if (eq (car itm) 90) (setq lst (cons (cons 90 (+ (cdr itm) 5)) lst)) ) ) (entmod (reverse lst)) (entupd o) ) ) ) ) (redraw) (princ) )(vl-load-com) Sir, Please give lisp which can convert any closed LWPOLYLINE to Ziz Zag lines as shown in the attached file (The enclosed area should remain the same. https://www.dropbox.com/s/0xo26ytciypwab3/demo.dwg?dl=0 Quote
anupmadhu Posted August 24, 2015 Posted August 24, 2015 Try this routine and it should do the trick as needed . NOTE: do not use the routine on arc segment of a polyline , cause you'd have unexpected result . (defun c:Test (/ s gr o p a b c d e ang prm pt l f lst) ;; Author : Tharwat Al Shoufi ;; ;; Date : 04. Sep. 2014 ;; (if (and (setq s (entsel "\n Select polyline :")) (eq (cdr (assoc 0 (entget (setq o (car s))))) "LWPOLYLINE") ) (progn (while (and (eq (car (setq gr (grread t 15 0))) 5) (not (redraw)) (setq p (vlax-curve-getclosestpointto o (cadr gr)) a (vlax-curve-getpointatdist o (- (vlax-curve-getdistatpoint o p) (/ 0.1709 2.))) b (vlax-curve-getpointatdist o (+ (vlax-curve-getdistatpoint o p) (/ 0.1709 2.))) ) (if (minusp (sin (- (angle a b) (angle b (cadr gr))))) (setq ang (angle b a)) (setq ang (angle a b)) ) (setq c (polar (polar a (+ ang (* pi 0.5)) 0.2103) (angle a b) 0.0341) d (polar p (+ ang (* pi 1.5)) 0.1823) e (polar c (angle a b) 0.1028) ) ) (grvecs (list -2 a c c d d e e b)) ) (if (and a b c d e) (progn (setq lst nil prm (fix (vlax-curve-getparamatpoint o a)) pt (vlax-curve-getpointatparam o prm) ) (foreach itm (entget o) (if (equal itm (setq f (list 10 (car pt) (cadr pt))) 0.0001) (setq lst (cons f lst) lst (cons (list 10 (car a) (cadr a)) lst) lst (cons (list 10 (car c) (cadr c)) lst) lst (cons (list 10 (car d) (cadr d)) lst) lst (cons (list 10 (car e) (cadr e)) lst) lst (cons (list 10 (car b) (cadr b)) lst) ) (setq lst (cons itm lst)) ) (if (eq (car itm) 90) (setq lst (cons (cons 90 (+ (cdr itm) 5)) lst)) ) ) (entmod (reverse lst)) (entupd o) ) ) ) ) (redraw) (princ) )(vl-load-com) Further sized down version which can open in autocad 2007 for convenience demo1.dwg 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.