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)
  • 相关阅读:
    gRPC .NET Core跨平台学习
    .NET Core性能测试组件BenchmarkDotNet 支持.NET Framework Mono
    ASP.NET Core中间件(Middleware)实现WCF SOAP服务端解析
    gRPC C#学习
    中标麒麟关闭防火墙
    linux安装python
    python matplotlib.pyplot保存jpg图片失败
    python正态分布
    数据健康管理总结
    python使用statsmodel
  • 原文地址:https://www.cnblogs.com/sitt/p/3065201.html
Copyright © 2011-2022 走看看