Results 1 to 7 of 7

Thread: Rotate objects by insertion point

  1. #1
    Member
    Join Date
    2009-07
    Posts
    11

    Default Rotate objects by insertion point

    I am looking for an AutoCAD 2011 add-on that allows a user to select multiple objects of any type in a DWG file (i.e.: line, rectangle, circle, text, dimension, block, ANY OBJECT) and rotate all of them together by a specific angle based on each object's individual insertion point.

    I've found AutoLISP routines that will do this for text, mtext, and blocks, but none for any and all types of objects in a DWG file.

    Any help and suggestions are greatly appreciated.
    Last edited by spattn; 2011-10-26 at 02:12 PM.

  2. #2
    AUGI Addict
    Join Date
    2006-12
    Posts
    1,520

    Default Re: Rotate objects by insertion point

    Not sure thats possible for "all" objects, since they don't all have a qualified insertion point. Take a line, for example - do you use the end point (which one?), or the middle? What about heavy/light polylines, 3D polylines? "Rectangle" isn't an object, it may be a single polyline or multiple lines. Dimensions are another story altogether.
    If you are going to fly by the seat of your pants, expect friction burns.
    Windows XP is now over 10 years old, in software terms it makes Joan Collins look like the new kid on the block. - Statler
    Everyone else being wrong is not the same thing as being right.

  3. #3
    All AUGI, all the time arshiel88's Avatar
    Join Date
    2005-02
    Location
    Off the Grid
    Posts
    550

    Default Re: Rotate objects by insertion point

    Quote Originally Posted by dgorsman View Post
    Not sure thats possible for "all" objects, since they don't all have a qualified insertion point. Take a line, for example - do you use the end point (which one?), or the middle? What about heavy/light polylines, 3D polylines? "Rectangle" isn't an object, it may be a single polyline or multiple lines. Dimensions are another story altogether.
    Its quite possible, if one will consider the center of the bounding box as base point for rotation of objects without Rotation property or Insertion point. About dimension objects, I don't think there's a need for them to be rotated. But if needed, together with the objects not included, you can add their object names in the Select Case clauses.

    Here's the code. Modify as needed.
    Code:
    Sub RotateObjects(RotAngle)
    Dim xEnt As AcadEntity
    Dim cMin As Variant
    Dim cMax As Variant
    Dim BoundingBoxCenter(0 To 2) As Double
    
    On Error Resume Next
    For Each xEnt In ThisDrawing.ActiveSelectionSet
        
        
        
        Select Case xEnt.ObjectName
        Case "AcDbPolyline", "AcDbLine", "AcDb3dSolid", "AcDbEllipse", "AcDb2dPolyline"   
                xEnt.GetBoundingBox cMin, cMax
                BoundingBoxCenter(0) = cMin(0) + (cMax(0) - cMin(0)) / 2
                BoundingBoxCenter(1) = cMin(1) + (cMax(1) - cMin(1)) / 2
                BoundingBoxCenter(2) = 0
                RotBasePt = BoundingBoxCenter
            
            Select Case RotAngle
                Case "POLARANG"
                    xEnt.Rotate RotBasePt, ThisDrawing.GetVariable("POLARANG")
                Case "-POLARANG"
                    xEnt.Rotate RotBasePt, ThisDrawing.GetVariable("POLARANG") * -1
                Case Else
                    xEnt.Rotate RotBasePt, ThisDrawing.Utility.AngleToReal(RotAngle, acDegrees)
            End Select
            
        
            
        Case Else 'Objects with Rotation property  (blocks,text,mtext etc)
            Select Case RotAngle
            Case "POLARANG"
                xEnt.Rotation = xEnt.Rotation + ThisDrawing.GetVariable("POLARANG")
            Case "-POLARANG"
                xEnt.Rotation = xEnt.Rotation - ThisDrawing.GetVariable("POLARANG")
            Case Else
                xEnt.Rotation = xEnt.Rotation + ThisDrawing.Utility.AngleToReal(RotAngle, acDegrees)
            End Select
            
        End Select
    Next xEnt
    ThisDrawing.SelectionSets.Item("CURRENT").Delete
    End Sub

    Now you can use the routine in a toolbar button/keyboard shortcut macro. You can even use the POLARANG variable for the rotation angle or any desired angle in degrees. For me, I have buttons for clockwise and counter-clockwise rotation. By the way, this routine uses the currently selected objects (ActiveSelection), so make sure you select first before issuing the command.

    examples.

    _vbastmt;RotateObjects("POLARANG");
    _vbastmt;RotateObjects("-POLARANG"); 'opposite direction
    _vbastmt;RotateObjects("-45");
    Last edited by arshiel88; 2011-10-27 at 01:31 AM.

    Shielbern Bolalin
    Architectural 3D Renderer
    ----------------------------------------------------------------------
    “A clever person solves a problem. A wise person avoids it.”

    1879-1955

  4. #4
    Member
    Join Date
    2009-07
    Posts
    11

    Default Re: Rotate objects by insertion point

    Thanks for providing the code. I will give it a try and see what happens.

  5. #5
    Member
    Join Date
    2009-07
    Posts
    11

    Default Re: Rotate objects by insertion point

    Arshiel88, thanks again for providing the information above.

    I am not familiar at all with Visual Basic coding. Could you point me in the right direction for complete, exact, step-by-step directions on how to install and use this coding?

  6. #6
    All AUGI, all the time arshiel88's Avatar
    Join Date
    2005-02
    Location
    Off the Grid
    Posts
    550

    Default Re: Rotate objects by insertion point

    1. Download the attached dvb file.
    2. VBALOAD then browse for the file.
    3. VBARUN then run the ObjectRotate macro.
    Attached Files Attached Files

    Shielbern Bolalin
    Architectural 3D Renderer
    ----------------------------------------------------------------------
    “A clever person solves a problem. A wise person avoids it.”

    1879-1955

  7. #7
    Active Member
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    62

    Default Re: Rotate objects by insertion point

    Add following line

    Dim RotBasePt As Variant

    avinash

Similar Threads

  1. join rotate block at base point + rotate atribute??
    By killerdemaster in forum AutoLISP
    Replies: 0
    Last Post: 2008-01-14, 04:10 PM
  2. Pick to Rotate at Insertion point
    By BCrouse in forum AutoLISP
    Replies: 5
    Last Post: 2007-07-13, 09:22 PM
  3. Placing insertion point at mid-point of flange on a steel section
    By Spenner in forum Dynamic Blocks - Technical
    Replies: 4
    Last Post: 2007-06-18, 01:53 PM
  4. Sort an array of text objects by their X and Y insertion point values
    By danderson.71652 in forum VBA/COM Interop
    Replies: 25
    Last Post: 2006-06-28, 03:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •