맥스스크립트 심화

배치스크립트 2

스크립팅하는애님 2021. 6. 27. 20:04
728x90
반응형

안녕하세요.

애니메이터가 들려주는 MAX Script의 스크립팅하는 애님입니다.

 

지난 시간에 이어서 배치 스크립트를 계속 진행하겠습니다.

 

우선 지난시간까지 작업한 내용을 보겠습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
exportBone = #($'Tube001', $'Teapot001')
select exportBone
 
pluginManager.loadClass FBXExporter
FBXExporterSetParam "SmoothingGroups" true
FBXExporterSetParam "NormalsPerPoly" false
FBXExporterSetParam "TangentSpaceExport" true
FBXExporterSetParam "SmoothMeshExport" false
FBXExporterSetParam "Preserveinstances" false
FBXExporterSetParam "SelectionSetExport" false
FBXExporterSetParam "GeomAsBone" true
FBXExporterSetParam "Triangulate" false            
FBXExporterSetParam "Animation" true
FBXExporterSetParam "UseSceneName" true
FBXExporterSetParam "Removesinglekeys" false
FBXExporterSetParam "BakeAnimation" true
FBXExporterSetParam "BakeFrameStart" (animationRange.start.frame as integer)
FBXExporterSetParam "BakeFrameEnd" (animationRange.end.frame as integer)
FBXExporterSetParam "BakeFrameStep" 1
FBXExporterSetParam "Skin" true
FBXExporterSetParam "Shape" true
FBXExporterSetParam "FilterKeyReducer" false
FBXExporterSetParam "PointCache" false                
FBXExporterSetParam "Cameras" false            
FBXExporterSetParam "Lights" false            
FBXExporterSetParam "EmbedTextures" false            
FBXExporterSetParam "ScaleFactor" 1.0
FBXExporterSetParam "ConvertUnit" "cm"
FBXExporterSetParam "UpAxis" "Z"
FBXExporterSetParam "ShowWarnings" false
FBXExporterSetParam "GenerateLog" false
FBXExporterSetParam "ASCII" false
FBXExporterSetParam "FileVersion" "FBX201600"
 
exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
exportFile pathFile #noPrompt selectedOnly:true
cs

 

위 상태에서 스크립트를 추가하여 진행해도 되겠지만 이해를 돕기 위해 우선은 배치 스크립트의 기본형을 만들어 보도록 하겠습니다.

배치 스크립트를 짜는 방식은 여러 개가 있겠지만, 개인적으로 작업의 효율을 생각해 배치에 적용된 파일을 한 폴더에 모두 넣어 폴더를 기준으로 적용이 되는 방식을 추천합니다. (여러 폴더에서 적용될 파일을 따로 정하는 것은 상당히 비효율적이거든요. ㅎㅎㅎ)

 

해결할 문제는

1. 적용할 폴더를 선택한다.

2. 폴더의 모든 맥스 파일을 저장한다

3. 모든 맥스파일을 돌면서 스크립트를 적용한다.

정도가 되겠네요.

이 부분이 지난 시간의 해결할 문제 3번인 '1, 2의 작업을 다수의 맥스 파일에 적용'에 해당하는 부분입니다.

 

우선 적용할 폴더를 선택하는 것을 해결하겠습니다.

다음과 같이 입력하고 확인은 하지 않겠습니다.

 

1
2
3
4
5
getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
if(getDirPath != undefined) do
(
)
cs

 

1번 라인은 폴더 선택 창이 열리면서  폴더를 선택할 수 있습니다.

 

 

만약 여기서 'Select Folder'를 클릭하면 해당 폴더의 패스가 'GetDirPath'변수에 저장되고 그렇지 않고 'Cancel'을 클릭하면 'undefined'가 저장이 됩니다.

3번 라인의 if문은 폴더를 선택했을 경우 하위 내용을 실행하고 그렇지 않으면 스크립트는 동작하지 않습니다.

 

