Page 1 of 1

TypeError in pymaxwell 5

Posted: Mon Sep 06, 2021 8:43 am
by Mingfae Wong 20210811011621
I'm trying to copy the Simulens setting from MXI back to MXS file, it works fine in pymaxwell4, but not with pymaxwell (just upgrade to Maxwell 5), can someone take a look for me?

Attached mxi and mxs.

Error Message:
sceneMXS.setDiffraction(0, 0, mxi_ApertureMap, mxi_ObstacleMap)
TypeError: in method 'Cmaxwell_setDiffraction', argument 4 of type 'mw::String const &'



Code:

# from pymaxwell4 import *
from pymaxwell5 import *


def transferMXISettingToMXS():

mxifilepath = "C:/Users/wong.mingfae/Desktop/model.mxi"
mxsfilepath = "C:/Users/wong.mingfae/Desktop/model.mxs"


if mxifilepath and mxsfilepath:
outputFile = "C:/Users/wong.mingfae/Desktop/model_output.mxs"
# -------------- Read MXI file ------------
sceneMXI = CmaxwellMxi()
sceneMXI.read(mxifilepath)
# -------------- Get MXI Simulens setting ------------
mxi_ApertureMap = sceneMXI.getApertureMap()
mxi_ObstacleMap = sceneMXI.getObstacleMap()
print(' ApertureMap:', mxi_ApertureMap)
print(' ObstacleMap:', mxi_ObstacleMap)
mxi_DiffractionEnabled = sceneMXI.isDiffractionEnabled()
print(' Diffraction On:', mxi_DiffractionEnabled)
if mxi_DiffractionEnabled:
mxi_DiffractionIntensity = sceneMXI.getDiffractionIntensity()
mxi_DiffractionFrequency = sceneMXI.getDiffractionFrequency()
print(' Diffraction:', mxi_DiffractionIntensity)
print(' Frequency:', mxi_DiffractionFrequency)
mxi_ScatteringEnabled = sceneMXI.isScatteringEnabled()
print(' Scattering On:', mxi_ScatteringEnabled)
if mxi_ScatteringEnabled:
mxi_Scattering = sceneMXI.getScattering()
print(' Scattering:', mxi_Scattering)
mxi_DevignettingEnabled = sceneMXI.isDevignettingEnabled()
print(' Devignetting On:', mxi_DevignettingEnabled)
if mxi_DevignettingEnabled:
mxi_Devignetting = sceneMXI.getDevignetting()
print(' Devignetting:', mxi_Devignetting)

# -------------- Read MXS file ------------
sceneMXS = Cmaxwell(mwcallback_cb)
sceneMXS.readMXS(mxsfilepath)

# -------------- Transfer Simulens setting back to MXS ----------
if mxi_DiffractionEnabled:
sceneMXS.enableDiffraction()
sceneMXS.setDiffraction(mxi_DiffractionIntensity, mxi_DiffractionFrequency, mxi_ApertureMap, mxi_ObstacleMap)
else:
sceneMXS.setDiffraction(0, 0, mxi_ApertureMap, mxi_ObstacleMap)
if mxi_ScatteringEnabled:
sceneMXS.setRenderParameter('DO SCATTERING_LENS', 1)
sceneMXS.setRenderParameter('SCATTERING_LENS', mxi_Scattering)
if mxi_DevignettingEnabled:
sceneMXS.setRenderParameter('DO DEVIGNETTING', 1)
sceneMXS.setRenderParameter('DEVIGNETTING', mxi_Devignetting)
print("Simulens setting transfer finished.")
sceneMXS.writeMXS(outputFile)
else:
print('MXI or MXS file missing.')
print('Done.')

transferMXISettingToMXS()

Re: TypeError in pymaxwell 5

Posted: Fri Sep 10, 2021 1:12 pm
by Brany
I see that not all the C++ methods of the SDK that use mw::String as input/output parameters (or return value) are properly ported to Python. The following methods are problematic:

Cmaxwell.getEngineVersionSaved
Cmaxwell.setPaths
Cmaxwell.getChannelUserSuffix
Cmaxwell.getChannelSuffixActive
Cmaxwell.setDiffraction

MxiBuffer.getName

CmaxwellMxi.getChannelName
CmaxwellMxi.getChannelShowName
CmaxwellMxi.getChannelSuffix

Sorry about this, we will try to find out a solution or a workaround.

Re: TypeError in pymaxwell 5

Posted: Fri Sep 17, 2021 3:41 am
by Mingfae Wong 20210811011621
Thanks for reply!