CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 2574 

CAD tip CAD tip # 11996:

Question CAD 
 %  platform  category 
Q - question

How to rotate selected blocks by the angle of an existing block?

A - answer 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 www.cadstudio.cz/download

ACAD
100% *  CAD 
30.8.2018    1927×  
Prices - CAD eShop:
applies to: AutoCAD ·

See also:
Tip 12237:UnfoldRS - unfold 3D surfaces to 2D in AutoCAD.
Tip 12150:How to update a block while keeping its attribute position and rotation?
Tip 12034:SolSimilar - select geometrically similar 3D solids.
Tip 11896:How to drive dyn.block parameters or constraints from Excel?
Tip 11354:Animate dyn.block parameters and dim.constraints in AutoCAD DWGs.


Back   All CAD Tips All CAD tips&tricks



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 glossary   



Featuring:
Export 3D VRML scenes from AutoCAD and Inventor
VRMLout More info


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