How to include deformation scaling into a plot created by Python Result? By default it is unscaled

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 206
100 Comments 25 Answers Second Anniversary 25 Likes
✭✭✭✭

By Adjusting Deformation scaling in Mechanical, one could scale the Deformed shape for any standard result. But, this doesn't seem to work for Python Result (scaling is greyed out).

Answers

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 206
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭
    edited August 8

    One would just need to add the below line to the default code when one inserts Python result to deform the plot based on Deformation scaling.

    dpf_workflow.SetOutputWarpField(u)

    def post_started(sender, analysis):# Do not edit this line
        define_dpf_workflow(analysis)
    
    # Uncomment this function to enable retrieving results from the table/chart
    # def table_retrieve_result(value):# Do not edit this line
        # import mech_dpf
        # import Ans.DataProcessing as dpf
        # wf = dpf.Workflow(this.WorkflowId)
        # wf.Connect('contour_selector', value)
        # this.Evaluate()
    
    def define_dpf_workflow(analysis):
        import mech_dpf
        import Ans.DataProcessing as dpf
        mech_dpf.setExtAPI(ExtAPI)
        dataSource = dpf.DataSources(analysis.ResultFileName)
        u = dpf.operators.result.displacement()
        nrm = dpf.operators.math.norm_fc()
        # timeScop = dpf.Scoping()
        # timeScop.Ids = [1]
        # u.inputs.time_scoping.Connect(timeScop)
        u.inputs.data_sources.Connect(dataSource)
        nrm.Connect(u)
        dpf_workflow = dpf.Workflow()
        dpf_workflow.Add(u)
        dpf_workflow.Add(nrm)
        dpf_workflow.SetOutputWarpField(u)
        # dpf_workflow.SetInputName(u, 0, 'time')
        # dpf_workflow.Connect('time', timeScop)
        dpf_workflow.SetOutputContour(nrm)
        dpf_workflow.Record('wf_id', False)
        this.WorkflowId = dpf_workflow.GetRecordedId()