【问题标题】:call maxscript from another maxscript从另一个 maxscript 调用 maxscript
【发布时间】:2012-10-05 16:23:54
【问题描述】:

我正在尝试编写一个调用外部脚本的函数,但语法上没有任何运气

scripts_folder = "C:\\Program Files\\Autodesk\\3ds Max 2008\\Scripts"
var script1 = "hello_world.ms"

-- use function to call scripts
callScript(script1)

-- function callScript
function callScript script =
(
getFiles scripts_folder + "\\" + script
)

【问题讨论】:

    标签: maxscript


    【解决方案1】:

    最好在这里区分两种可能的解决方案:

    1. 文件输入
    2. 包括

    fileIn 将执行与“运行脚本”相同的操作或在编辑器中评估所有内容。它可以使一个函数在全局声明的情况下可用(不是最好的,使用尽可能少的全局变量),如果它是在该脚本中本地声明的,则您无法访问它。

    Include 实际上从该文件中获取代码并在该点注入它。因此,如果您有一个大脚本并且您想更好地组织事物,您可以在单独的文件中编写某些函数并在脚本执行时包含该函数,以便该函数始终可以访问,因为它包含在该范围内。

    【讨论】:

      【解决方案2】:

      想通了!

      --- "hello_world.ms"
      enter function hello =
      (
      print "hello the world"
      )
      
      
      ---- another _script.ms
      fileIn "hello_world.ms"
      
      -- use function to call scripts
      

      你好()

      似乎 fileIn 比 include 效果更好

      【讨论】:

        猜你喜欢
        • 2018-10-26
        • 2018-09-14
        • 1970-01-01
        • 2014-02-17
        • 2020-10-18
        • 2014-09-23
        • 2018-07-23
        • 2015-11-07
        • 2013-01-08
        相关资源
        最近更新 更多