Jump to content

Recommended Posts

Posted (edited)

Lisp for match rotation angle between objects (works on multileaders) - combined from 2 found lisps on the internet, with the help of A.I.

 

;;; Rotate by existing object/angle - Debugging (including Multileaders)
(vl-load-com)

(defun C:RB (/ sourceObj rot targetObj)
  (defun convert-to-double (angle)
    (vl-catch-all-apply 'rtos (list angle 2 2))
  )

  (setq sourceObj (car (entsel "\nSelect the source object for rotation < specify manually >: ")))
  (if (setq sourceObj (vlax-ename->vla-object sourceObj))
      (progn
        (setq rot (vla-get-rotation sourceObj))
        (setq targetObj (car (entsel "\nSelect target object to be rotated: ")))
        (if (setq targetObj (vlax-ename->vla-object targetObj))
            (if (not (vl-catch-all-error-p
                       (cond ((and (eq (vla-get-objectname targetObj) "AcDbMLeader") (eq (vla-get-contenttype targetObj) 2))
                              (progn
                                (vla-put-textrotation targetObj (convert-to-double rot))
                                (vla-put-rotation targetObj (convert-to-double rot))
                              )) ; Rotate multileader text and block to the source object's rotation
                             (t
                              (vla-put-rotation targetObj (convert-to-double rot)) ; Rotate other objects
                              )
                       )
                   ))
                (prompt "\nRotation applied successfully.")
                (prompt "\nCannot apply rotation angle!")
            )
        )
      )
      (prompt "\nError: Source object not selected.")
  )
  (princ)
)


 

Rotate Object by another's angle-RB.lsp

Edited by SLW210
Added Code Tags!!
Posted

Just a quick one a circle, line, arc etc do not have a rotation property. So if for multi leaders then can change then entsel to a ssget and only pick mleaders.

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