zoukankan      html  css  js  c++  java
  • MaxScript重启Max

    这个需要用另外的进程来做,不然执行到关闭就会终止脚本的执行。简单的范例如下

    Fn ReStartMax inputSecond = 
    (
        local CSharpProvider,CompilerParams,CompilerResults,errorMessage
        CSharpCodeSource ="
        using System;
        using System.Diagnostics;
        using System.Threading;
        
        namespace Temp
        {
            static class Program
            {
                public static void Main(string[] args)
                {
                    Thread.Sleep(" + ((inputSecond * 1000 ) as Integer) as string + ");
                    Process.Start(@\""+ GetDir #MaxRoot + "3dsmax.exe" + "\");
                }
            }
        }
        "
        CSharpProvider = DotnetObject "Microsoft.CSharp.CSharpCodeProvider"
        CompilerParams = DotnetObject "System.CodeDom.Compiler.CompilerParameters"
    
        CompilerParams.ReferencedAssemblies.Add("System.dll")
        CompilerParams.GenerateExecutable = true
        CompilerParams.GenerateInMemory = false
        CompilerParams.OutputAssembly  = GetDir #MaxRoot + "ReStartMax.exe"
        CompilerParams.CompilerOptions  = "/target:winexe"
        CompilerResults = CSharpProvider.CompileAssemblyFromSource CompilerParams #(CSharpCodeSource)
        if CompilerResults.errors.HasErrors then
        (
            for i = 0 to CompilerResults.errors.count - 1 do
            (
                errorMessage =  (CompilerResults.errors.item i).line as string + ": " +  (CompilerResults.errors.item i).errorText
                print errorMessage
            )
        )
        else
        (
            ShellLaunch (GetDir #MaxRoot+"ReStartMax.exe") ""
            QuitMax #noPrompt
        )
    )
    
    ReStartMax(60)
  • 相关阅读:
    【pytest】(六) pytest中fixture的使用
    【pytest】(七) pytest的一些你爱不释手的插件
    【pytest】(五) pytest中的断言
    【pytest】(四) pytest的一些其他的运行用法
    本两周学习总结
    本两周学习总结
    本两周总结
    本两周学习总结
    本周学习总结(原生)
    本周学习总结(原生)
  • 原文地址:https://www.cnblogs.com/sitt/p/3065201.html
Copyright © 2011-2022 走看看