How can I add Pre-Test Calculator (NVH Toolkit) and Export Sensor location UNV file?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 505
100 Answers 250 Likes 100 Comments Second Anniversary
✭✭✭✭

How can I add Pre-Test Calculator (NVH Toolkit) and Export Sensor location UNV file?

Comments

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 505
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    edited May 16

    Tested with 2024R2.

    1. Please set the export file path (including file name, without extension) in line 33.
    2. Define a named selection with faces that will be scoped in PT calculator. For this example the named-selection is called ns_faces
    # Analysis
    modal = Model.Analyses[0]
    pt = modal.CreatePostObject("PreTestTreeObject", "NVHToolkit")
    
    # Get faces named selection
    ns_type = Ansys.ACT.Automation.Mechanical.NamedSelection
    all_face_objs = ExtAPI.DataModel.GetObjectsByName("faces")
    ns_faces = filter(lambda x: (x.GetType() == ns_type), all_face_objs)[0]
    
    # Populate PT Tree Object
    face_sel = ExtAPI.SelectionManager.CreateSelectionInfo(
        SelectionTypeEnum.GeometryEntities)
    face_sel.Ids = ns_faces.Ids
    pt.Properties["Geometry/DefineBy/Geo"].Value = face_sel
    
    # Set distance between nodes
    pt.Properties["FilterNodesDistance"].Value = 30
    
    # Proximity between sensors
    pt.Properties["SensorDefinition"].Properties["ProximityBetweenSensors"].Value = 35
    
    # Set Max Sensors
    pt.Properties["SensorDefinition"].Properties["MaximumNumberSensors"].Value = 20
    pt.Properties["FilterNodesDistance"].Validate()
    
    # Evaluate
    pt.NotifyChange()
    modal.Solution.EvaluateAllResults()
    
    # Export UNV File
    nvh_tool = ExtAPI.ExtensionManager.GetExtensionByName("NVHToolkit")
    # Set sensor and exciter file name including path.
    nvh_tool.Attributes["exportdir"] = r"\Path\to\exported\file"
    nvh_tool.ScriptScope.PT_PANES["Pre-Test Worksheet"].ExportUNV(pt)