다음으로 폴더를 선택했다면 해당 폴더에 있는 맥스 파일을 찾아서 적당한 변수에 저장을 합니다.

(저는 이전에 만든 '샘플1.max'파일을 2개 더 복사해서 '샘플2.max', '샘플3.max'파일을 만들었습니다.)

다음과 같이 입력하고 내용을 확인해 보겠습니다.

 

1
2
3
4
5
6
7
8
9
10
getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
if(GetDirPath != undefined) do
(
    maxlist = getFiles (getDirPath + "\\*.max")
    for i = 1 to maxlist.count do
    (
        format "%\n" maxlist[i]
    )
)
cs

 

 

위 이미지와 비슷하게 나왔으면 정상적으로 작동하는 것입니다.

5번 라인의 내용은 선택한 폴더에서 'max'라는 확장자를 가지고 있는 모든 파일을 변수 maxlist에 저장하라는 의미입니다.

6번 라인의 for문은 maxlist에 저장된 파일명을 확인하는 것이기 때문에 실제 스크립트에 필요한 내용은 압니다.

정상 작동하는 것을 봤으면 삭제해도 무방합니다.

 

마지막으로 모든 맥스 파일을 돌면서 스크립트를 적용합니다.

다음과 같이 입력하고 실행하지는 마세요.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
if(GetDirPath != undefined) do
(
    maxlist = getFiles (getDirPath + "\\*.max")
    for i = 1 to maxlist.count do
    (
        loadmaxfile maxlist[i] quiet:on
        -- 적용할 스크립트
        
        saveMaxFile maxlist[i]
    
        resetMaxFile #noPrompt
    )
)
cs

 

8번 라인의 내용은 맥스파일을 오픈하는 내용입니다.

6번 라인의 for문에 의해 선택한 폴더에 있는 맥스 파일들을 하나씩 돌면서 오픈하게 됩니다.

'quiet:on'을 했기 때문에 오픈할 때 물어보는 대화창은 모두 스킵됩니다.

9번 라인에 적용해야 할 스크립트를 입력합니다.

11번 라인은 저장하고 종료할 필요가 있을 때 사용하고 없다면 쓰지 않아도 무방합니다.

13번 라인은 오픈된 정보를 깨끗이 비우기 위해 리셋을 합니다.

 

기본적으로 위 내용만 사용하면 되지만 

1. 선택한 폴더에 맥스 파일이 없다면?

2. 배치 스크립트를 사용할 때 계속적으로 파일을 읽어 올 텐데 이미 맥스 파일이 열려 있는 상태라면? 미리 열린 파일을 무시하고 리셋할 것인가? 저장을 할것인가?

와 같은 예외상황 발생합니다.

스크립트를 만든 사람은 만들면서 이럴 때는 이렇게 하고 저럴 때는 저렇게 하자고 예외 상항을 염두하지만 제작하지 않은사람은 예외상항을 숙지하지 못하기 때문에 스크립트가 에러가 나거나 결과물이 이상하게 나오는 경우가 많습니다.

(저 또한 작업한 스크립트를 오랜만에 열면 어떻게 하더라 하는 경우도 많습니다. ㅎㅎ)

 

우선 선택한 폴더에 맥스 파일이 없을 경우를 대비해 다음과 같이 수정하겠습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
if(GetDirPath != undefined) do
(
    maxlist = getFiles (getDirPath + "\\*.max")
    if(maxlist.count != 0) then
    (
        for i = 1 to maxlist.count do
        (
            loadmaxfile maxlist[i] quiet:on
            -- 적용할 스크립트
            
            saveMaxFile maxlist[i]
        
            resetMaxFile #noPrompt
        )
    )
    else messagebox "맥스파일이 없습니다."
)
cs

 

maxlist의 수를 세어 0이 아니면 정상 작동을 0이면 메시지 박스가 나오도록 했습니다.

 

