如果不使用脚本,我们导入obj模型的界面是这个样子的:
调节的参数,只有我们点击了import之后,这些参数才会保存。比如,我导入obj文件时,不想导入材质,那么把Import materials 去掉勾选就可以了。问题是:这个保存只保留在自己电脑,如果被人拿到你的max文件,导入obj模型时,这个操作就会消失,会根据对方默认的设置进行导入。
此时,我们有两种方法,一是在对方电脑上先导入一个模型,把import materials √去掉。这样对方电脑也和我们一样。另外一种方法是直接调节参数保存的文件,该设置的文件保存路径:C:\Users\admin\AppData\Local\Autodesk\3dsMax\2017 - 64bit\ENU\en-US\plugcfg\gw_objimp.ini 。该文档界面如下:
将ImportMaterials=0(不导入材质)、1(导入材质)
感觉上面说的这些都是废话,会用max的人进本都知道????
问题:如果不用人手工来修改呢?我的max文件在别人电脑导入obj就是不要材质呢?
解决:写脚本,自动执行修改。
--Open the INI file for editing in the MAXScript Editor
edit (objimp.getIniName())
--Alternatively, use INI file access to read and write:
theINI =objimp.getIniName()
getIniSetting theINI--get INI file categories
-->#("General", "Objects", "Geometry", "Units/Scale", "Material")
--get the keys of the General category:
getIniSetting theINI "Geometry"
-->#("FlipZyAxis", "CenterPivots", "Shapes", "TextureCoords", "SmoothingGroups", "NormalsType", "SmoothAngle", "FlipNormals")
--get thevalueof theGeometry>Shapeskey:
getIniSetting theINI "Geometry""Shapes"
-->"0"
--TurnShapes on:
setIniSetting theINI "Geometry""Shapes" "1"
-->true
setIniSetting theINI "Geometry""FlipZyAxis" "0"
做了一下反转测试(setIniSetting theINI "Geometry""FlipZyAxis" "0"),亲测可用。
搞定!!!