It looks like you're new here. If you want to get involved, click one of these buttons!
Hello,
I want to use the filling tool in my Python script and for that, I need to translate the following script from Ruby to Python. I have problem with the While loop. Any suggestions?
r = ... # region to fill c = ... # cell in which to produce the fill cells fc_index = ... # fill cell index fc_box = ... # fill cell footprint fill_margin = RBA::Point::new(0, 0) # x/y distance between tile cells with different origin # Iteration: fill a region and fill the remaining parts as long as there is anything left. # Polygons not worth being considered further are dropped (last argument is nil). while !r.is_empty? c.fill_region(r, fc_index, fc_box, nil, r, fill_margin, nil) end
Comments
Hi, Mo!
I think
while not r.is_empty()
is correct translation to Python. Similar to other methods with question mark.@EugeneZelenko
Many thanks for your help. That solved the while issue but for some reason still the filling does not work!!
Isn't
None
Python equivalent ofnil
?@MoBe @EugeneZelenko is right. You should use "None" instead of "False".
But there are more issues:
Make sure that "circle" is a cell index. "amcp_cell_4" needs to be a Region and will receive the remaining parts.
Matthias
Thanks very much for your support @Matthias @EugeneZelenko
@Matthias I understood the first point you made. But I still don't understand how I can fix the while loop so that it will terminate and how I should define "circle" in a way that I can correctly call it on the "fill_region" function. Here is how I defined it.
Thank you again for the amazing support here.
MoBe
I think this is what you after ..
I don't know what your channel_radius is
so just plugged in a number
Tracy
@tagger5896 Thanks for the codes. I already defined the circle and it works as it is supposed to. However, the problem is I don't understand in the above scripts, how I should call the circle in the "fill_region" function correctly and how I can stop the loop. Basically, I don't understand the "unsigned int fill_cell_index" written in the documentation for fill_region:
Another point is what I am trying to build is a PCell, and I don't want to make another cell within my PCell (I am not sure if that is even possible). So, basically, I should make the circle within the Pcell and call it in fill_region function. Hope this makes sense!
Thanks again.
The fill_cell_index is the
cell.cell_index()
wherecell
is thepya.Cell
object you want to use for filling. And of course it is possible to instantiate other cells within a PCell, where would the fun be without that possibility (you can even instantiate other PCells within a PCell, although I had to bother Matthias a long time until I understood how to do that ^^).@sebastian Thank you for your help. Really appreciate it. However, nothing worked for me to translate the following into python codes, although I was able to do it some other way it is extremely slow because of the loops that it contained! If anyone has an idea, that would be much appreciated!
Hello @MoBe
You should specify the starting point (instead of nil) to make the fill_region work correctly:
The last argument could be set to 'None'.
Regards,