다음으로 배치 스크립트를 하기 전에 맥스 파일이 열려 있는 경우를 위해 다음과 같이 수정하겠습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if(maxFileName == "") then
(
    getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
    if(GetDirPath != undefined) do
    (
        maxlist = getFiles (getDirPath + "\\*.max")
        if(maxlist.count != 0) then
        (
            for i = 1 to maxlist.count do
            (
                loadmaxfile maxlist[i] quiet:on
                -- 적용할 스크립트
                
                saveMaxFile maxlist[i]
            
                resetMaxFile #noPrompt
            )
        )
        else messagebox "맥스파일이 없습니다."
    )
)
else messagebox "맥스파일이 열려 있습니다."
cs

 

maxFileName를 사용하여 현제 열려있는 파일의 이름이 있으면 메시지 박스를 띄우고 이름이 없으면 실행하도록 했습니다.

이제 이전에 작업했던 내용을 '-- 적용할 스크립트'에 넣어줍니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if(maxFileName == "") then
(
    getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
    if(GetDirPath != undefined) do
    (
        maxlist = getFiles (getDirPath + "\\*.max")
        if(maxlist.count != 0) then
        (
            for i = 1 to maxlist.count do
            (
                loadmaxfile maxlist[i] quiet:on
                
                exportBone = #($'Tube001', $'Teapot001')
                select exportBone
 
                pluginManager.loadClass FBXExporter
                FBXExporterSetParam "SmoothingGroups" true
                FBXExporterSetParam "NormalsPerPoly" false
                FBXExporterSetParam "TangentSpaceExport" true
                FBXExporterSetParam "SmoothMeshExport" false
                FBXExporterSetParam "Preserveinstances" false
                FBXExporterSetParam "SelectionSetExport" false
                FBXExporterSetParam "GeomAsBone" true
                FBXExporterSetParam "Triangulate" false            
                FBXExporterSetParam "Animation" true
                FBXExporterSetParam "UseSceneName" true
                FBXExporterSetParam "Removesinglekeys" false
                FBXExporterSetParam "BakeAnimation" true
                FBXExporterSetParam "BakeFrameStart" (animationRange.start.frame as integer)
                FBXExporterSetParam "BakeFrameEnd" (animationRange.end.frame as integer)
                FBXExporterSetParam "BakeFrameStep" 1
                FBXExporterSetParam "Skin" true
                FBXExporterSetParam "Shape" true
                FBXExporterSetParam "FilterKeyReducer" false
                FBXExporterSetParam "PointCache" false                
                FBXExporterSetParam "Cameras" false            
                FBXExporterSetParam "Lights" false            
                FBXExporterSetParam "EmbedTextures" false            
                FBXExporterSetParam "ScaleFactor" 1.0
                FBXExporterSetParam "ConvertUnit" "cm"
                FBXExporterSetParam "UpAxis" "Z"
                FBXExporterSetParam "ShowWarnings" false
                FBXExporterSetParam "GenerateLog" false
                FBXExporterSetParam "ASCII" false
                FBXExporterSetParam "FileVersion" "FBX201600"
 
                exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
                pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
                exportFile pathFile #noPrompt selectedOnly:true
 
                saveMaxFile maxlist[i]
            
                resetMaxFile #noPrompt
            )
        )
        else messagebox "맥스파일이 없습니다."
    )
)
else messagebox "맥스파일이 열려 있습니다."
cs

 

이대로 실행하기 전에 정리를 해야 할 것 같습니다.

맥스 파일을 열 때마다 매번 세팅값을 넣을 필요가 없는 것들은 밖으로 빼주는 게 좋을 것 같습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
exportBone = #($'Tube001', $'Teapot001')
select exportBone
 
