Electronics

Electronics

Topics relate to HFSS, Maxwell, SIwave, Icepak, Electronics Enterprise and more

Issue with Editing Materials in Ansys Maxwell

    • Evka
      Subscriber

      Hello, Ansys Maxwell community,

      I hope you are all doing well. I'm facing an issue while trying to create and edit materials in Ansys Maxwell using IronPython scripting. I have encountered the error message "The definition name cannot be blank" and despite multiple attempts to resolve it, I have been unsuccessful. I'm seeking the expertise of this community to help me identify and solve this problem.

      Here's my code:

      import ScriptEnv

      # Initialize the environment
      ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")

      # Restore the window
      oDesktop.RestoreWindow()

      # Set the active project
      oProject = oDesktop.SetActiveProject("PS_without_shunt_litz")

      # Get the definition manager
      oDefinitionManager = oProject.GetDefinitionManager()

      # Common material properties
      material_properties = [
          "CoordinateSystemType:=", "Cartesian",
          "BulkOrSurfaceType:=", 1,
          ["NAME:PhysicsTypes", "set:=", ["Electromagnetic"]],
          "permittivity:=", "1",
          "permeability:=", "1",
          "conductivity:=", "56818181.818182",
          ["NAME:stacking_type", "property_type:=", "ChoiceProperty", "Choice:=", "Litz Wire"],
          ["NAME:wire_type", "property_type:=", "ChoiceProperty", "Choice:=", "Round"],
          "strand_number:=", "200",
          "wire_diameter:=", "0.1mm"
      ]

      # Material names
      material_names = ["CondMat2_1", "CondMat2_2", "CondMat2_3", "CondMat2_4", "CondMat2_5", "CondMat2_6", "CondMat1_6"]

      # Create and edit materials in a loop
      for material_name in material_names:
          # Clone the material properties to avoid modifying the original list
          material_properties_copy = list(material_properties)
          # Update the material name in the cloned properties using .format
          material_properties_copy[0] = '"NAME:{}"'.format(material_name)
          material_name_1 = '"{}"'.format(material_name)
          # Call EditMaterial with the updated properties list
          oDefinitionManager.EditMaterial(material_name_1, material_properties_copy)

       

      Despite my efforts to correct the code, I still receive the error "The definition name cannot be blank." I have also tried various formatting methods for material_name, but the issue persists.

      If anyone has experience with this error or suggestions on resolving it, your assistance would be greatly appreciated.

      Thank you in advance for your help.

    • HDLI
      Ansys Employee

      Hello Evka,

             Please record py scripting to find correct ironpyhon format for Maxwell or find it in the Maxwell scripting help manual. 

             I think you should use "oDefinitionManager.AddMaterial()" to add new material. Thanks.

      HDLI

Viewing 1 reply thread
  • You must be logged in to reply to this topic.