Notifications
Clear all

[Closed] MaxScript Object name

I am detaching an object from vertex selection in edit-poly modifier.

I want to give a “new name” name to the new object.

$.modifiers[#Edit_Poly].DetachToObject “new name” don`t work!

$.modifiers[#Edit_Poly].DetachToObject.name = “new name” don`t work!

How do I do it?

Thanks

4 Replies

Try this:

newName = "new name"
$.modifiers[#Edit_Poly].DetachToObject &newName

Notice that the maxscript needs <&TSTR>:

<void>DetachToObject <&TSTR>newObjectName

newObjectName is In and Out parameter
More information on parameters that lead with & can be found here.

-Eric

Thanks Eric

But Im still hitting a wall here. Ive made a short video of the issue…

//youtu.be/pzlaBS4VUug

You didn’t follow my directions, you have to assign the name to a variable and then set &variable to name it work. See the code below.

NOTE: You need to use a unique object name, otherwise it will append a number to it. In your current sample you are naming the new object the same as the starting object.

fn detachObj obj vertArr outName  = (
    -- assign material to variable
    if obj.material != undefined then (
        objMat = obj.material
    ) else (
        objMat = obj.material = standard()
    )
    -- set and cache diffuse map
    objDiff = objMat.diffusemap = Checker()
    -- set object material settings
    objMat.name = outName
    objMat.showInViewport = on
    objDiff.coords.U_Tiling = 25
    objDiff.coords.V_Tiling = 25
    -- cache modifier to variable
    if obj.modifiers[#Edit_Poly] != undefined then (
        epMod = obj.modifiers[#Edit_Poly]
    ) else (
        epMod = edit_poly()
        addmodifier obj epMod		
    )
    -- set modifier active in modpanel
    modpanel.setCurrentObject epMod
    -- set SO Level
    subobjectLevel = 1
    -- set Vertex Selection using supplied BitArray
    epMod.Select #Vertex &vertArr
    -- detach the object and setname using by-reference variable
    epMod.DetachToObject &outname
    -- delete modifier
    deletemodifier obj epMod
)
-- Usage:
-- detachObj <Object> <Vertex_BitArray> <Name_String>
detachObj $ #{1..51,85..2091,2764..2880} "DetachObject"

Now that you have a function all you need to supply to repeat the process is an Object, Vertex BitArray, and an Unique Name.

-Eric

Thanks Eric, works like a charm ;]