pluginManager.loadClass FBXExporter
FBXExporterSetParam "SmoothingGroups" true
FBXExporterSetParam "NormalsPerPoly" false
FBXExporterSetParam "TangentSpaceExport" true
FBXExporterSetParam "SmoothMeshExport" false
FBXExporterSetParam "Preserveinstances" false
FBXExporterSetParam "SelectionSetExport" false
FBXExporterSetParam "GeomAsBone" true
FBXExporterSetParam "Triangulate" false            
FBXExporterSetParam "Animation" true
FBXExporterSetParam "UseSceneName" true
FBXExporterSetParam "Removesinglekeys" false
FBXExporterSetParam "BakeAnimation" true
FBXExporterSetParam "BakeFrameStart" (animationRange.start.frame as integer)
FBXExporterSetParam "BakeFrameEnd" (animationRange.end.frame as integer)
FBXExporterSetParam "BakeFrameStep" 1
FBXExporterSetParam "Skin" true
FBXExporterSetParam "Shape" true
FBXExporterSetParam "FilterKeyReducer" false
FBXExporterSetParam "PointCache" false                
FBXExporterSetParam "Cameras" false            
FBXExporterSetParam "Lights" false            
FBXExporterSetParam "EmbedTextures" false            
FBXExporterSetParam "ScaleFactor" 1.0
FBXExporterSetParam "ConvertUnit" "cm"
FBXExporterSetParam "UpAxis" "Z"
FBXExporterSetParam "ShowWarnings" false
FBXExporterSetParam "GenerateLog" false
FBXExporterSetParam "ASCII" false
FBXExporterSetParam "FileVersion" "FBX201600"
                
if(maxFileName == "") then
(
    getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
    if(GetDirPath != undefined) do
    (
        maxlist = getFiles (getDirPath + "\\*.max")
        if(maxlist.count != 0) then
        (
            for i = 1 to maxlist.count do
            (
                loadmaxfile maxlist[i] quiet:on
 
                exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
                pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
                exportFile pathFile #noPrompt selectedOnly:true
 
                saveMaxFile maxlist[i]
            
                resetMaxFile #noPrompt
            )
        )
        else messagebox "맥스파일이 없습니다."
    )
)
else messagebox "맥스파일이 열려 있습니다."
cs

 

이상태에서 실행하면 잘 될 것 같지만 그렇지가 않습니다.

fbx파일은 생성되지만, fbx파일을 열어보면 오브젝트가 없습니다.

이유는 1번 라인 때문인데요.

맥스에서 '$'가 붙을 경우 오브젝트를 의미합니다.

그런데 열려있는 파일이 없는 상태에서 실행하면 1번 라인에서 변수에 넣는 오브젝트는 모두 존재하지 않기 때문에 없는 것으로(undefined) 취급이 됩니다.

그래서  'exportBone'에는 '#($'Tube001', $'Teapot001')'값이 아닌 '#(undefined, undefined)'가 됩니다.

그래서 2번 라인에 오는 선택 명령에서도 아무것도 선택하지 못하게 됩니다.

밖으로 빼낸 것 중에 일부를 다시 안으로 넣도록 하겠습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pluginManager.loadClass FBXExporter
FBXExporterSetParam "SmoothingGroups" true
FBXExporterSetParam "NormalsPerPoly" false
FBXExporterSetParam "TangentSpaceExport" true
FBXExporterSetParam "SmoothMeshExport" false
FBXExporterSetParam "Preserveinstances" false
FBXExporterSetParam "SelectionSetExport" false
FBXExporterSetParam "GeomAsBone" true
FBXExporterSetParam "Triangulate" false            
FBXExporterSetParam "Animation" true
FBXExporterSetParam "UseSceneName" true
FBXExporterSetParam "Removesinglekeys" false
FBXExporterSetParam "BakeAnimation" true
FBXExporterSetParam "BakeFrameStart" (animationRange.start.frame as integer)
FBXExporterSetParam "BakeFrameEnd" (animationRange.end.frame as integer)
FBXExporterSetParam "BakeFrameStep" 1
FBXExporterSetParam "Skin" true
FBXExporterSetParam "Shape" true
FBXExporterSetParam "FilterKeyReducer" false
FBXExporterSetParam "PointCache" false                
FBXExporterSetParam "Cameras" false            
FBXExporterSetParam "Lights" false            
FBXExporterSetParam "EmbedTextures" false            
FBXExporterSetParam "ScaleFactor" 1.0
FBXExporterSetParam "ConvertUnit" "cm"
FBXExporterSetParam "UpAxis" "Z"
FBXExporterSetParam "ShowWarnings" false
FBXExporterSetParam "GenerateLog" false
FBXExporterSetParam "ASCII" false
FBXExporterSetParam "FileVersion" "FBX201600"
                
