Discussion Groups

Simulation Moldflow Insight

Reply
Contributor
phammer
Posts: 25
Registered: ‎07-29-2011
Accepted Solution

automatic import of many bdf meshes in moldflow - how could this work

116 Views, 1 Replies
01-08-2014 01:48 AM

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

Please use plain text.
Product Support
nordhb
Posts: 453
Registered: ‎03-23-2009

Re: automatic import of many bdf meshes in moldflow - how could this work

01-08-2014 05:03 AM in reply to: phammer

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

 

 

 



Berndt Nordh
Please use plain text.