+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default Diagonal Lines for Outer rectangles to Inner rectangle

    Registered forum members do not see this ad.

    Can some one help? need Diagonal Lines by selecting all and draw Diagonal lines in between outer rectangle to inner maximum size rectangle.

    Thank you.
    Attached Files

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,071

    Default

    Hi,

    Be sure to have the external rectangles visible in the screen and just select the external rectangles as the message of the program indicates to:

    Code:
    (defun c:Test (/ int sel ent rct pts vol nos are obj big lst dis lng pnt)
      ;;	Tharwat - Date: 09.Nov.2017	;;
      (princ "\nSelect external Rectangles only with four corners :")
      (if (setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4))))
        (while (setq ent (ssname sel (setq int (1+ int))))
          (and
            (setq rct (ssget "_WP"
                             (setq pts (mapcar 'cdr
                                               (vl-remove-if-not
                                                 '(lambda (p) (eq (car p) 10))
                                                 (entget ent)
                                               )
                                       )
                             )
                             '((0 . "LWPOLYLINE") (90 . 4))
                      )
            )
            (progn
              (setq vol 0.0)
              (repeat (setq nos (sslength rct))
                (if (> (setq
                         are (vlax-curve-getarea
                               (setq obj (ssname rct (setq nos (1- nos))))
                             )
                       )
                       vol
                    )
                  (setq vol are
                        big obj
                  )
                )
              )
              big
            )
            (= (length (setq lst (mapcar 'cdr
                                         (vl-remove-if-not
                                           '(lambda (p) (eq (car p) 10))
                                           (entget big)
                                         )
                                 )
                       )
               )
               4
            )
            (mapcar
              '(lambda (vrx)
                 (setq pnt (car lst)
                       dis (distance vrx pnt)
                 )
                 (mapcar '(lambda (cor)
                            (if (< (setq lng (distance vrx cor)) dis)
                              (setq pnt cor
                                    dis lng
                              )
                            )
                          )
                         lst
                 )
                 (entmake (list '(0 . "LINE") (cons 10 vrx) (cons 11 pnt)))
               )
              pts
            )
          )
        )
      )
      (princ)
    ) (vl-load-com)
    Attached Images

  3. #3
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    hi Tharwat,
    thank you..it is perfect working.

  4. #4
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    528

    Default

    Here's another for fun
    Code:
    (defun c:foo (/ b p pts s s2 x)
      ;; RJP - 11.19.2017
      ;; Code assumes that the outer polylines have the same area
      (if
        (and
          (setq s (ssget '((0 . "LWPOLYLINE") (-4 . "<OR") (70 . 1) (70 . 129) (-4 . "OR>") (90 . 4))))
          (setq s (vl-sort (mapcar '(lambda (x) (cons (vlax-curve-getarea x) x))
    			       (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
    		       )
    		       '(lambda (a b) (> (car a) (car b)))
    	      )
          )
          (setq s (vl-remove-if
    		'(lambda (x) (and (equal (caar s) (car x) 1e-8) (setq s2 (cons (cdr x) s2))))
    		s
    	      )
          )
          (setq s (mapcar 'cdr s))
        )
         (foreach a	s2
           (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget a))))
           (setq p (car pts))
           (if (setq b (car	(vl-sort s
    				 '(lambda (a b)
    				    (< (distance p (vlax-curve-getclosestpointto a p))
    				       (distance p (vlax-curve-getclosestpointto b p))
    				    )
    				  )
    			)
    		   )
    	   )
    	 (foreach p pts
    	   (entmakex (list '(0 . "line")
    			   (assoc 8 (entget a))
    			   (cons 10 p)
    			   (cons 11 (vlax-curve-getclosestpointto b p))
    		     )
    	   )
    	 )
           )
         )
      )
      (princ)
    )
    (vl-load-com)
    Attached Images

  5. #5
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,071

    Default

    Quote Originally Posted by Raje View Post
    hi Tharwat,
    thank you..it is perfect working.
    You are welcome.

  6. #6
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    helo ronjonp,
    another version of your code also excellent.

    Thankyou....

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    528

    Default

    Quote Originally Posted by Raje View Post
    helo ronjonp,
    another version of your code also excellent.

    Thankyou....
    Glad to help

  8. #8
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    helo ronjonp,
    if different size of outer rectangles not getting diagonal lines. please fix to work any size outer rectangles.

    Thank you...

  9. #9
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    528

    Default

    Quote Originally Posted by Raje View Post
    helo ronjonp,
    if different size of outer rectangles not getting diagonal lines. please fix to work any size outer rectangles.

    Thank you...
    Post an example drawing. We'd need to define an area rule of what is considered an 'outer' rectangle.

    Actually try this:
    Code:
    (defun c:foo (/ b p pts s s2 x)
      ;; RJP - 11.10.2017
      (if
        (and
          (setq s (ssget '((0 . "LWPOLYLINE") (-4 . "<OR") (70 . 1) (70 . 129) (-4 . "OR>") (90 . 4))))
          (setq s (vl-sort (mapcar '(lambda (x) (cons (vlax-curve-getarea x) x))
    			       (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
    		       )
    		       '(lambda (a b) (> (car a) (car b)))
    	      )
          )
          (setq s (vl-remove-if
    		'(lambda (x) (and (> (/ (car x) (caar s)) 0.5) (setq s2 (cons (cdr x) s2))))
    		s
    	      )
          )
          (setq s (mapcar 'cdr s))
        )
         (foreach a	s2
           (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget a))))
           (setq p (car pts))
           (if (setq b (car	(vl-sort s
    				 '(lambda (a b)
    				    (< (distance p (vlax-curve-getclosestpointto a p))
    				       (distance p (vlax-curve-getclosestpointto b p))
    				    )
    				  )
    			)
    		   )
    	   )
    	 (foreach p pts
    	   (entmakex (list '(0 . "line")
    			   (assoc 8 (entget a))
    			   (cons 10 p)
    			   (cons 11 (vlax-curve-getclosestpointto b p))
    		     )
    	   )
    	 )
           )
         )
      )
      (princ)
    )
    (vl-load-com)
    Attached Images
    Last edited by ronjonp; 10th Nov 2017 at 05:12 pm.

  10. #10
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    Registered forum members do not see this ad.

    hi ronjonp,

    it is working. thank you for updating code and advice.

Similar Threads

  1. Blurry text and diagonal lines
    By ThingsNStuff in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 26th Sep 2017, 09:22 am
  2. Lisp for diagonal lines for selected rectangles
    By structo in forum AutoLISP, Visual LISP & DCL
    Replies: 33
    Last Post: 29th Nov 2016, 02:08 pm
  3. Why diagonal construction lines?
    By Vagulus in forum Autodesk Inventor
    Replies: 3
    Last Post: 28th May 2014, 11:55 pm
  4. Diagonal Lines
    By HHRC in forum AutoCAD General
    Replies: 6
    Last Post: 22nd Jul 2007, 03:29 am
  5. removing diagonal lines that show curves??!!
    By MikeP in forum AutoCAD 3D Modelling & Rendering
    Replies: 2
    Last Post: 3rd May 2007, 04:06 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts