Hello,
I have been using the following Python script (via win32com.client) to create a simple design in Ansys Electronics Desktop – Maxwell 2D. It was working correctly a few weeks ago, but now it returns an error when trying to open or create the project.
I’m wondering:
- Has there been an update to Electronics Desktop or Maxwell that could explain this behavior?
- Or do you see any issue in my code that could now cause this?
Here is a simplified version of the code that used to work:
import win32com.client
project_name = "Maxwell2Design_Test2Wires"
software = "Ansoft.ElectronicsDesktop"
oAnsoftApp = win32com.client.Dispatch(software)
oDesktop = oAnsoftApp.GetAppDesktop()
def create_project(design_type, project_name, solution_type, oDesktop):
oProject = oDesktop.NewProject()
oProject.InsertDesign(design_type, project_name, solution_type, "")
return oProject
def get_or_create_project(project_name, design_type, solution_type, oDesktop):
for project in oDesktop.GetProjects():
if project.GetName() == project_name:
return project
return create_project(design_type, project_name, solution_type, oDesktop)
oProject = get_or_create_project(project_name, "Maxwell 2D", "Electrostatic", oDesktop)
oDesign = oProject.SetActiveDesign(project_name)
oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateRectangle(
[
"NAME:RectangleParameters",
"IsCovered:=", True,
"XStart:=", "2mm",
"YStart:=", "2mm",
"ZStart:=", "0mm",
"Width:=", "2mm",
"Height:=", "2mm",
"WhichAxis:=", "Z"
],
[
"NAME:Attributes",
"Name:=", "test",
"Color:=", "255, 165, 0",
"Transparency:=", 0.85,
"PartCoordinateSystem:=", "Global",
"MaterialValue:=", "\"vacuum\"",
"SolveInside:=", True
]
Error dialog :
Traceback (most recent call last):
File ~...
in compat_exec
exec(code, globals, locals)
File c: ...
oEditor.CreateRectangle(
File
in CreateRectangle
com_error: (-2147417851, 'The server threw an exception.', None, None)