Jump to content

Recommended Posts

Posted (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 by suriwaits
Posted

Express has a break routine built in you may be able to call it somehow from a lisp to automate.

Posted

Thanks Bigal for your valuable suggestion,

Posted

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)

Posted (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 by suriwaits
  • 11 months later...
Posted
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

Posted
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

Scrren shot.jpg

demo1.dwg

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