首页 > 其他 > 详细

切换应用模块并且修改UG标题栏文字

时间:2018-06-26 00:15:55      阅读:391      评论:0      收藏:0      [点我收藏+]
using System;
using NXOpen;

public class NXJournal
{
    [System.Runtime.InteropServices.DllImport("user32.DLL", EntryPoint = "SetWindowText")]
    public static extern int SetWindowText(IntPtr h, string str);

  public static void Main(string[] args)
  {

    NXOpen.Session theSession = NXOpen.Session.GetSession();
    NXOpen.Part workPart = theSession.Parts.Work;
    NXOpen.Part displayPart = theSession.Parts.Display;

    //UG模块对应名称:
    //加工: UG_APP_MANUFACTURING
    //建模: UG_APP_MODELING
    //基本环境: UG_APP_GATEWAY
    //制图: UG_APP_DRAFTING
    //没有打开部件: UG_APP_NOPART

    //查询当前模块
    string AppName = theSession.ApplicationName;
    //System.Windows.Forms.MessageBox.Show(AppName);

    try    
    {
        //从建模切换到加工 
        if (AppName == "UG_APP_MODELING")
        {
            theSession.ApplicationSwitchImmediate("UG_APP_MANUFACTURING");
        }

        //从加工切换到建模
        else if (AppName == "UG_APP_MANUFACTURING")
        {
            theSession.ApplicationSwitchImmediate("UG_APP_MODELING");
        }

        //其他模块默认切换到建模
        else
        {
            theSession.ApplicationSwitchImmediate("UG_APP_MODELING");
        }

        IntPtr ug = NXOpenUI.FormUtilities.GetDefaultParentWindowHandle();
        SetWindowText(ug, "我的UG");
        AppName = string.Empty;
    }
    catch(Exception e)
    {
        //throw表示把异常抛给UG处理
        //屏蔽这一句,表示捕捉到的任何异常都不处理
        //throw;
    }

  }
  public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; }
}

 

切换应用模块并且修改UG标题栏文字

原文:https://www.cnblogs.com/wangxingzhou/p/9226591.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!