Hi everybody,
I want to add some meshes to a study. Yes i can do this by hand with the add command, but I don't want to do this with mare than 20 meshes.
I was thinking of if there would be a possibility to write a script that imports bdf files in a folder to a study. Would this be possible?
Greetings Philipp
Solved! Go to Solution.
Solved by nordhb. Go to Solution.
Hi,
this should be possible.
You need to use File System Object
Set fso = CreateObject("Scripting.FileSystemObject")
to collect files from a folder.
You can then loop through the files and use:
StudyDoc.AddFile
Here is an example:
'Creating File System Object Set fso = CreateObject("Scripting.FileSystemObject") 'Getting the Folder Object 'Only the files to be added in this folder Set ObjFolder = fso.GetFolder("C:\Temp\add_files") 'Getting the list of Files Set ObjFiles = ObjFolder.Files 'Getting the Path and Name of each File and Add SetLocale("en-us") Set Synergy = CreateObject("synergy.Synergy") Synergy.SetUnits "Metric" i=0 Set ImpOpts = Synergy.ImportOptions() Set StudyDoc = Synergy.StudyDoc() 'ImpOpts.MeshType "3D" 'ImpOpts.Units "mm" For Each ObjFile In ObjFiles StudyDoc.AddFile ObjFile.Path, ImpOpts, False i = i + 1 Next MsgBox "Files Added: " & i ,, "Information"
The import options are outprompted, but might need to be adjusted for your purpose.
You can copy above code to a text-file and save as vbs.
Change path or copy bdf-files to folder as in script, and give it a try.
Hope this helps.
Regards,
Berndt