How to use DPF in WB Project Page Scripting Console?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 470
100 Answers 250 Likes 100 Comments Second Anniversary
✭✭✭✭
edited April 2024 in Structures

How to use DPF in WB Project Page Scripting Console?

Comments

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 470
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    edited April 2024

    You need to import all the relevant libraries for DPF. Below is an example code (tested with 2024R1)

    import clr
    import os
    import sys
    import Ansys
    
    def DPFAddReference(reference_name):
        try:
            clr.AddReference(reference_name);
            return
        except:
            print(reference_name + " reflection was not generated.")
    
    def importPlugins():
    
        DPFAddReference("Ans.Utilities")
        DPFAddReference("CS_DataProcessing")
    
        from Ans.DataProcessing import DataProcessingCore
        from Ans.DataProcessing.load import GeneratePluginDll
        DataProcessingCore.Initialization()
    
        DPFAddReference("Ans_Dpf_Native_dll_cs")
        DPFAddReference("Ans_Dpf_FEMutils_dll_cs")
        DPFAddReference("meshOperatorsCore_dll_cs")
        DPFAddReference("mapdlOperatorsCore_dll_cs")
        DPFAddReference("Ans_Dpf_Math_dll_cs")
        DPFAddReference("Ans_Dpf_Hdf5_dll_cs")
        DPFAddReference("Ans_Dpf_PointCloudSearch_dll_cs")
        DPFAddReference("Ans_Dpf_Mechanical_dll_cs")
        DPFAddReference("Ans_Dpf_MechanicalResults_dll_cs")
    
    importPlugins()
    
    import Ans.DataProcessing as dpf
    rst_path = r"\Path\to\file.rst"
    model = dpf.Model(rst_path)
    print(model.ResultInfo.AnalysisType)