how to insert a polygon?

Hi sir,
I got a list that is a polygon each points (coordinate) from another software.
can I follow that to create a shape as the coordinate list to make me double check by manual ?
that is what my code and idea.....but ~~ that not workable...

fatalword="(-2348.275000,-4985.623000),(-2348.275000,-4985.624000),(-2347.906000,-4986.132000),(-2347.505000,-4986.616000),(-2347.075000,-4987.075000),(-2346.616000,-4987.505000),(-2346.132000,-4987.906000),(-2345.624000,-4988.275000),(-2345.093000,-4988.612000),(-2344.542000,-4988.914000),(-2343.973000,-4989.182000),(-2343.389000,-4989.414000),(-2342.791000,-4989.608000),(-2342.182000,-4989.764000),(-2341.565000,-4989.882000),(-2340.942000,-4989.960000),(-2340.314000,-4990.000000),(-2339.686000,-4990.000000),(-2339.686000,-5180.000000),(-2340.314000,-5180.000000),(-2340.942000,-5180.040000),(-2341.565000,-5180.118000),(-2342.182000,-5180.236000),(-2342.791000,-5180.392000),(-2343.389000,-5180.586000),(-2343.973000,-5180.818000),(-2344.542000,-5181.086000),(-2345.093000,-5181.388000),(-2345.624000,-5181.725000),(-2346.132000,-5182.094000),(-2346.616000,-5182.495000),(-2347.075000,-5182.925000),(-2347.505000,-5183.384000),(-2347.906000,-5183.868000),(-2348.275000,-5184.376000),(-2348.275000,-5184.377000),(-2348.275000,-5126.411000),(-2347.961000,-5126.391000),(-2347.650000,-5126.352000),(-2347.341000,-5126.293000),(-2347.036000,-5126.215000),(-2346.738000,-5126.118000),(-2346.445000,-5126.002000),(-2346.161000,-5125.868000),(-2345.886000,-5125.717000),(-2345.620000,-5125.548000),(-2345.366000,-5125.364000),(-2345.124000,-5125.163000),(-2344.895000,-5124.948000),(-2344.680000,-5124.719000),(-2344.479000,-5124.477000),(-2344.295000,-5124.223000),(-2344.126000,-5123.958000),(-2343.975000,-5123.682000),(-2343.841000,-5123.398000),(-2343.725000,-5123.106000),(-2343.628000,-5122.807000),(-2343.550000,-5122.502000),(-2343.491000,-5122.194000),(-2343.452000,-5121.882000),(-2343.432000,-5121.568000),(-2343.432000,-5011.758000),(-2343.452000,-5011.444000),(-2343.491000,-5011.132000),(-2343.550000,-5010.824000),(-2343.628000,-5010.519000),(-2343.725000,-5010.220000),(-2343.841000,-5009.928000),(-2343.975000,-5009.644000),(-2344.126000,-5009.368000),(-2344.295000,-5009.103000),(-2344.479000,-5008.849000),(-2344.680000,-5008.607000),(-2344.895000,-5008.378000),(-2345.124000,-5008.162000),(-2345.366000,-5007.962000),(-2345.620000,-5007.777000),(-2345.886000,-5007.609000),(-2346.161000,-5007.458000),(-2346.445000,-5007.324000),(-2346.738000,-5007.208000),(-2347.036000,-5007.111000),(-2347.341000,-5007.033000),(-2347.650000,-5006.974000),(-2347.961000,-5006.934000),(-2348.275000,-5006.915000),(-2348.275000,-4985.623000)"
pattern_list= Array.new()


layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
layout_view = RBA::Application::instance.main_window.current_view
current_work_cell= RBA::Application::instance.main_window.current_view.active_cellview.cell_name
layout = RBA::CellView.active.layout

fatalword.split("),(").each do  |xx|
pattern_list << xx.gsub("(","").gsub(")","")
end
puts pattern_list


layer1 = layout.layer(1, 0)
top = layout.cell(current_work_cell)
top.shapes(layer1).insert(RBA::Polygon::new(pattern_list))

Comments

  • Hi @jiunnweiyeh,

    "Polygon" takes an list of points, for example this way:

    pts = [ 
      [ -2348.275000,-4985.623000 ], 
      [ -2348.275000,-4985.624000 ], 
      [ -2347.906000,-4986.132000 ],
    ...
    ]
    
    layer1 = layout.layer(1, 0)
    top = layout.cell(current_work_cell)
    top.shapes(layer1).insert(RBA::DPolygon::new(pts))
    

    You also should use "DPolygon", if your coordinates are in micrometers. With "Polygon" (no "D"), the coordinates have to be in database units (1 = 1 DBU).

    Matthias

  • Is there a way to specify a different insertion point for the shapes? Like for instance say I have a shape created in a cell and I want to create a few different versions of the position of this cell using the python macros for automating changes. I am looking to layer a few other not changing blocks, where their coordinates and positions align at the origin, but I want to place inside a new block iterations of a block conformation shifted by specific units--in particular it would be two of the same design shifted away from center by a unit of distance.

    What I have looks something like this...

    def _single_cell_create(self, 
                            block_cell_name,
                            cell_contents):
    
        # Create or find the block cell
        block_cell = self.layout.create_cell(block_cell_name)
    
        for _components in cell_contents:
            block_layer_index, block_shape, block_coordinates = _components
    
            block_cell.shapes(block_layer_index).insert(block_shape)
    

    Inside the cell_contents, I envision that there would be a tuple of an integer (layer), string (block or shape), and some coordinates. However I cannot seem to see where to put the coordinates for where they should go, or what reference origin point to use.

    Is there a way to do this that isn't by hand?

  • edited April 28

    @Matthias
    Thanks , but I using that code and get a script erorr as
    "RuntimeError: No overload with matching agruments in DPolygon::initalize"
    it any wrong or mistake in my code?

    layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
    layout_view = RBA::Application::instance.main_window.current_view
    current_work_cell= RBA::Application::instance.main_window.current_view.active_cellview.cell_name
    layout = RBA::CellView.active.layout
    pts = [[-5000,-5000],[-5000,5000],[5000,5000],[5000,-5000]]
    puts pts
    layer1 = layout.layer(1, 0)
    top = layout.cell(current_work_cell)
    top.shapes(layer1).insert(RBA::DPolygon::new(pts))
    

  • Hi @jiunnweiyeh,

    Are you using some (quite) old version maybe?

    It works in 0.30.1:

    Older versions want to see a list of DPoint objects:

    pts = [RBA::DPoint::new(-5000,-5000),RBA::DPoint::new(-5000,5000),RBA::DPoint::new(5000,5000),RBA::DPoint::new(5000,-5000)]
    polygon = RBA::DPolygon::new(pts)
    ...
    

    Matthias

  • Hi @double0darbo,

    Regarding your question: all work objects (Polygon, DPolygon, Box, ...) have a "moved" method that creates a shifted version of that object. Use that to move the object by the specified distance before inserting it.

    Matthias

  • Hi @Matthias
    Yes , I using 0.28.12 version , cause in my side , we have a lot scrpit base on this version.
    and I have to check some condition is fine in the new version and apply some document .
    After that (all document been approveed) , I can update the new version(finally~)....
    But , I have no time to do that... it is reason I using a old version...

Sign In or Register to comment.