Jump to content

move arrow head to the nearest point


CADWORKER

Recommended Posts

Hi,

A start with your drawing

(defun c:FOO ( / ss n dxf_ent pt ss_c i nw_pt a d)
  (setq ss (ssget "_X" '((0 . "LEADER"))))
  (cond
    (ss
      (repeat (setq n (sslength ss))
        (setq
          dxf_ent (entget (ssname ss (setq n (1- n))))
          pt (cdr (assoc 10 dxf_ent))
        )
        (cond
          ((setq ss_c (ssget "_C" (mapcar '- pt '(0.5 0.5 0.0)) (mapcar '+ pt '(0.5 0.5 0.0)) '((0 . "INSERT,POINT"))))
            (repeat (setq i (sslength ss_c))
              (setq nw_pt (cdr (assoc 10 (entget (ssname ss_c (setq i (1- i)))))))
              (cond
                ((> (cadr nw_pt) (cadr pt))
                  (setq
                    a (angle pt nw_pt)
                    d (distance pt nw_pt)
                  )
                  (foreach e dxf_ent
                    (if (eq (car e) 10)
                      (setq dxf_ent (subst (cons 10 (polar (cdr e) a d)) e dxf_ent))
                    )
                  )
                  (entmod dxf_ent)
                )
              )
            )
          )
        )
      )
    )
  )
  (prin1)
)

 

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