Home Coding, Scripting, Shaders

[Maxscript] Add Object to layer

polycounter lvl 14
Offline / Send Message
.morph3us polycounter lvl 14
At work we need to convert a scene from 3DSMax - Vray to Cinema 4D - Corona.
For this we bought a script from 3DtoAll, but it does not keep the VrayProxies.
So I thought I could easily do this automated in Maxscript, but am failing. Maybe someone is up for helping me?

Basically at the moment I want to addthe reimported Mesh to the layer the original proxy was in, but I constantly get a
"Unable to convert: #($XYZ @ [-40.608887,-460.106506,487.212769]) to type: <node>"
(where XYZ is the name of the reimported mesh.)

I have this:
for obj in objects do(
    if classof obj == VRayProxy then(
        reimport = vrayMeshImport proxy: obj
        redrawViews()
        reimport.transform = obj.transform
        reimport.material = obj.material
        obj.layer.addNode reimport
        delete obj
    )
)
(If one of you gods is bored and would like to help me even further, is there a good way to keep the instancing of the Proxies with the reimports?)

Thanks in advance! :)

Replies

  • Noors
    Offline / Send Message
    Noors greentooth
    vrayMeshImport returns an array of objects because you can have several meshes per proxy. Something like  #(myObject) is an array with a single element, but not the element itself.
    So you need to parse the array to put each object in the layer, even if you only have 1.
    Some properties like .transform and .material can be set to a collection of objects, hence there's no error here.
    for r in reimport do obj.layer.addNode r

  • .morph3us
    Offline / Send Message
    .morph3us polycounter lvl 14
    I wasnt aware that it returned an array, your explanation makes sense! Thank you!
Sign In or Register to comment.