if(maxFileName == "") then
(
    getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
    if(GetDirPath != undefined) do
    (
        maxlist = getFiles (getDirPath + "\\*.max")
        if(maxlist.count != 0) then
        (
            for i = 1 to maxlist.count do
            (
                loadmaxfile maxlist[i] quiet:on
                    
                exportBone = #($'Tube001', $'Teapot001')
                select exportBone
 
                exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
                pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
                exportFile pathFile #noPrompt selectedOnly:true
 
                saveMaxFile maxlist[i]
            
                resetMaxFile #noPrompt
            )
        )
        else messagebox "맥스파일이 없습니다."
    )
)
else messagebox "맥스파일이 열려 있습니다."
cs

 

이제 실행하면 스크립트가 정상적으로 작동합니다.

이대로 사용해도 될 것 같지만 한 가지 고민이 생겼습니다.

만약 내가 정해놓은 오브젝트가 해당 맥스 파일에 없으면 어떻게 할 것인가?

테스트를 해보도록 하겠습니다.

'샘플2.max'파일에는 'Teapot001'오브젝트를 삭제하고 '샘플3.max'파일에는 'Tube001'와 'Teapot001'을 모두 삭제하고 결과를 확인해 보겠습니다.

원하는 건 '샘플2.fbx'파일에서는 'Teapot001'오브젝트를 제외한 'Tube001'오브젝트가 익스포트 되고,

'샘플3.fbx'파일은 아예 생성되지 않았으면 좋겠습니다.

 

'샘플2.max'

 

샘플3.max

 

'샘플2.max'파일에서 에러가 나기 시작하네요.

'샘플2.max'파일의 'exportBone'값은 '#($Tube:Tube001 @ [8.575972,63.080135,0.000000], undefined)'가 됩니다.

이것을 'select'하였더니 에러가 났습니다.

존재하지 않는 오브젝트를 선택했기 때문에 생긴 문제였습니다.

수정을 해보겠습니다.

방법은 for문을 사용하여 'exportBone'을 하나씩 돌면서 선택을 하고 'undefined'가 나오면 선택하지 않도록 합니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..................
for i = 1 to maxlist.count do
(
    loadmaxfile maxlist[i] quiet:on
        
    exportBone = #($'Tube001', $'Teapot001')
                
    for j = 1 to exportBone.count do
    (
        if(exportBone[j] != undefined) do selectMore exportBone[j]
    )
 
    exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
    pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
    exportFile pathFile #noPrompt selectedOnly:true
 
    saveMaxFile maxlist[i]
            
    resetMaxFile #noPrompt
)
..................
cs

 

여기서 조금 더 설명하자면 이전에는 선택할 노드를 'select'를 사용하여 한번에 선택했지만 이번에는 for문을 사용하여 하나씩 선택하기 때문에 'selectMore'를 사용하여 추가 선택하는 방식을 선택했습니다.

결과는 '샘플2.max'는 정상적으로 익스포트 됐지만, 익스포트를 원치 않은 '샘플3.max'은 빈 파일로 '샘플3.fbx'파일을 익스포트 했습니다.

 

