hi!
I have a parent topcell with a few child cells. Say if I draw 2 child cells with x=30, y=60 each with origin at center x=15, y=30.
How can I use the script to rotate the child cell by 90 degree and arrange them so that they appear back to back when you see them from parent topcell? After rotation and displacement, first child cell x=60, y=30 with origin x=30, y=15 and back to back with second child cell with origin at x=90, y=15.
( I did it manually by selecting parent topcell as new top, rotating and shifting them. When I select the child cell as new top, I will still want to see x=30,y=60 orientation.)
Thank you.
Comments
Hello,
I'm not sure whether I understand your request.
Do you mean you want to see the content of the cell rotated rather than the cell instance? You can rotate the content by switching to the cell, selecting all and choosing "Edit/Selection/Rotate". You won't need a script for that.
Or are those cells two instances of the same cell? In that case, you need to create variants - but I wonder why you want to have the content of the cell rotated in that case. Instantiating a cell in two different ways is the real benefit of hierarchical layout, so why making use of that?
Matthias
It was my bad for not able to make you understand my need. I should have included my script and I am new in this scripting.
My project is to write a script to automate and draw some elements as input to another application. The elements will be drawn based on information read from a text file.
Yes, I don't need script to do the rotation of the cell content but the script will not be complete if it is able to draw the elements but the end user needs to rotate them manually. I am trying to follow the original rotation of the elements drawn manually by the originator.
Below is sample script to show my problem and need; not my actual script.
# create a new application window
app = RBA::Application.instance
mw = app.main_window
# create a new layout and cell "Top"
mw.create_layout( 0 )
@view = mw.current_view
@layout = @view.cellview( 0 ).layout
@Top = @layout.add_cell( "Top" )
# create cell "Topcell1"
@Topcell = @layout.add_cell("Topcell1" )
cell = @layout.cell( @Top)
inst = RBA::CellInstArray::new( @Topcell, RBA::Trans::new )
cell.insert( inst )
# create child cell "child_cell1"
@tmp_lid_1 = RBA::LayerInfo.new( 1, 0 )
@tmp_lay_1 = @layout.insert_layer( @tmp_lid_1 )
@subcell = @layout.add_cell("child_cell1" )
cell = @layout.cell( @Topcell )
inst = RBA::CellInstArray::new( @subcell, RBA::Trans::new )
cell.insert( inst )
box = RBA::Box::new( -7500, -15000, 7500, 15000 )
@layout.cell( @subcell ).shapes( @tmp_lay_1 ).insert_box( box )#for understanding, just box is drawn
# create child cell "child_cell2"
@tmp_lid_2 = RBA::LayerInfo.new( 2, 0 )
@tmp_lay_2 = @layout.insert_layer( @tmp_lid_2 )
@subcell2 = @layout.add_cell("child_cell2" )
cell = @layout.cell( @Topcell )
inst = RBA::CellInstArray::new( @subcell2, RBA::Trans::new )
cell.insert( inst )
box = RBA::Box::new( -7500, -15000, 7500, 15000 )
@layout.cell( @subcell2 ).shapes( @tmp_lay_2 ).insert_box( box )
# settings for the view and rotate cell "Topcell1"
@view.select_cell_path( [@Topcell], 0 )
mw.cm_lv_add_missing
mw.cm_select_all
mw.cm_sel_rot_ccw
@view.update_content
@view.zoom_fit
@view.max_hier
# run the application
app.exec
From my script, I am able to rotate topcell1. When topcell1 is selected as new top, child_cell1 is overlapping with child_cell2 because both child cells are drawn with origin at center. I hope to use script to arrange them back to back without overlapping. I not sure the script is able to do that but they can be moved manually. If this is impossible, I will apply offset at the child cell level.
Most MainWindow methods are bound to a menu. It would be nice if passing parameters is possible in the script such as select cell, move cell. Just my thought.
Thank you again.
Hello,
Thank you for providing the script. That way it's easier to understand your request.
Basically, cm_select_all and cm_rotate_ccw are not intended to be used within scripts - they are provided as hooks for the menu items only. In general, scripts are intended to provide operations on the layout database, not for interaction with the editor. Hence for example it is not possible to select certain objects in order to apply rotation or movement just to them.
But you can create the instances accordingly. The responsible parameter is the transformation (second parameter in the CellInstArray constructor).
So what you need to do is to specify a certain transformation, i.e.
For an explanation of the parameters: 1 is the rotation angle "in units of 90 degree", so 1 equals 90 degree. false is the mirror flag (here: no mirroring), and 0/7500 is the displacement vector in database units (x/y).
You can apply a similar transformation for the other cell. This time the displacement is downwards:
The effect will be that the cells are stacked and do not overlap.
Please adjust the transformations according to your requirements. In the end, you won't have to use cm_select_all and cm_rotate_ccw - just create the instances in their final arrangement.
Let me allow some more remarks:
Here is a leaner version of that script including the new transformations:
Regards,
Matthias
This is what I needed.
Thanks a lot.
Regards,
Kho CK