Hello Matthias,
the 0.22 version is really powerful and with a lot of very nice new features ! A real good job! An i also like the idea of the 3D soft you are developping too !
I want to know if is possible to call a Pcell instance from a script, with parameters "hard coded" (or extracted from a csv file) in the script ? What i want to do is basically create a mapping of Pcells (text for instance) with the text parameter varying for each intanciation of the Pcell, and this "automaticaly" from a simple script.
Best Regards
Comments
here's some code which I got from Matthias in response to the same question :-)
begin
ly = RBA::Layout.new
top = ly.add_cell("TOP")
# find the lib
lib = RBA::Library.library_by_name("Basic")
lib || raise("Unknown lib 'Basic'")
# find the pcell
pcell_decl = lib.layout.pcell_declaration("TEXT")
pcell_decl || raise("Unknown PCell 'TEXT'")
# set the parameters
param = { "text" => "KLAYOUT RULES", "layer" =>
RBA::LayerInfo::new(10, 0), "mag" => 2.5 }
# build a param array using the param hash as a source
pv = pcell_decl.get_parameters.collect do |p|
param[p.name] || p.default
end
# create a PCell variant cell
pcell_var = ly.add_pcell_variant(lib, pcell_decl.id, pv)
# instantiate that cell
t = RBA::Trans::new(RBA::Trans::r90, 0, 0)
pcell_inst = ly.cell(top).insert(RBA::CellInstArray::new(pcell_var, t))
# write the output
ly.write("pcells.gds")
ensure
# if KLayout is started with "-r script.rb" this line ensures that
the GC has been run
# before KLayout exists. In particular this removes the link to the
library which otherwise
# causes a crash. This will be fixed in version 0.22.2.
lib = nil
GC.start
end
hope this helps,
Stefan
Hi Stefan,
thanks for posting that script - I can't really add much to that :-)
Matthias
many,many thanks!
Joël