Jump to content

Creation of automate polyline between dimension lines


rk25134

Recommended Posts

I need for right side

 

Try this ...

 

(defun c:Test (/ leg ss l)
 ;;    Tharwat 06. jan. 2014    ;;
 (defun leg (x e) (cdr (assoc x (entget e))))
 (if (setq ss (ssget '((0 . "*DIMENSION"))))
   (progn ((lambda (i / sn a b)
             (while (setq sn (ssname ss (setq i (1+ i))))
               (if (< (car (setq a (leg 13 sn))) (car (setq b (leg 14 sn))))
                 (setq l (cons b l))
                 (setq l (cons a l))
               )
             )
           )
            -1
          )
          (if (and l (> (length l) 1) (setq l (vl-sort l '(lambda (p q) (< (cadr p) (cadr q))))))
            (entmakex (append (list '(0 . "LWPOLYLINE")
                                    '(100 . "AcDbEntity")
                                    '(100 . "AcDbPolyline")
                                    (cons 90 (length l))
                                    '(70 . 0)
                              )
                              (mapcar (function (lambda (p) (cons 10 (list (car p) (cadr p))))) l)
                      )
            )
          )
   )
 )
 (princ)
)

Link to comment
Share on other sites

Yes your routine is working fine. need same for left side also.

 

Not a problem , here is a complete one to work on the two sides besides that one more option for both . ;)

 

Try it and let me know ...

 

(defun c:Test (/ leg _LW ss lt rt k)
 ;;    Tharwat 06. jan. 2014    ;;
 (defun leg (x e) (cdr (assoc x (entget e))))
 (defun _LW (pts)
   (entmakex (append (list '(0 . "LWPOLYLINE")
                           '(100 . "AcDbEntity")
                           '(100 . "AcDbPolyline")
                           (cons 90 (length pts))
                           '(70 . 0)
                     )
                     (mapcar (function (lambda (p) (cons 10 (list (car p) (cadr p))))) pts)
             )
   )
 )
 (princ "\n Select Dimensions ...")
 (if (setq ss (ssget '((0 . "*DIMENSION"))))
   (progn ((lambda (i / sn a b)
             (while (setq sn (ssname ss (setq i (1+ i))))
               (if (< (car (setq a (leg 13 sn))) (car (setq b (leg 14 sn))))
                 (setq rt (cons b rt)
                       lt (cons a lt)
                 )
                 (setq rt (cons a rt)
                       lt (cons b lt)
                 )
               )
             )
           )
            -1
          )
          (if (and (> (length lt) 1) (> (length rt) 1))
            (if (progn (initget 6 "Left Right Both")
                       (setq k (cond ((getkword (strcat "\n Specify a side [Left/Right/Both] < "
                                                        (cond (*side*)
                                                              ((setq *side* "Left"))
                                                        )
                                                        " > :"
                                                )
                                      )
                                     )
                                     (*side*)
                               )
                       )
                )
              (cond ((eq k "Left") (mapcar '_LW (list (vl-sort lt '(lambda (p q) (< (cadr p) (cadr q)))))))
                    ((eq k "Right") (mapcar '_LW (list (vl-sort rt '(lambda (p q) (< (cadr p) (cadr q)))))))
                    (t
                     (mapcar '_LW
                             (list (vl-sort lt '(lambda (p q) (< (cadr p) (cadr q))))
                                   (vl-sort rt '(lambda (p q) (< (cadr p) (cadr q))))
                             )
                     )
                    )
              )
            )
            (princ "\n <!> You should select two dimensions at least <!> ")
          )
   )
 )
 (princ)
)

  • Like 1
Link to comment
Share on other sites

Like to think the actual drawing would be more complex than the one you posted rk25134 , would you be so kind to post a more realistic drawing sample.

 

 

like so.PNG

Edited by pBe
Link to comment
Share on other sites

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