Can I duplicate a structure/monitor form one project file to another in the same solver or in a different solver?

mode
fdtd
copy
paste
device

#1

Could I copy and paste a structure and/or a monitor from one FDTD project file to another? Could I do the same thing among different solvers, say from an FDTD project file to a MODE project file?


#2

Yes. You can copy and paste structures/monitors/analysis groups from one FDTD file to another. To do this simply select the desired object press CTRL+C (or select copy from the ‘Edit’ menu) and then go to the other project and press CTRL+V (or select paste from the ‘Edit’ menu).

You can also copy/paste structure between different solvers. It is possible to copy/paste structures between FDTD Solution and MODE Solution. Structure can also be copied from FDTD/MODE into DEVICE. However, it is currently not possible to copy structures from DEVICE and paste the into FDTD/MODE.


get structure from FDTD solutions
#3

Is there a script command that does this process? The copy command only copies the structure within the same project file. I will like to build my own structure library and thus I will need a script command that takes my own structure to a new project file. For example, I have my structures in library.fsp and need to copy&paste them to my_new_project.fsp.


#4

EDIT: this is possible from script. See the reply further below: Can I duplicate a structure/monitor form one project file to another in the same solver or in a different solver?

@kchow
I don’t think this is something that can be done from the script. There are two possible workarounds even though they are not exactly what you are asking for.

  1. The first approach requires that you have not created the second project file yet. In that case, load the project where you want to get your structures from using the script. Save the project file with a new name (for your new project) and delete the unwanted objects. Add and modify new/existing objects to finalize new project.

  2. The second approach requires that you do not already have a project file from where you want to copy your structures. In this approach, you can create a script file to build your first project. You can then use the same script to build your second project and then add/edit the structures to finalize your second project.

Unfortunately, once you have already created a project file, it is not possible to copy objects from it and paste it into another existing project file using script.


#5

@kchow, @aalam, I am curious about the inter-file copy and paste too. Is there a script command for copying to clipboard and pasting from clipboard? Could those commands if they do exist work between two different files? How about between two different solvers?


#6

I think I have found a way to use the script commands to copy and paste structures from one project file to another, even between different solvers! You can use the ‘copytoclipboard’ and ‘pastefromclipboard’ commands. I will post the detailed process on Monday.


#7

If your structure has a construction script, you can simply copy paste the script in your new project file. This simply re-constructs a new structure. Well, this mayn’t exactly what you need but it may help.


#8

Here is how you can copy structures from an existing project file to another project file (between same or different solvers):

I) Between same solvers: If you are copying structures between project files that belong to the same solver (say, FDTD Solutions), you can use the above mentioned ‘copytoclipboard’ and ‘pastefromclipboard’ commands. The script file will look something like this,

load(“library.fsp”);
select(“substrate”);
copytoclipboard;
load(“new_project.fsp”);
pastefromclipboard;

this script will copy the structure “substrate” from the library.fsp file into new_project.fsp.

II) Between different solvers: If you are copying between project files belonging to different solvers, the process if a bit tricky,

i) First create a script file (copy_objects.lsf) that will select the desired structure(s) from the source file (library.fsp) and copy it to the clipboard. The script file will look something like this:

selectall;
copytoclipboard;
exit;

ii) Open the target (new) project file in (say MODE Solutions) and run the following commands (paste_objects.lsf),

system(’ " “C:\Program files\Lumerical\FDTD\bin\fdtd-solutions.exe” “library.fsp” -run “copy_objects.lsf” " ');
pastefromclipboard;

The script commands will open the command prompt, run FDTD Solutions, open library.fsp, and run test_sript.lsf. test_script.lsf will copy all the structures from library.fsp into the clipboard and exit [it is important to execute the ‘exit’ command so that the system returns to the first solver (MODE Solutions)]. The second line of the script commands will then paste the structures from the clipboard into the new project file.

NOTE: You will need to add the path to the project and script files in the ‘system’ command.

I am adding some sample files to test the second case (copying between different solvers:

copy_objects.lsf (312 Bytes)paste_objects.lsf (394 Bytes)library.fsp (225.5 KB)


Build up your own personal object library
#10

Hi, I encoured a problem about copy from structuregroup.
My script is as following

addstructuregroup;
set(“name”,“a”);
addsphere;
addtogroup;
addcircle;
addtogroup;

select(“a”);
for(i=-3/2:3/2){
for(j=-3/2:3/2){
copy;
set(“x”,(j)*0.15);
set(“y”,(i)*0.15);
}
}

I want to get a 4x4 array, but how to delete the original one as my attached file?try2.fsp (284.2 KB)


#11

Hi @shihwen,

You cannot use the “delete” command to delete the original structure directly since all the copies have the same name as the original one. I suggest to re-name the copies in the for loops and then you can use the “delete” command to delete the original structure.

addstructuregroup;
set("name","a");
addsphere;
addtogroup;
addcircle;
addtogroup;

select("a");
for(i=-3/2:3/2){
    for(j=-3/2:3/2){
        copy;
        set("x",(j)*0.15);
        set("y",(i)*0.15);
        set("name", "a" + num2str(i) + num2str(j));
    }
} 

select("a");
delete;

Here is the modified file try2_modified.fsp (282.6 KB)


#12

Thank you @gwang

It would be more convenient if there has a command “addmyownstructure”…but it works :smile: slight_smile: