It looks like you're new here. If you want to get involved, click one of these buttons!
I'm currently using COMSOL Multiphysics to export geometries to DXF. I need to combine these separate files into a layout, where each DXF is imported into its own layer, then save the layout as a .gds file. I have been doing this manually, but it is quite time consuming. Is there a way to do this using python or ruby?
I've tried modifying some example code (see below) that I found throughout these forums. I am hoping that it is as simple as modifying the loop that reads the DXF file into the master_layout, but I cannot figure out the syntax.
begin
include RBA
layout = RBA::Layout::new()
top = layout.create_cell("TOP")
# INPUTS:
save_output = true # Whether to save the resultant file automatically
out_filepath = 'E:\\'
out_filename = 'test.gds'
opt = SaveLayoutOptions::new
opt.gds2_libname = "LIBNAME"
opt.format = "GDS2"
top_cell_name = "TOP"
#Create new layout
master_layout = layout
top_cell_idx =top.cell_index
# Ask the user for the files
dialog = QFileDialog::new(mw)
dialog.setDirectory(QDir::homePath())
dialog.setFileMode(QFileDialog::ExistingFiles)
if (dialog.exec())
files = dialog.selectedFiles()
end
# Create a progress bar
progress = RelativeProgress::new("Loading...", files.length)
# Create number of layers equivalent to number of files
layerIndex = []
for i in 1..files.length()
layerIndex[i] = master_layout.layer(i,0)
end
# Loop through each file and import it into separate layer
files.each_with_index { |f,i|
p "Reading #{f}"
master_layout.layerIndex[i].read(f)
progress.inc
}
if save_output
p "Writing output file..."
master_layout.write(File.expand_path(out_filepath + out_filename), opt)
p "Done!"
end
ensure
progress.destroy
end
Comments
I was able to get it working
Thanks for letting us know. What was the problem?
Regards,
Matthias
Hi Matthias,
Thanks for everything you do!
My syntax was incorrect of course! I'm new to Ruby and still figuring it out. I was trying to .read() a DXF file directly into a layer, when I needed to place it into a cell using .shapes(). Everything is working as intended now.
Best,
Eric