CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.096.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator. New AutoCAD 2026 commands and variables.

CAD tip CAD tip # 11996:

Question

CAD 
 %  platform  category 
A
If you want to rotate selected texts, blocks or other types of objects in the same angle as an existing object, you can use the following LISP utility "RotBy".

Save the code to the file RotBy.lsp and load it by dragging into the AutoCAD window or with the APPLOAD command. Then type the command ROTBY. Select the source object with the requested rotation angle and then incrementally pick the objects, which should be rotated by it.

;Rotate by existing object/angle… (mod by Beekee)
(vl-load-com)

(defun C:RotBy (/ obj rot)
  (if (cond ((setq obj (entsel "\nSelect the source object for rotation < specify manually >: "))
             (and (setq obj (vlax-ename->vla-object (car obj)))
                  (or (not (vl-catch-all-error-p (setq rot (vl-catch-all-apply 'vla-get-rotation (list obj)))))
                      (prompt "\nRotation angle cannot be detected!"))))
            ((setq rot (getangle "\Specify final angle: ")))
      )

    (while (setq obj (entsel "\nSelect next target object to be rotated < exit >: "))
      (and (setq obj (vlax-ename->vla-object (car obj)))
           (or (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-rotation (list obj rot))))
               (prompt "\nCannot apply rotation angle!")
               )
           )
      )
    )
  (princ)
)

You can also download RotBy.lsp directly from DL Download

ACAD
100% *CAD
30.8.2018    12176×  
applies to: AutoCAD ·

See also:
Tip 14402:What is the difference between the BLOCKREPLACE, BREPLACE, REPLACEBLOCK, RIBLOCK and BLKREDEF commands?
Tip 14304:How to generate a report of used blocks including their visibility status in AutoCAD LT?
Tip 14215:IF statement in AutoCAD text fields and attributes.
Tip 13938:ModDXF - utility for bulk modification/display of internal DXF properties in DWG entities.
Tip 13784:Export block coordinates to a table. How to use the DATAEXTRACTION command in AutoCAD LT?


Back    All CAD Tips



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD: 
OS: 
Categ: 
Text:
 FAQ
  



Featuring:
Increase your productivity with our set of add-on functions for AutoCAD Civil 3D
CADstudio Civil Tools More info


Please use these tips at your own risk.
ARKANCE is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist