Hi team
I am trying to create a 'python result' that takes a name selection (that is a line) and then takes some stresses offset from that line, does some math with the stress and plots on the graph the calculated result.
Current struggle is to:
Get the locations of name selection in x,y,z
Get stresses at new x,y,z
Plot on graph
Code so far:
def post_started(sender, analysis):#.Do.not .edit .this.line
define_dpf_workflow(analysis)
def define_dpf_workflow(analysis):
import mech_dpf
import Ans.DataProcessing as dpf
mech_dpf.setExtAPI(ExtAPI)
my_data_sources = dpf.DataSources(analysis.ResultFileName)
model = dpf.Model(my_data_sources)
selection_name = this.GetCustomPropertyByPath("Properties/Named selection").ValueString
direction = this.GetCustomPropertyByPath("Properties/Direction of use").ValueString
my_time_scoping = dpf.Scoping()
s_eqv_op = dpf.operators.result.stress_von_mises()
s_eqv_op.inputs.requested_location.Connect('Nodal')
s_eqv_op.inputs.data_sources.Connect(my_data_sources)
number_sets = s_eqv_op.outputs.fields_container.GetData().GetTimeFreqSupport().NumberSets
my_time_scoping.Ids = [number_sets]
zone1_mesh_region = model.GetNamedSelection(selection_name)
s_eqv_op.inputs.time_scoping.Connect(my_time_scoping)
s_eqv_op.inputs.mesh_scoping.Connect(zone1_mesh_region)
scale_value = this.GetCustomPropertyByPath("Properties/Thick Value").Value
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(s_eqv_op)
dpf_workflow.SetOutputContour(s_eqv_op)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId()
Property provider:
def reload_props():
this.PropertyProvider = None
# Create the property instance
provider = Provider()
# Create a group named Group 1.
group = provider.AddGroup("Properties")
thick_value = group.AddProperty("Thick Value", Control.Double)
# Select component for plotting directional deformation
direction_prop = group.AddProperty("Direction of use", Control.Options)
direction_prop.Options = {0: 'X', 1: 'Y', 2: 'Z', 3: '-X', 4: '-Y', 5: '-Z'}
# DropDown to select a named selection
selection_prop = group.AddProperty("Named selection", Control.Options)
# Retrieve all named selections and fill the dropdown with the list of named selections
all_named_sel=DataModel.GetObjectsByType(DataModelObjectCategory.NamedSelection)
ns_list={}
idx=1
for ns in all_named_sel:
ns_list[idx]=ns.Name
idx+=1
selection_prop.Options = ns_list
this.PropertyProvider = provider