Itoo Software Forum

Author Topic: Constant crash and error message  (Read 5990 times)

Klonsemann

  • Jr. Member
  • **
  • Posts: 61
Re: Constant crash and error message
« Reply #15 on: August 06, 2015, 05:42:27 PM »
I got some time to searche for the problem and finaly found it.
If you add this to a MaxScript in the Startup folder, max crashes as shown in my last posts.

Seems to me that something is stored on a layer that is declared as empty when looking for the nodecount.
So the layer and its contect gets deleted by this script.

Code: [Select]
fn deleteEmptyLayers = (
print "execute deleteEmptyLayers()"
debug = false
trennersign = "---" --internal sign to seperate layers in groups, so this layer stays in the scene even if empty

emptyLayers =#()

defaultlayer = layerManager.getLayerFromName "0"
defaultlayer.current = true

for i = 0 to layerManager.count-1 do (
ilayer = layerManager.getLayer i
layerName = ilayer.name as string
if debug then print layerName
layer = ILayerManager.getLayerObject i
layerNodes = refs.dependents layer
layer.Nodes &theNodesTemp
if theNodesTemp.count == 0  and findString layerName trennersign == undefined do (
append emptyLayers layerName
)
)
for i = 1 to emptyLayers.count do ( layermanager.deleteLayerByName emptyLayers[i] )
if LayerManager.isDialogOpen() == true then (
LayerManager.closeDialog()
layermanager.editlayerbyname ""
)
)

callbacks.addScript #filePostOpen "deleteEmptyLayers()" id:#deleteEmtyLayers_filePostOpen persistent:false

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4388
    • iToo Software
Re: Constant crash and error message
« Reply #16 on: August 08, 2015, 05:56:29 AM »
Ok, i can reproduce the problem. It happens because the script removes unused objects from the "forest_templates" layer, which is used to store billboard templates and library objects.
Forest also runs its own cleanup process on save, so probably there is a conflict between them.

It can be fixed excluding the forest layer in the script :

Code: [Select]
fn deleteEmptyLayers = (
print "execute deleteEmptyLayers()"
debug = false
trennersign = "---" --internal sign to seperate layers in groups, so this layer stays in the scene even if empty

emptyLayers =#()

defaultlayer = layerManager.getLayerFromName "0"
defaultlayer.current = true

for i = 0 to layerManager.count-1 do (
ilayer = layerManager.getLayer i
layerName = ilayer.name as string
if layerName != "forest_templates" then (
if debug then print layerName
layer = ILayerManager.getLayerObject i
layerNodes = refs.dependents layer
layer.Nodes &theNodesTemp
if theNodesTemp.count == 0  and findString layerName trennersign == undefined do (
append emptyLayers layerName
)
)
)
for i = 1 to emptyLayers.count do ( layermanager.deleteLayerByName emptyLayers[i] )
if LayerManager.isDialogOpen() == true then (
LayerManager.closeDialog()
layermanager.editlayerbyname ""
)
)

callbacks.addScript #filePostOpen "deleteEmptyLayers()" id:#deleteEmtyLayers_filePostOpen persistent:false

Additionally i suggest to not rename this layer, or move the objects from it. It nof, other unexpected problems would happen.

Carlos Quintero
iToo Software

Klonsemann

  • Jr. Member
  • **
  • Posts: 61
Re: Constant crash and error message
« Reply #17 on: August 08, 2015, 04:54:24 PM »
I changed the code exactly in that way to prevent the crashing.

I'm very glad to have that problem solved !

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4388
    • iToo Software
Re: Constant crash and error message
« Reply #18 on: August 09, 2015, 03:13:58 AM »
That's great! Glad we could help out. :)
Carlos Quintero
iToo Software