Page 1 of 1

Remove material from the scene

Posted: Thu Jan 13, 2022 6:11 am
by Mingfae Wong 20210811011621
I'm trying to remove the material from the scene, the code just doesn't work whatever use "free()" or "extract()", anyone can give me some tip?

scene = Cmaxwell(mwcallback_cb)
scene.readMXS(mxsFile)
material= CmaxwellMaterialIterator()
mat = material.first(scene)
while not mat.isNull():
mat.free()
mat = material.next()
scene.writeMXS(mxsFile)

Re: Remove material from the scene

Posted: Mon Jan 17, 2022 6:36 pm
by Brany
I'm afraid you cannot delete a material from the scene and keep using the material interator. Try to store the materials you want to delete in a list, and then delete each one:
Code: Select all
scene = Cmaxwell(mwcallback_cb)
scene.readMXS(mxsFile)
material= CmaxwellMaterialIterator()
mat = material.first(scene)
matlist = []
while not mat.isNull():
    matlist.append(mat)
    mat = material.next()
for m in matlist:
    mat.free()
scene.writeMXS(mxsFile)

Re: Remove material from the scene

Posted: Tue Jan 18, 2022 8:55 am
by Mingfae Wong 20210811011621
I see, then how about just delete the Coating, BSDF or a Layer in a material? I can only find the "freeEmitter" method in layer but no other.

Re: Remove material from the scene

Posted: Tue Jan 18, 2022 9:00 pm
by Brany
Thas functionality is not available, sorry.

Re: Remove material from the scene

Posted: Thu Jan 20, 2022 6:09 am
by Mingfae Wong 20210811011621
oh...ok...Thank you for answer!