Jump to content

Creation of automate polyline between dimension lines


Recommended Posts

Posted

need lisp for automatic creation of polyline

Posted

Hi .

 

Are you after drawing a polyline on the left side hand coordinates of the selected dimensions ?

Posted (edited)

I need for right side

Edited by rk25134
Posted
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)
)

Posted

thank you its working, please provide for left side also.

Posted
thank you its working, please change the below code to right side

 

Just change the number 13 to 14

Posted

After changing 13 to 14 I am getting incorrect way as please find the attached screenshot

Right side.JPG

Posted
After changing 13 to 14 I am getting incorrect way as please find the attached screenshot

 

Did you try my routine ?

Posted

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

Posted
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
Posted (edited)

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
Posted
working fine

 

Any another lisp

 

Since it is working fine , what is the need to ask for another lisp ? :danger:

Posted

Please find the attached screenshot. I Used latest routine and enter right option from the lisp

Right side.JPG

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