第一個hello World程序
通過創(chuàng)建一個Hello World的消息框,來熟悉Tecnomatix 二次開發(fā)流程攒砖。具體步驟如下:
(1)使用Visual Studio 創(chuàng)建 C# Class 庫
(2) 添加 Tecnomatix.Engineer.dll引用 設(shè)置copy local = false
(3)設(shè)置output 路徑到 tecnomatix empower DoneTCommand路徑下;
(4)Add new public class
- 添加 using tecnomatix.engineering
- 繼承 TxButtonCommand
- 設(shè)置Name return;
- 設(shè)置Category return
- Execute Command 實現(xiàn)彈出對話框(添加引用Windows Forms)
TxMessageBox.Show("Hello World", "TecnomatixTraining", MessageBoxButtons.OK, MessageBoxIcon.Information);
實現(xiàn)代碼如下(VB.Net 版本,可以自行轉(zhuǎn)為C#版本):
Imports Tecnomatix.Engineering
Imports System.Windows.Forms
''' <summary>
''' Tecnomatix 二次開發(fā)入門教程 3
''' </summary>
''' <remarks></remarks>
Public Class Class3 : Inherits TxButtonCommand
Public Overrides ReadOnly Property Category As String
Get
Return "testPDPS"
End Get
End Property
Public Overrides Sub Execute(cmdParams As Object)
TxMessageBox.Show("Hello World", "TecnomatixTraining", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Public Overrides ReadOnly Property Name As String
Get
Return "Command3"
End Get
End Property
End Class
(5) 注冊命令
將程序集DLL放在<Installation dir> \ DotNetCommands \或其子目錄中。建議將此目錄預(yù)設(shè)為“構(gòu)建配置屬性”的“輸出路徑”字段中的路徑。
通過運行CommandReg應(yīng)用程序?qū)⒚钭裕桑┑絋ecnomatix產(chǎn)品中币狠。
CommandReg.exe位于安裝目錄下,默認情況下為C:\ Program Files \ Tecnomatix \ eMPower砾层。
使用CommandReg漩绵,可以將命令配置添加到.xml文件中,該文件包含將命令集成到所需產(chǎn)品所需的所有信息肛炮。因此渐行,它可以與命令程序集一起分發(fā),以便將其集成到其他計算機中铸董。
要正常工作祟印,.xml文件必須位于<安裝目錄> \ DotNetExternalApplications下。無需為分發(fā).xml文件的每臺計算機單獨運行CommandReg.exe粟害。唯一的要求是在這些計算機上蕴忆,將文件放在<Installation dir> \ DotNetExternalApplications位置。
- 瀏覽到包含新命令的程序集悲幅。
- 從“類”列表中選擇要添加的命令套鹅。
- 選擇要添加命令的產(chǎn)品。 (產(chǎn)品根據(jù)您的安裝列出汰具。)
- 選擇.xml文件名卓鹿。
- 創(chuàng)建新的.xml文件或?qū)⒚钐砑拥?lt;Installation dir> \ DotNetExternalApplications目錄下的現(xiàn)有.xml。
- 單擊注冊留荔。命令注冊將添加到選定的.xml文件中吟孙。
- 要使用CommandReg從產(chǎn)品中取消注冊命令,請選擇與此命令集成的.xml文件,然后單擊“取消注冊”杰妓。保存此命令注冊的部分將從.xml文件中刪除藻治。
以下為xml注冊文件內(nèi)容
<?xml version="1.0" encoding="UTF-8"?>
<TecnomatixConfigurationData>
<ConfigurationsSection>
<Configuration ID="viewer" Name="viewer">
<DotNetCommands>
<Assembly File="DotNetCommands\testPDPS001.dll">
<DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
</Assembly>
</DotNetCommands>
</Configuration>
<Configuration ID="newassemblertc" Name="newassemblertc">
<DotNetCommands>
<Assembly File="DotNetCommands\testPDPS001.dll">
<DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
</Assembly>
</DotNetCommands>
</Configuration>
<Configuration ID="newassembler" Name="newassembler">
<DotNetCommands>
<Assembly File="DotNetCommands\testPDPS001.dll">
<DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
</Assembly>
</DotNetCommands>
</Configuration>
<Configuration ID="newviewer" Name="newviewer">
<DotNetCommands>
<Assembly File="DotNetCommands\testPDPS001.dll">
<DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
</Assembly>
</DotNetCommands>
</Configuration>
</ConfigurationsSection>
</TecnomatixConfigurationData>
(6)通過Customize Ribbon 找到注冊的菜單
“自定義” 添加新命令。然后巷挥,將其拖動到工具欄或菜單中桩卵,單擊即可執(zhí)行。