• 使用.NET(C#或VB.NET)开发NX外部程序


    00219AD81.如何不用将exe程序拷贝到UGII目录下运行?

    答:向上指在调用NX Open命令函数前,将当前目录移动到NX安装目录UGII\,NX安装目录必须和环境变量UGII_BASE_DIR的值一致,否则报错。可以使用如下代码:

    Dim instalDir As String = Environment.GetEnvironmentVariable("UGII_BASE_DIR")
    System.IO.Directory.SetCurrentDirectory(instalDir)

    0021D3652.我的外部程序很小,不想打包NX的.NET库文件一起发布,而是使用用户的库文件,要怎样做呢?

    答:向上指第一步,显示项目所有文件,展开Application.myapp文件,再打开Application.Designer.vb文件,为MyApplication添加Startup事件回调函数,在里面添加如下代码:

    Dim ufdir As String = Environment.GetEnvironmentVariable("UGII_BASE_DIR")
     Reflection.Assembly.LoadFrom(IO.Path.Combine(ufdir, "UGIImanagedNXOpen.dll"))
    Reflection.Assembly.LoadFrom(IO.Path.Combine(ufdir, "UGIImanagedNXOpen.UF.dll"))
    Reflection.Assembly.LoadFrom(IO.Path.Combine(ufdir, "UGIImanagedNXOpen.Utilities.dll"))

    向上指第二步,修改程序运行配置文件:你的exe程序文件名.config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <dependentAssembly>
                    <assemblyIdentity name="NXOpen"  culture="neutral" publicKeyToken="null"/>
                    <codeBase version="8.0.2.2" href="FILE://D:Program FilesSiemensNX 8.0UGIImanagedNXOpen.dll"/>
                </dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="NXOpen.UF"  culture="neutral" publicKeyToken="null"/>
                    <codeBase version="8.0.2.2" href="FILE://D:Program FilesSiemensNX 8.0UGIImanagedNXOpen.UF.dll"/>
                </dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="NXOpen.Utilities"  culture="neutral" publicKeyToken="null"/>
                    <codeBase version="4.0.0.0" href="FILE://D:Program FilesSiemensNX 8.0UGIImanagedNXOpen.Utilities.dll"/>
                </dependentAssembly>
            </assemblyBinding>
        </runtime>
    </configuration>
  • 相关阅读:
    HDU2647(拓扑排序+反向建图)
    Android Activity之间通信
    Swift 编程语言学习0.1——Swift简单介绍
    HDU 5012 Dice (BFS)
    当向后台插入或读取JSON数据遇见回车时
    Android CTS測试Fail项改动总结(四)
    【Unity 3D】学习笔记三十五:游戏实例——摄像机切换镜头
    android蓝牙4.0(BLE)开发之ibeacon初步
    Error opening zip file or JAR manifest missing : D:play-1.2.5/framework/play-1.2.5.jar
    Codeforces Round #256 (Div. 2)——Multiplication Table
  • 原文地址:https://www.cnblogs.com/bizca/p/4978109.html
Copyright © 2020-2023  润新知