Notifications
Clear all

[Closed] Issue with code: Unknown system exception

So here is the code:

for obj in $* do (
try(ConvertTo obj Editable_Poly)catch()
)
for obj in $* do (
obj.parent = undefined
)
for obj in $* do (
if NOT classof obj == Editable_Poly do (
delete obj
)
) – here it shows the error
for obj in $* do (
if polyop.getNumVerts obj == 0 do (
delete obj
)
)

Works well when executed from listener or editor and even macro. But once I make a rollout and use this in a button I get*Unknown system exception. ?

2 Replies

A few things:
Why are you using $?
Why are you using multiple loops on the same collection of objects, instead of a single loop?
Since you are deleting objects your $
may have reference to a deleted object. You should should check if it is a valid object and not deleted.

for obj in $* where isvalidnode obj AND NOT isdeleted obj do (
   if polyop.getNumVerts obj == 0 do (
      delete obj
   )
)

-Eric

EDIT: Consolidated Code Option:

selArr = selection as array
for obj in selArr do (
   obj.parent = undefined
   if canConvertTo obj Editable_Poly then (
      convertTo obj Editable_Poly
      if polyop.getNumVerts obj == 0 do (
         delete obj
      )
   ) else (
      if isvalidnode obj AND NOT isdeleted obj do (
         delete obj
      )
   )
)

Hi @PiXeL_MoNKeY. Sorry for late response but very busy lately.*

So besically writing an asset importer from maya to max based on alembic.

Im importing a lot of alembic objects. Then I need to clean up the scene and get rid of useless sh*t. I didnt know these two: ‘isdeleted’ and ‘canConvertTo’ thats pretty useful.

However even with your code I get exception error when using in a rollout.*

Im doing some different stuff right now on a weekend, but when I go back to this importer on monday I will show you the exact “not working” code.

Have a nice weekend all!