How to set a property (say Phase Angle of Acceleration load) from Constant to Tabular?

Options
Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 253
50 Answers 100 Likes 100 Comments Second Anniversary
✭✭✭✭

I am trying to populate that Freq vs Phase angle data via Mechanical scripting, but I get the error "Changing definition type to Discrete is not supported."

It seems to be related to changing the type from Constant to Tabular as shown below.

How to fix this?

Best Answer

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 253
    50 Answers 100 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    Answer ✓

    You can use context_menu import along with some jscript to sort this issue. Please check the below script, which is for "Phase Angle" and this property name is an input in the code.

    Please activate the Acceleration object (in my case) and run the below script in Mechanical Scripting Console.

    a = Tree.FirstActiveObject
    
    cmd="""
    ds=DS;
    wb=WB;
    var oScript = DS.Script;
    var ListView=DS.Script.lv;
    var Load = ds.Tree.FirstActiveObject;
    ListView.SelectItem("Phase Angle");
    """
    ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
    import context_menu
    context_menu.DoChangeEDObjectSelection(ExtAPI,'_EnggData_Table')
    
    phi = [3,5,8]
    freq = [2,6,11]
    a.PhaseAngle.Inputs[0].DiscreteValues = [Quantity(i,"Hz") for i in freq]
    a.PhaseAngle.Output.DiscreteValues = [Quantity(i,"deg") for i in phi]