从MaxScript中的对象列表创建一个Array并将它们添加到新层

时间:2018-08-31 19:23:08

标签: select layer 3dsmax 3ds

我是Maxscript的新手,并且想自动化一个过程,我一直在看一些教程,但是我遇到了选择问题。我想做的是,有一个字符串列表(可能必须添加到其中),这些字符串表示要选择的最大文件中的对象(如果它们存在于该文件中),然后添加到新文件中层。

例如:

/* I have a big long list of objects I want to mass select, this has to be hardcoded because its a similar list that exists in a ton of max files */
rObj1 = "testObj1"
rObj2 = "sampleObj2"
""
rObj99 = "newObj90"

/*I want to then add it to an array
removeList = #(rObj***)

/* Then run through each entry in the array to make sure it exists and then add it to my selection
for i in removeList do
    (
    if i != undefined then select (i)   
    )

/*Then Add what I have selected to a new layer

newLayer = LayerManager.newLayerFromName "removed_list"
for obj in selection do newLayer.addNode obj

选择时我总是出错,这是Max的新手,我不确定该怎么办。

1 个答案:

答案 0 :(得分:0)

您正在尝试选择应该在其中选择(或添加到图层)对象的字符串:

newLayer = LayerManager.newLayerFromName "removed_list"
for objName in removeList where isValidNode (getNodeByName objName) do
    newLayer.addNode (getNodeByName objName)