How to read "Temp_Winding_Max" variable values.

Here is the syntax, to read values. But it was not performing well

Dim WindingTemp
Call mcad.GetVariable("Temp_Winding_Maximum", WindingTemp)

Answers

  • James Derrick
    James Derrick Administrator, Employee Posts: 283
    Ancient Membership 100 Comments 100 Likes 25 Answers
    admin

    Hi Naveen, I don't understand what the question you're asking is. Could you elaborate a bit more in your question?

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Hi @James Derrick

    I wants to change the fluid flow in Motorcad Thermal module with respect to an output variable "Temp_Winding_Max".

    For example, if the output winding temperature is less than 100deg, the inlet fluid flow should be 8, otherwise it should be 6.

    However when Im trying to call the output variable in the script, the written variable is not working.

    Would like to know whether we can call an output variable value in script.

    related to PyMotorCAD | VB Script.

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Hi @James Derrick as described above, any suggestion from PyMotorCAD Team...!!

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 128
    100 Comments 25 Likes Second Anniversary 5 Answers
    ✭✭✭✭

    @Naveen Kumar Begari Have a look into documenation. you will probably have to change the function name.

    https://motorcad.docs.pyansys.com/version/dev/user_guide/backwards_compatibility.html#change-function-names

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Thanks @Rajesh Meena , I vll check with this.

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Hi @Rajesh Meena, That was good enough to proceed, but the provided script was executing and displaying incorrect data on the graph.

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Hi @AKD-Scripting-Team , any solutions of this front.?

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    @James Derrick and @AKD-Scripting-Team . Any suggestions for this query.?

  • James Derrick
    James Derrick Administrator, Employee Posts: 283
    Ancient Membership 100 Comments 100 Likes 25 Answers
    admin

    Hi @Naveen Kumar Begari can you share a bit more regarding the new problem? Ideally we need to be able to recreate it ourselves to help. We understand that you probably can't share the exact code with us for security reasons, however, if you could make a minimal verifiable reproducible example, like one would on Stack Overflow that demonstrates the problem, we should be able to get to the heart of the issue faster.

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Sure @James Derrick , I vll share it

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Hi @James Derrick Here is the VB Script

    `
    Function MainFunction(Title)

    Dim mcad
    Dim WindingTemp
    
    #Create MotorCAD application object
    Set mcad = CreateObject("motorcad.appautomation")
    
    #Avoid immediate updates
    Call mcad.AvoidImmediateUpdate(True)
    
    #Disable error messages
    Call mcad.SetVariable("ERROR_MESSAGES_DISABLED", 1)
    
    #Get the winding temperature variable
    Call mcad.GetVariable("Temp_Winding_Max", WindingTemp)
    
    #Check if WindingTemp is in the range (0, 100)
    If WindingTemp > 0 And WindingTemp < 100 Then
        #Set the fluid volume flow rate
        Dim flowRate
        flowRate = 8 / 60000
        Call mcad.SetVariable("WJ_Fluid_Volume_Flow_Rate", flowRate)
        #Show the message
        Call mcad.showmessage("WJ_Fluid_Volume_Flow_Rate = " + CStr(flowRate))
    Else
        #Set the fluid volume flow rate to 0
        Call mcad.SetVariable("WJ_Fluid_Volume_Flow_Rate", 0)
        #Show the message
        Call mcad.showmessage("WJ_Fluid_Volume_Flow_Rate = " + CStr(0))
    End If
    

    End Function
    `

    I wants to change the fluid flow in Motorcad Thermal module with respect to an output variable "Temp_Winding_Max".
    For example, if the output winding temperature is less than 100deg, the inlet fluid flow should be 8, otherwise it should be 6.
    However when Im trying to call the output variable in the script, the written variable is not working.
    Would like to know whether we can call an output variable value in script.

    related to PyMotorCAD | VB Script.

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    `I wants to change the fluid flow in Motorcad Thermal module with respect to an output variable "Temp_Winding_Max".

    For example, if the output winding temperature is less than 100deg, the inlet fluid flow should be 8, otherwise it should be 6.

    However when Im trying to call the output variable in the script, the written variable is not working.

    Would like to know whether we can call an output variable value in script.

    related to PyMotorCAD | VB Script.`

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    `Function MainFunction(Title)

    Dim mcad
    Dim WindingTemp
    
    #Create MotorCAD application object
    Set mcad = CreateObject("motorcad.appautomation")
    
    #Avoid immediate updates
    Call mcad.AvoidImmediateUpdate(True)
    
    #Disable error messages
    Call mcad.SetVariable("ERROR_MESSAGES_DISABLED", 1)
    
    #Get the winding temperature variable
    Call mcad.GetVariable("Temp_Winding_Max", WindingTemp)
    
    #Check if WindingTemp is in the range (0, 100)
    If WindingTemp > 0 And WindingTemp < 100 Then
        #Set the fluid volume flow rate
        Dim flowRate
        flowRate = 8 / 60000
        Call mcad.SetVariable("WJ_Fluid_Volume_Flow_Rate", flowRate)
        #Show the message
        Call mcad.showmessage("WJ_Fluid_Volume_Flow_Rate = " + CStr(flowRate))
    Else
        #Set the fluid volume flow rate to 0
        Call mcad.SetVariable("WJ_Fluid_Volume_Flow_Rate", 0)
        #Show the message
        Call mcad.showmessage("WJ_Fluid_Volume_Flow_Rate = " + CStr(0))
    End If
    

    End Function`

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Function MainFunction(Title)

    Dim mcad
    Dim WindingTemp
    
    #Create MotorCAD application object
    Set mcad = CreateObject("motorcad.appautomation")
    
    #Avoid immediate updates
    Call mcad.AvoidImmediateUpdate(True)
    
    #Disable error messages
    Call mcad.SetVariable("ERROR_MESSAGES_DISABLED", 1)
    
    #Get the winding temperature variable
    Call mcad.GetVariable("Temp_Winding_Max", WindingTemp)
    
    #Check if WindingTemp is in the range (0, 100)
    If WindingTemp > 0 And WindingTemp < 100 Then
        #Set the fluid volume flow rate
        Dim flowRate
        flowRate = 8 / 60000
        Call mcad.SetVariable("WJ_Fluid_Volume_Flow_Rate", flowRate)
        #Show the message
        Call mcad.showmessage("WJ_Fluid_Volume_Flow_Rate = " + CStr(flowRate))
    Else
        #Set the fluid volume flow rate to 0
        Call mcad.SetVariable("WJ_Fluid_Volume_Flow_Rate", 0)
        #Show the message
        Call mcad.showmessage("WJ_Fluid_Volume_Flow_Rate = " + CStr(0))
    End If
    

    End Function

    For Better Understanding, this is the complete code.

  • James Derrick
    James Derrick Administrator, Employee Posts: 283
    Ancient Membership 100 Comments 100 Likes 25 Answers
    admin

    @PyMotorCAD-Team may be able to help

  • PyMotorCAD-Team
    PyMotorCAD-Team Member, Employee Posts: 3
    First Comment Name Dropper
    ✭✭✭
    edited November 2024

    Hi @""Naveen Kumar Begari". This output variable should be accessible with your script. Can I ask if you are seeing an error or any unexpected behaviour? If you try the below script, it should display the max winding temperature in the pop-up. Please let me know if this works as expected.

    Dim mcad
    Dim WindingTemp
    
    ' Create MotorCAD application object
    Set mcad = CreateObject("motorcad.appautomation")
    
    ' Get the winding temperature variable
    Call mcad.GetVariable("Temp_Winding_Max", WindingTemp)
    Call mcad.showmessage("Temp Winding Max = " + CStr(WindingTemp))``
    

    Do you have more than one Motor-CAD window open? Sometimes ActiveX communication can struggle with more than one instance open. We recommend using Python scripting instead of VBScript, as this uses JSON-RPC communication, which is more stable than ActiveX. Also, with Python, you would have the advantage of having more options to run a script during analysis.

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 53
    10 Comments First Anniversary Name Dropper Photogenic
    **

    Hi @PyMotorCAD-Team , Thanks for providing this solution. Hope this information is good enough.

    We are opening only one motorCAD window.

    Sure team, Python scripting vll be used in further jobs.

    Thank you so much @James Derrick