조금 더 수정하겠습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..................
for i = 1 to maxlist.count do
(
    loadmaxfile maxlist[i] quiet:on
                    
    exportBone = #($'Tube001', $'Teapot001')
                
    for j = 1 to exportBone.count do
    (
        if(exportBone[j] != undefined) do selectMore exportBone[j]
    )
                
    if((selection as array).count != 0)do
    (
        exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
        pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
        exportFile pathFile #noPrompt selectedOnly:true
    )
 
    saveMaxFile maxlist[i]
            
    resetMaxFile #noPrompt
)
..................
cs

 

13번 라인의 if문을 사용하여 현재 선택된 오브젝트의 수가 0이면 익스포트를 하지 않도록 하였습니다.

이제 실행하면 원하는 데로 일부 오브젝트만 있으면 일부 오브젝트만 익스포트 하고 오브젝트가 없으면 아예 익스포트를 하지 않게 됐습니다.

 

지금까지 작업한 스크립트는 다음과 같습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pluginManager.loadClass FBXExporter
FBXExporterSetParam "SmoothingGroups" true
FBXExporterSetParam "NormalsPerPoly" false
FBXExporterSetParam "TangentSpaceExport" true
FBXExporterSetParam "SmoothMeshExport" false
FBXExporterSetParam "Preserveinstances" false
FBXExporterSetParam "SelectionSetExport" false
FBXExporterSetParam "GeomAsBone" true
FBXExporterSetParam "Triangulate" false            
FBXExporterSetParam "Animation" true
FBXExporterSetParam "UseSceneName" true
FBXExporterSetParam "Removesinglekeys" false
FBXExporterSetParam "BakeAnimation" true
FBXExporterSetParam "BakeFrameStart" (animationRange.start.frame as integer)
FBXExporterSetParam "BakeFrameEnd" (animationRange.end.frame as integer)
FBXExporterSetParam "BakeFrameStep" 1
FBXExporterSetParam "Skin" true
FBXExporterSetParam "Shape" true
FBXExporterSetParam "FilterKeyReducer" false
FBXExporterSetParam "PointCache" false                
FBXExporterSetParam "Cameras" false            
FBXExporterSetParam "Lights" false            
FBXExporterSetParam "EmbedTextures" false            
FBXExporterSetParam "ScaleFactor" 1.0
FBXExporterSetParam "ConvertUnit" "cm"
FBXExporterSetParam "UpAxis" "Z"
FBXExporterSetParam "ShowWarnings" false
FBXExporterSetParam "GenerateLog" false
FBXExporterSetParam "ASCII" false
FBXExporterSetParam "FileVersion" "FBX201600"
                
if(maxFileName == ""then
(
    getDirPath = getSavePath caption:"소스 MAX파일 폴더 선택"()
 
    if(GetDirPath != undefined) do
    (
        maxlist = getFiles (getDirPath + "\\*.max")
        if(maxlist.count != 0then
        (
            for i = 1 to maxlist.count do
            (
                loadmaxfile maxlist[i] quiet:on
                    
                exportBone = #($'Tube001', $'Teapot001')
                
                for j = 1 to exportBone.count do
                (
                    if(exportBone[j] != undefined) do selectMore exportBone[j]
                )
                
                if((selection as array).count != 0)do
                (
                    exptFileName = getFilenameFile maxFileName --맥스의 파일명을 구함.
                    pathFile = maxfilepath + "\\" + exptFileName + ".fbx"
                    exportFile pathFile #noPrompt selectedOnly:true
                )
 
                saveMaxFile maxlist[i]
            
                resetMaxFile #noPrompt
            )
        )
        else messagebox "맥스파일이 없습니다."
    )
)
else messagebox "맥스파일이 열려 있습니다."
cs

 

 

이렇게 배치 스크립트의 기본형과 선택한 노드의 익스포트에 대해 이야기했습니다.

수고하셨습니다.

728x90
반응형