#401039
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()
You do not have the required permissions to view the files attached to this post.
User avatar
By Brany
#401046
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.
Agate-type crystal / SSS

Hi guys, Thanks for the suggestions, once I come […]

Thanks Andreas - all good information to improve o[…]

Hello Mark, The easiest way would be to load t[…]

Cheers, gives novices something to start from. I p[…]