rotating multiple shapes

Hi all,

I am looking for a way to rotate polygons by 45° on a dedicated layer but they should stay in place.
Practically saying I want to rotate tons of diamond shapes into orthogonal shapes, but the shape itself should remain in its position.

If I am using the rotate function while having multiple shapes selected, the origin of the shapes is also changed.

The array is shown in the screenshot while the regular rotation (having 2 shapes selected) is changing the origin and if I am rotating shape by shape the result is good... Any ideas :) Many thanks, Martin

Comments

  • Hello,

    First of all, if you have a shape that is repeated a lot of times, it is way better to work hierarchically: create the shape in a new cell, and instantiate that cell in the original cell (multiple times). If the shape changes, you have to do that only once inside that new cell and it will change everywhere. Your file size will also get much smaller if you have a huge number of repetitions.

    I tried the "Selection > Rotation By Angle" menu entry and it seems to rotate the selected shapes around the center of the Bbox of all the selected shapes combined.

    To rotate each structure around the center of its own Bbox you can write a small script and add it as a new menu entry like "Rotate Each Shape Individually By Angle".

    Cheers,

    Tomas

  • Hi @mpee,

    Here is a sample for a script like the one @thomas2004 mentioned (Ruby):

    vw = RBA::LayoutView.current
    
    selection = vw.object_selection
    
    selection.each do |s|
      shape = s.shape
      if shape
        # The transformation consists of these parts:
        # 1.) move the shape so its center is at 0,0 -> t1
        # 2.) rotate the shape by 45 degree -> t2
        # 3.) move the shape back to the original position -> t1.inverted
        t1 = RBA::ICplxTrans::new(RBA::Point::new - shape.bbox.center)
        t2 = RBA::ICplxTrans::new(1.0, 45.0, false)
        tr = t1.inverted * t2 * t1
        shape.polygon = shape.polygon.transformed(tr)
        # store the new shape in the selection array
        s.shape = shape
      end
    end
    
    # establish the new selection
    vw.object_selection = selection
    

    Note that the rotation comes with a small rounding error due to the finite resolution of the database. Hence the rotated edges may not be precisely 45 degree edges.

    Matthias

  • Hi Matthias,
    Many thanks for your code, it perfectly worked at the first attempt.
    @thomas2004: Thanks for your feedback, of course we are using hierarchical layout and viadefs, but I do have a very special case here...
    Best Regards,
    Martin

  • Hello,

    You could also replace the boxes/polygons by instances using the search and replace utility and put the desired shape in that instantiated cell... It makes your layout easier to update (again) later if needed...

    Cheers,

    Tomas

Sign In or Register to comment.