StandardAddInServer.vb 273.9 KB
Newer Older
leaky114's avatar
leaky114 已提交
1 2 3 4 5 6 7
'设置为一个动作,可一次撤销
'Dim transientGeometry As TransientGeometry
'                transientGeometry = ThisApplication.TransientGeometry
''start a transaction so the slot will be within a single undo step
'Dim createSlotTransaction As Transaction
'                createSlotTransaction = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument, "重新设置序号")

leaky114's avatar
21.12.3  
leaky114 已提交
8
'
leaky114's avatar
leaky114 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22

''end the transactio
'createSlotTransaction.End()

Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Drawing
Imports System.IO
Imports Inventor
Imports Inventor.SelectionFilterEnum
Imports Inventor.DocumentTypeEnum
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports Microsoft
leaky114's avatar
leaky114 已提交
23 24
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
leaky114's avatar
leaky114 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

Namespace InventorAddIn
    <ProgIdAttribute("InventorAddIn.StandardAddInServer"), _
    GuidAttribute("0a8e6d1d-68ec-48be-9e61-32779d2aae77")> _
    Public Class StandardAddInServer
        Implements Inventor.ApplicationAddInServer

#Region "Data Member"

        '============================================================
        '定义 按钮
        '
        '获取文件名修改iProperty           1
        Private WithEvents m_修改文件iProperty_Buttondef As Inventor.ButtonDefinition

        '获取部件子集修改iProperty           2
        Private WithEvents m_修改部件iProperty_Buttondef As Inventor.ButtonDefinition

        '更改文件名     3
        Private WithEvents m_更改文件名_Buttondef As Inventor.ButtonDefinition

        '提取iProperty更改文件名        4
        Private WithEvents m_提取iPro修改文件名_Buttondef As Inventor.ButtonDefinition

        '自动生成零件图号       5
        Private WithEvents m_生成图号_Buttondef As Inventor.ButtonDefinition

        '更改镜像零件文件名          6
        Private WithEvents m_更改镜像文件名_Buttondef As Inventor.ButtonDefinition

        '打开文件所在文件夹           7
        Private WithEvents m_打开文件夹_Buttondef As Inventor.ButtonDefinition

        '保存并关闭         8
        Private WithEvents m_保存关闭_Buttondef As Inventor.ButtonDefinition

        '另存为pdf                9
        Private WithEvents m_另存为Pdf_Buttondef As Inventor.ButtonDefinition

        '另存为dwg    10
        Private WithEvents m_另存为Dwg_Buttondef As Inventor.ButtonDefinition

        '设置bom结构    11
        Private WithEvents m_设置BOM结构_Buttondef As Inventor.ButtonDefinition

        '比例   12
        Private WithEvents m_设置比例_Buttondef As Inventor.ButtonDefinition

        '对称件iProperty      13
        Private WithEvents m_设置对称件iProperty_Buttondef As Inventor.ButtonDefinition

        '检查序号完整性     14
        Private WithEvents m_检查序号完整性_Buttondef As Inventor.ButtonDefinition

        '新建序号       15
        Private WithEvents m_新建序号_Buttondef As Inventor.ButtonDefinition

        '设置日期       16
        Private WithEvents m_设置日期_Buttondef As Inventor.ButtonDefinition

        '清除日期       17
        Private WithEvents m_清除日期_Buttondef As Inventor.ButtonDefinition

        '自定义日期     18
        Private WithEvents m_自定义日期_Buttondef As Inventor.ButtonDefinition

        '签字       19
        Private WithEvents m_设置签字_Buttondef As Inventor.ButtonDefinition

leaky114's avatar
21.12.3  
leaky114 已提交
94
        '清除签字     20
leaky114's avatar
leaky114 已提交
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
        Private WithEvents m_清除签字_Buttondef As Inventor.ButtonDefinition

        '自定义签字     21
        Private WithEvents m_自定义签字_Buttondef As Inventor.ButtonDefinition

        '设置       22
        Private WithEvents m_设置_Buttondef As Inventor.ButtonDefinition

        '量产iPropertys       23
        Private WithEvents m_量产iPropertys_Buttondef As Inventor.ButtonDefinition

        '批量另存为     24
        Private WithEvents m_工程图批量另存为_Buttondef As Inventor.ButtonDefinition

        '关于   25
        Private WithEvents m_关于_Buttondef As Inventor.ButtonDefinition

        '26
        Private WithEvents m_保存关闭所有部件_Buttondef As ButtonDefinition

leaky114's avatar
leaky114 已提交
115 116
        ''27
        'Private WithEvents m_保存关闭所有零件_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
117

leaky114's avatar
leaky114 已提交
118 119
        ''28
        'Private WithEvents m_保存关闭所有工程图_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

        '29
        'Private WithEvents m_绘制槽孔_Buttondef As ButtonDefinition

        '30
        Private WithEvents m_设置描述_Buttondef As ButtonDefinition

        '31
        Private WithEvents m_刷新引用_Buttondef As ButtonDefinition

        '32
        Private WithEvents m_清理旧版文件_Buttondef As ButtonDefinition

        ''33
        Private WithEvents m_添加直径_Buttondef As ButtonDefinition

        '34
        Private WithEvents m_全部另存为_Buttondef As ButtonDefinition

        '35
        Private WithEvents m_检查是否有工程图_Buttondef As ButtonDefinition

        '36
        Private WithEvents m_打开全部工程图_Buttondef As ButtonDefinition

        Private WithEvents m_打开指定工程图_Buttondef As ButtonDefinition

        '37
        Private WithEvents m_部件替换文件名_Buttondef As ButtonDefinition

        '38
        Private WithEvents m_导出平面BOM_Buttondef As ButtonDefinition

        '39
        Private WithEvents m_还原旧图_Buttondef As ButtonDefinition

        '40
        Private WithEvents m_帮助_Buttondef As ButtonDefinition

        '41
        Private WithEvents m_移动指定文件_Buttondef As ButtonDefinition

        '42
        Private WithEvents m_对齐原始坐标面_Buttondef As ButtonDefinition

        '43
        Private WithEvents m_查找缺失文件的部件_Buttondef As ButtonDefinition

        '44
        Private WithEvents m_统计质量面积_Buttondef As ButtonDefinition

        '45
        Private WithEvents m_调整IPro顺序_Buttondef As ButtonDefinition

        '46
        Private WithEvents m_插入序号_Buttondef As Inventor.ButtonDefinition

        '47
        Private WithEvents m_尺寸圆整_Buttondef As Inventor.ButtonDefinition

        '48
        Private WithEvents m_导入存货编码_Buttondef As Inventor.ButtonDefinition

        '49
leaky114's avatar
leaky114 已提交
184
        Private WithEvents m_ERP材料编码_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
185 186 187 188 189 190

        '50
        Private WithEvents m_打开工程图_Buttondef As ButtonDefinition

        '51
        Private WithEvents m_批量打印_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
191 192 193

        '52
        Private WithEvents m_重写BOM序号_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
194 195 196

        '53
        Private WithEvents m_查询ERP编码_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
197 198 199

        '54
        Private WithEvents m_打开ERP数据文件_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
200

leaky114's avatar
leaky114 已提交
201 202
        '55
        Private WithEvents m_快速打开_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
203

leaky114's avatar
leaky114 已提交
204 205
        ''27
        'Private WithEvents m_关闭所有零件_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
206

leaky114's avatar
leaky114 已提交
207 208
        ''28
        'Private WithEvents m_关闭所有工程图_Buttondef As ButtonDefinition
leaky114's avatar
leaky114 已提交
209 210 211 212 213





leaky114's avatar
leaky114 已提交
214 215
        '================================================================================

leaky114's avatar
leaky114 已提交
216 217


leaky114's avatar
leaky114 已提交
218 219 220 221 222 223 224 225 226 227 228 229
#End Region

        ' Inventor application object.
        'Private   ThisApplication As Inventor.Application

#Region "ApplicationAddInServer Members"

        Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

            ' This method is called by Inventor when it loads the AddIn.
            ' The AddInSiteObject provides access to the Inventor Application object.
            ' The FirstTime flag indicates if the AddIn is loaded for the first time.
leaky114's avatar
leaky114 已提交
230
            On Error Resume Next
leaky114's avatar
leaky114 已提交
231

leaky114's avatar
leaky114 已提交
232 233
            ' Initialize AddIn members.
            ThisApplication = addInSiteObject.Application
leaky114's avatar
leaky114 已提交
234

leaky114's avatar
leaky114 已提交
235 236 237 238 239
            '打开文件时事件
            ThisApplicationEvents = ThisApplication.ApplicationEvents
            'AddHandler ThisApplicationEvents.OnOpenDocument, AddressOf ThisApplicationEvents_OnOpenDocument
            AddHandler ThisApplicationEvents.OnActivateDocument, AddressOf ThisApplicationEvents_OnActivateDocument
            'AddHandler ThisApplicationEvents.OnSaveDocument, AddressOf ThisApplicationEvents_OnOnSaveDocument
leaky114's avatar
leaky114 已提交
240

leaky114's avatar
leaky114 已提交
241 242
            ' TODO:  Add ApplicationAddInServer.Activate implementation.
            ' e.g. event initialization, command creation etc.
leaky114's avatar
leaky114 已提交
243

leaky114's avatar
leaky114 已提交
244 245
            ContentCenterFiles = ThisApplication.FileOptions.ContentCenterPath  '初始化零件库
            'MsgBox(ContentCenterFiles)
leaky114's avatar
leaky114 已提交
246

leaky114's avatar
leaky114 已提交
247 248 249 250 251
            '初始化图号文件名映射
            Map_StochNum = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapStochNum", "库存编号")
            If Map_StochNum Is Nothing Then
                Map_StochNum = "库存编号"
            End If
leaky114's avatar
leaky114 已提交
252

leaky114's avatar
leaky114 已提交
253 254 255 256
            Map_PartName = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapPartName", "零件代号")
            If Map_PartName Is Nothing Then
                Map_PartName = "零件代号"
            End If
leaky114's avatar
leaky114 已提交
257

leaky114's avatar
leaky114 已提交
258 259 260 261
            Map_PartNum = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapPartNum", "成本中心")
            If Map_PartNum Is Nothing Then
                Map_PartNum = "成本中心"
            End If
leaky114's avatar
leaky114 已提交
262

leaky114's avatar
leaky114 已提交
263 264 265 266 267
            '初始化对称件图号文件名映射
            Map_Mir_StochNum = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapMirStochNum", "对称件图号")
            If Map_Mir_StochNum Is Nothing Then
                Map_Mir_StochNum = "对称件图号"
            End If
leaky114's avatar
leaky114 已提交
268

leaky114's avatar
leaky114 已提交
269 270 271 272
            Map_Mir_PartName = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapMirPartName", "对称件名称")
            If Map_Mir_PartName Is Nothing Then
                Map_Mir_PartName = "对称件名称"
            End If
leaky114's avatar
leaky114 已提交
273

leaky114's avatar
leaky114 已提交
274 275 276 277 278
            '初始化比例映射
            Map_DrawingScale = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapDrawingScale", "比例")
            If Map_DrawingScale Is Nothing Then
                Map_DrawingScale = "比例"
            End If
leaky114's avatar
leaky114 已提交
279

leaky114's avatar
leaky114 已提交
280
            IsSetDrawingScale = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "IsSetDrawingScale", "-1")
leaky114's avatar
leaky114 已提交
281

leaky114's avatar
leaky114 已提交
282 283 284 285 286
            '初始化质量映射
            Map_Mass = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapMass", "质量")
            If Map_Mass Is Nothing Then
                Map_Mass = "质量"
            End If
leaky114's avatar
leaky114 已提交
287

leaky114's avatar
leaky114 已提交
288 289 290 291
            IsSetMass = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "IsSetMass", "-1")
            If IsSetMass Is Nothing Then
                IsSetMass = -1
            End If
leaky114's avatar
leaky114 已提交
292

leaky114's avatar
leaky114 已提交
293 294 295 296 297
            '初始化打印时间映射
            Map_PrintDay = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "MapPrintDay", "打印日期")
            If Map_PrintDay Is Nothing Then
                Map_PrintDay = "打印日期"
            End If
leaky114's avatar
leaky114 已提交
298

leaky114's avatar
leaky114 已提交
299 300 301 302
            IsOpenPrint = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "IsOpenPrint", "-1")
            If IsOpenPrint Is Nothing Then
                IsOpenPrint = -1
            End If
leaky114's avatar
leaky114 已提交
303

leaky114's avatar
leaky114 已提交
304 305 306 307
            IsDayAndName = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "IsDayAndName", "-1")
            If IsDayAndName Is Nothing Then
                IsDayAndName = -1
            End If
leaky114's avatar
leaky114 已提交
308

leaky114's avatar
leaky114 已提交
309 310
            '工程师
            EngineerName = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "EngineerName", "")
leaky114's avatar
leaky114 已提交
311

leaky114's avatar
leaky114 已提交
312 313 314 315 316
            'BOM导出表头
            BOMTiTle = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "BOMTiTle", "库存编号|空格|零件代号|材料|质量|所属装配代号|数量|总数量|描述")
            If BOMTiTle Is Nothing Then
                BOMTiTle = "库存编号|空格|零件代号|材料|质量|所属装配代号|数量|总数量|描述"
            End If
leaky114's avatar
leaky114 已提交
317

leaky114's avatar
leaky114 已提交
318 319 320 321 322
            '质量精度
            Mass_Accuracy = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "Mass_Accuracy", "2")
            If Mass_Accuracy Is Nothing Then
                Mass_Accuracy = "2"
            End If
leaky114's avatar
leaky114 已提交
323

leaky114's avatar
leaky114 已提交
324 325 326 327 328
            '面积精度
            Area_Accuracy = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "Area_Accuracy", "4")
            If Area_Accuracy Is Nothing Then
                Area_Accuracy = "4"
            End If
leaky114's avatar
leaky114 已提交
329

leaky114's avatar
leaky114 已提交
330 331
            'excel文件名
            Excel_File_Name = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "Excel_File_Name", "")
leaky114's avatar
leaky114 已提交
332

leaky114's avatar
leaky114 已提交
333
            If Excel_File_Name = "" Then
leaky114's avatar
leaky114 已提交
334
                Excel_File_Name = My.Application.Info.DirectoryPath & "\最新物料编码.xlsx"
leaky114's avatar
leaky114 已提交
335 336
                'MsgBox(Excel_File_Name)
            End If
leaky114's avatar
leaky114 已提交
337

leaky114's avatar
leaky114 已提交
338 339 340
            'excel文件不存在,到服务器下载
            If IsFileExsts(Excel_File_Name) = False Then
                Dim documentURL As String
leaky114's avatar
leaky114 已提交
341
                documentURL = "\\Likai-pc\发行版\2011\最新物料编码.xlsx"
leaky114's avatar
leaky114 已提交
342

leaky114's avatar
leaky114 已提交
343
                If IsFileExsts(documentURL) = True Then
leaky114's avatar
leaky114 已提交
344

leaky114's avatar
leaky114 已提交
345 346
                    Dim wc As New System.Net.WebClient
                    wc.DownloadFile(documentURL, Excel_File_Name)
leaky114's avatar
leaky114 已提交
347
                End If
leaky114's avatar
leaky114 已提交
348
            End If
leaky114's avatar
leaky114 已提交
349

leaky114's avatar
leaky114 已提交
350 351 352 353 354
            '搜索的表
            Sheet_Name = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "Sheet_Name", "物料")
            If Sheet_Name Is Nothing Then
                Sheet_Name = "物料"
            End If
leaky114's avatar
leaky114 已提交
355

leaky114's avatar
leaky114 已提交
356 357 358 359 360
            '搜索的范围
            Table_Arrays = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "Table_Array", "A,B,C,D,E")
            If Table_Arrays Is Nothing Then
                Table_Arrays = "A,B,C,D,E"
            End If
leaky114's avatar
leaky114 已提交
361

leaky114's avatar
leaky114 已提交
362 363 364 365 366
            '搜索列
            Col_Index_Num = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "Col_Index_Num", "B")
            If Col_Index_Num Is Nothing Then
                Col_Index_Num = "B"
            End If
leaky114's avatar
leaky114 已提交
367

leaky114's avatar
leaky114 已提交
368 369 370 371 372
            '检查更新
            CheckUpdate = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "CheckUpdate", "1")
            If CheckUpdate Is Nothing Then
                CheckUpdate = "1"
            End If
leaky114's avatar
leaky114 已提交
373

leaky114's avatar
leaky114 已提交
374 375
            '创建按钮
            CreatUI(firstTime)
leaky114's avatar
leaky114 已提交
376

leaky114's avatar
leaky114 已提交
377 378
            '检查更新
            If CheckUpdate = "1" Then
leaky114's avatar
22.2.25  
leaky114 已提交
379 380
                'NewUpdater.UpDater2(False)

381 382 383 384
                'IsShowUpdateMsg = False
                'Dim frmupdate As New frmUpdate
                'frmupdate.Visible = False
                'frmupdate.ShowDialog()
leaky114's avatar
leaky114 已提交
385
                If NewUpdater.CreateUpdate() = True Then
386 387 388
                    NewUpdater.Update3()
                End If

leaky114's avatar
leaky114 已提交
389
            End If
leaky114's avatar
leaky114 已提交
390

leaky114's avatar
leaky114 已提交
391 392
            'Catch ex As Exception
            '    MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)
leaky114's avatar
leaky114 已提交
393

leaky114's avatar
leaky114 已提交
394
            'End Try
leaky114's avatar
leaky114 已提交
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410

        End Sub

        Public Sub CreatUI(ByVal bfirstTime As Boolean)

            Dim oCommandManager As CommandManager
            Dim oUserInterfaceManager As UserInterfaceManager
            'Dim oIPictureDisp32 As Object  '大图标
            'Dim oIPictureDisp8 As Object   '小图标

            Dim smallPicture As stdole.IPictureDisp
            Dim largePicture As stdole.IPictureDisp

            Try
                oCommandManager = ThisApplication.CommandManager
                oUserInterfaceManager = ThisApplication.UserInterfaceManager
leaky114's avatar
leaky114 已提交
411

leaky114's avatar
leaky114 已提交
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
                'clientId = Me.GetType().GUID.ToString("B")
                ClientID = AddInGuid(GetType(StandardAddInServer))
                '---------------------------------------------------------------------------------------
                'create button's definition here
                'm_修改文件iProperty_Buttondef = New 修改文件iProperty_Button("修改文件iProperty", "InName修改文件iProperty", _
                '                       CommandTypesEnum.kShapeEditCmdType, clientId, , , , , )
                '1
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.修改文件iProperty161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.修改文件iProperty323224.ToBitmap)

                m_修改文件iProperty_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("修改文件iProperty", "InName修改文件iProperty", _
                                      CommandTypesEnum.kShapeEditCmdType, ClientID, , "以第一个汉字为标识,提取文件名中的图号和名称,根据【iProperty映射】的设置,写入【iProperty】【项目】中的字段。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '2
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.修改部件iProperty161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.修改部件iProperty323224.ToBitmap)
                m_修改部件iProperty_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("修改部件iProperty", "InName修改部件iProperty", _
                                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "根据【BOM表】【结构化】的数据,设置下一级或所有级文件的iProperty。注意:将忽略零件库和参考文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '3
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.更改文件名161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.更改文件名323224.ToBitmap)
                m_更改文件名_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("更改文件名", "InName更改文件名", _
                                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在部件文件中选择一个文件,修改其文件名,将替换选中的文件或全部文件。若在与文件同一文件夹中存在其同名工程图,将生成新的工程图。注意:将忽略零件库。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '4
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.提取iPro修改文件名161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.提取iPro修改文件名323224.ToBitmap)
                m_提取iPro修改文件名_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("提取iPro修改文件名", "InName提取iPro修改文件名", _
                       CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在部件文件中选择一个文件,根据【iProperty映射】设置,提取【iProperty】【项目】中的字段,修改选取文件的文件名。与【修改部件iProperty】反向。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '5
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.生成图号161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.生成图号323224.ToBitmap)
                m_生成图号_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("生成图号", "InName生成图号", _
                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "根据第一级部件的图号,设置子级部件或零件的图号变化规则,重命名其文件名。对于新设计先命名后图号特别有用。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '6
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.更改镜像文件名161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.更改镜像文件名323224.ToBitmap)
                m_更改镜像文件名_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("更改镜像文件名", "InName更改镜像文件名", _
                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在部件中选择一个是镜像生成的文件,修改其文件名,将原基础文件改为临时文件,重新手动指定其基础文件,后还原基础文件。对于基础文件和镜像文件都需修改的文件很有用。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '7
                'oIPictureDisp32 = GetIcon("InventorAddIn.打开文件夹323224.ico")
                ''oIPictureDisp8 = GetIcon("InventorAddIn.打开文件夹8824.ico")
                'm_打开文件夹_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("打开文件夹", "InName打开文件夹", _
                '               CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开当前文件所在的文件夹。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.打开文件夹161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.打开文件夹323224.ToBitmap)
leaky114's avatar
21.12.3  
leaky114 已提交
463
                ' Create the button definition.
leaky114's avatar
leaky114 已提交
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
                m_打开文件夹_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("打开文件夹", "InName打开文件夹", _
                               CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开当前文件所在的文件夹。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '8
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.保存关闭161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.保存关闭323224.ToBitmap)
                m_保存关闭_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("保存关闭", "InName保存关闭", _
                       CommandTypesEnum.kShapeEditCmdType, ClientID, "", "保存并关闭当前打开的文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '9
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.另存为Pdf161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.另存为Pdf323224.ToBitmap)
                m_另存为Pdf_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("另存为Pdf", "InName另存为Pdf", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "将当前文件另存为Pdf格式。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '10
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.另存为Dwg161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.另存为Dwg323224.ToBitmap)
                m_另存为Dwg_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("另存为Dwg", "InName另存为Dwg", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "将当前文件另存为Dwg格式。可能 因为设置的不同而是 Zip 格式的,也将其打开。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '11
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置BOM结构161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置BOM结构323224.ToBitmap)
                m_设置BOM结构_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置BOM结构", "InName设置BOM结构", _
                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在部件中使用,输入序号,将部件的所有子级设置为对应的BOM结构。对与液压管等特别有用。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '12
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置比例161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置比例323224.ToBitmap)
                m_设置比例_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置比例", "InName设置比例", _
                       CommandTypesEnum.kShapeEditCmdType, ClientID, "", "获取工程图主视图的比例,根据【比例映射】的设置,写入【iProperty】【自定义】字段。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '13
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.对称件iProperty161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.对称件iProperty323224.ToBitmap)
                m_设置对称件iProperty_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("对称件iProperty", "InName对称件iProperty", _
                                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "选择一个文件,根据【对称件iProperty映射】的设置,将其iProperty写入【iProperty】【自定义】字段。对于对称件的工程图很有用。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '14
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.检查序号完整性161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.检查序号完整性323224.ToBitmap)
                m_检查序号完整性_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("检查序号完整性", "InName检查序号完整性", _
                               CommandTypesEnum.kShapeEditCmdType, ClientID, "", "检查工程图的序号是否标注完整。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '15
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.新建序号161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.新建序号323224.ToBitmap)
                m_新建序号_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("新建序号", "InName新建序号", _
                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "重新对工程图的序号进行变化,使寻找序号更简便。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '16
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置日期161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置日期323224.ToBitmap)
                m_设置日期_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置日期", "InName设置日期", _
                                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "根据【签字】【打印日期】的设置,将当前日期写入【iProperty】【自定义】字段。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '17
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.清除日期161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.清除日期323224.ToBitmap)
                m_清除日期_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("清除日期", "InName清除日期", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '18
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.自定义日期161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.自定义日期323224.ToBitmap)
                m_自定义日期_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("自定义日期", "InName自定义日期", _
               CommandTypesEnum.kShapeEditCmdType, ClientID, "", "", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '19
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置签字161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置签字323224.ToBitmap)
                m_设置签字_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置签字", "InName设置签字", _
                         CommandTypesEnum.kShapeEditCmdType, ClientID, "", "根据【签字】【工程师】的设置,将当前日期写入【iProperty】【自定义】字段。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '20
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.清除签字161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.清除签字323224.ToBitmap)
                m_清除签字_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("清除签字", "InName清除签字", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '21
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.自定义签字161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.自定义签字323224.ToBitmap)
                m_自定义签字_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("自定义签字", "InName自定义签字", _
                      CommandTypesEnum.kShapeEditCmdType, ClientID, "", "", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '22
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置323224.ToBitmap)
                m_设置_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置", "InName设置", _
                         CommandTypesEnum.kShapeEditCmdType, ClientID, "打开【设置】窗口,对配置进行设置。", "", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '23
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.量产iPropertys161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.量产iPropertys323224.ToBitmap)
                m_量产iPropertys_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("量产iProperty", "InName量产iProperty", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开【量产iProperty】窗口,对多个文件设置【iProperty】。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '24
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.批量另存为161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.批量另存为323224.ToBitmap)
                m_工程图批量另存为_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("工程图批量另存为", "InName工程图批量另存为", _
                     CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开【批量另存为】窗口,将添加的工程图另存为Paf或Dwg文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '25
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.关于161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.关于323224.ToBitmap)
                m_关于_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("关于", "InName关于", _
                     CommandTypesEnum.kShapeEditCmdType, ClientID, "", "", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '26
leaky114's avatar
leaky114 已提交
576 577
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.保存全部161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.保存全部323224.ToBitmap)
leaky114's avatar
leaky114 已提交
578 579 580 581
                m_保存关闭所有部件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("保存关闭所有部件", "InName保存关闭所有部件", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "保存并关闭打开的所有部件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '27
leaky114's avatar
leaky114 已提交
582 583 584 585
                'smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.保存关闭零件161624.ToBitmap)
                'largePicture = PictureConverter.ImageToPictureDisp(My.Resources.保存关闭零件323224.ToBitmap)
                'm_保存关闭所有零件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("保存关闭所有零件", "InName保存关闭所有零件", _
                '    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "保存并关闭打开的所有零件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)
leaky114's avatar
leaky114 已提交
586

leaky114's avatar
leaky114 已提交
587 588 589 590 591
                ''28
                'smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.保存关闭工程图161624.ToBitmap)
                'largePicture = PictureConverter.ImageToPictureDisp(My.Resources.保存关闭工程图323224.ToBitmap)
                'm_保存关闭所有工程图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("保存关闭所有工程图", "InName保存关闭所有工程图", _
                '    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "保存并关闭打开的所有工程图。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)
leaky114's avatar
leaky114 已提交
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692

                '29
                'oIPictureDisp32 = GetIcon("InventorAddIn.绘制槽孔323224.ico")
                'm_绘制槽孔_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("绘制槽孔", "InName绘制槽孔", _
                '                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在二维草图中绘制槽孔,鼠标选择一个点,为第一个圆中心,输入槽孔的高度(圆直径)和宽度(两圆中心距),单位毫米(mm)。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '30
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置描述161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置描述323224.ToBitmap)
                m_设置描述_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置描述", "InName设置描述", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "输入文字,设置到 【Iproperty】【项目】【描述的值】", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '31
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.刷新引用161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.刷新引用323224.ToBitmap)
                m_刷新引用_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("刷新引用", "InName刷新引用", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "刷新浏览器中的引用名称。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '32
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.清理旧版文件161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.清理旧版文件323224.ToBitmap)
                m_清理旧版文件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("清理旧版文件", "InName清理旧版文件", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "扫描指定路径下的旧版文件,删除之。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '33
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.添加直径161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.添加直径323224.ToBitmap)
                m_添加直径_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("添加直径", "InName添加直径", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在工程图选择一个尺寸,在尺寸前添加 Φ。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '34
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.全部另存为161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.全部另存为323224.ToBitmap)
                m_全部另存为_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("全部另存为", "InName全部另存为", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "保存打开的全部工程图为 Pdf 或 Dwg 格式。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '35
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.检查是否有工程图161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.检查是否有工程图323224.ToBitmap)
                m_检查是否有工程图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("检查是否有工程图", "InName检查是否有工程图", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "检查部件中指定图号的文件是否有对应的工程图。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '36
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.打开全部工程图161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.打开全部工程图323224.ToBitmap)
                m_打开全部工程图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("打开全部工程图", "InName打开全部工程图", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开部件中所有子级对应的工程图。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '37
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.部件替换文件名161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.部件替换文件名323224.ToBitmap)
                m_部件替换文件名_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("批量替换文件名", "InName部件替换文件名", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "批量替换部件中子集文件的文件名。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '38
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.导出平面BOM161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.导出平面BOM323224.ToBitmap)
                m_导出平面BOM_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("导出平面BOM", "InName导出平面BOM", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "根据BOM导出项目,导出平面性的BOM为Excel文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '39
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.还原旧图161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.还原旧图323224.ToBitmap)
                m_还原旧图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("还原旧图", "InName还原旧图", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "还原更改文件名后的 .old 文件为原始文件名。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '40
                'oIPictureDisp32 = GetIcon("InventorAddIn.帮助323224.ico")
                'm_帮助_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("帮助", "InName帮助", _
                '                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开帮助文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.帮助161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.帮助323224.ToBitmap)
                m_帮助_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("帮助", "InName帮助", _
                                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开帮助文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '36
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.打开全部工程图161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.打开全部工程图161624.ToBitmap)
                m_打开指定工程图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("打开指定工程图", "InName打开指定工程图", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开部件中所有包含指定图号子级的对应的工程图。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '41
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.移动指定文件161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.移动指定文件323224.ToBitmap)
                m_移动指定文件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("移动指定文件", "InName移动指定文件", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "移到组件中指定前缀的零件和组件到当前组件所在文件夹。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '42
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.对齐原始坐标面161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.对齐原始坐标面323224.ToBitmap)
                m_对齐原始坐标面_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("对齐原始坐标面", "InName对齐原始坐标面", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "选择部件中的两个部件或零件,使其原始坐标面对齐。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '43
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.查找缺失文件的部件161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.查找缺失文件的部件323224.ToBitmap)
                m_查找缺失文件的部件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("查找缺失文件的部件", "InName查找缺失文件的部件", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "查找当前部件中缺失的文件,并打开缺失文件的父级部件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '44
leaky114's avatar
22.2.25  
leaky114 已提交
693 694
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.统计161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.统计323224.ToBitmap)
leaky114's avatar
leaky114 已提交
695 696 697 698
                m_统计质量面积_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("统计质量面积", "InName统计质量面积", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "选择部件中的部件或零件,统计总质量和面积。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '45
leaky114's avatar
leaky114 已提交
699 700
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.调整IPro顺序161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.调整IPro顺序323224.ToBitmap)
leaky114's avatar
leaky114 已提交
701 702 703 704
                m_调整IPro顺序_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("调整IPro顺序", "InName调整IPro顺序", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "交换IProperty中零件代号、库存编号、描述三者的数据。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '44
leaky114's avatar
leaky114 已提交
705 706
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.插入序号161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.插入序号323224.ToBitmap)
leaky114's avatar
leaky114 已提交
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
                m_插入序号_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("插入序号", "InName插入序号", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "插入一个序号。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '47
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.尺寸圆整161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.尺寸圆整323224.ToBitmap)
                m_尺寸圆整_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("尺寸圆整", "InName尺寸圆整", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "尺寸圆整,四舍五入尺寸小数位到个位。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '48
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置材料编码161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置材料编码323224.ToBitmap)
                m_导入存货编码_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("导入存货编码", "InName导入存货编码", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "导入存货编码。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '49
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.设置材料编码161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.设置材料编码323224.ToBitmap)
leaky114's avatar
leaky114 已提交
725 726
                m_ERP材料编码_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("设置材料编码", "InName设置材料编码", _
                   CommandTypesEnum.kShapeEditCmdType, ClientID, "", "设置ERP编码。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)
leaky114's avatar
leaky114 已提交
727 728 729 730 731 732 733 734 735 736 737 738 739

                '50
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.工程图161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.工程图323224.ToBitmap)
                m_打开工程图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("打开工程图", "InName打开工程图", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开当前文件或部件中选择的文件对应的工程图。 ", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

                '51
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.打印161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.打印323224.ToBitmap)
                m_批量打印_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("批量打印工程图", "InName批量打印", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "批量打印工程图。 ", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

leaky114's avatar
leaky114 已提交
740 741 742 743 744 745
                '52
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.重写BOM161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.重写BOM323224.ToBitmap)
                m_重写BOM序号_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("重写BOM序号", "InName重写BOM序号", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "重写BOM序号并按序号升序排序。 ", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

leaky114's avatar
leaky114 已提交
746
                '53
leaky114's avatar
leaky114 已提交
747 748
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.查询材料编码161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.查询材料编码323224.ToBitmap)
leaky114's avatar
leaky114 已提交
749 750 751
                m_查询ERP编码_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("查询ERP编码", "InName查询ERP编码", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在Excel数据表中查询ERP编码。 ", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

leaky114's avatar
leaky114 已提交
752 753 754 755 756 757
                '54
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.打开ERP数据文件161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.打开ERP数据文件323224.ToBitmap)
                m_打开ERP数据文件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("打开ERP数据文件", "InName打开ERP数据文件", _
                  CommandTypesEnum.kShapeEditCmdType, ClientID, "", "打开ERP数据文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)

leaky114's avatar
leaky114 已提交
758 759 760 761 762
                '55
                smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.快速打开161624.ToBitmap)
                largePicture = PictureConverter.ImageToPictureDisp(My.Resources.快速打开323224.ToBitmap)
                m_快速打开_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("快速打开", "InName快速打开", _
                    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "在当前项目中快速打开指定文件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)
leaky114's avatar
leaky114 已提交
763

leaky114's avatar
leaky114 已提交
764 765 766 767 768
                ''56
                'smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.关闭零件161624.ToBitmap)
                'largePicture = PictureConverter.ImageToPictureDisp(My.Resources.关闭零件323224.ToBitmap)
                'm_关闭所有零件_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("关闭所有零件", "InName关闭所有零件", _
                '    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "关闭打开的所有零件。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)
leaky114's avatar
leaky114 已提交
769

leaky114's avatar
leaky114 已提交
770 771 772 773 774
                ''57
                'smallPicture = PictureConverter.ImageToPictureDisp(My.Resources.关闭工程图161624.ToBitmap)
                'largePicture = PictureConverter.ImageToPictureDisp(My.Resources.关闭工程图323224.ToBitmap)
                'm_关闭所有工程图_Buttondef = oCommandManager.ControlDefinitions.AddButtonDefinition("关闭所有工程图", "InName关闭所有工程图", _
                '    CommandTypesEnum.kShapeEditCmdType, ClientID, "", "关闭打开的所有工程图。", smallPicture, largePicture, ButtonDisplayEnum.kDisplayTextInLearningMode)
leaky114's avatar
leaky114 已提交
775 776 777



leaky114's avatar
leaky114 已提交
778
                '  Dim oUserInterfaceManager As Inventor.UserInterfaceManager = ThisApplication.UserInterfaceManager
leaky114's avatar
leaky114 已提交
779 780 781 782 783 784 785 786 787 788 789

                If bfirstTime Then

                    '==========================================
                    'oButtonDefinitions.Clear()
                    'oButtonDefinitions.Add()
                    'oButtonDefinitions.Add()
                    'oButtonDefinitions.Add()
                    'panel.CommandControls.AddPopup(, oButtonDefinitions, False)
                    '==========================================

leaky114's avatar
leaky114 已提交
790
                    If oUserInterfaceManager.InterfaceStyle = InterfaceStyleEnum.kRibbonInterface Then
leaky114's avatar
leaky114 已提交
791 792
                        Dim oRibbon As Inventor.Ribbon
                        Dim oRibbonTab As Inventor.RibbonTab
leaky114's avatar
leaky114 已提交
793
                        Dim oRibbonPanel As Inventor.RibbonPanel
leaky114's avatar
leaky114 已提交
794 795 796 797 798 799

                        Dim oButtonDefinitions As Inventor.ObjectCollection
                        oButtonDefinitions = ThisApplication.TransientObjects.CreateObjectCollection
                        '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                        '启动环境
leaky114's avatar
leaky114 已提交
800
                        oRibbon = oUserInterfaceManager.Ribbons.Item("ZeroDoc")
leaky114's avatar
leaky114 已提交
801
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_GetStarted")
leaky114's avatar
leaky114 已提交
802
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaAssemblyPanel", ClientID)
leaky114's avatar
leaky114 已提交
803

leaky114's avatar
leaky114 已提交
804
                        oRibbonPanel.CommandControls.AddButton(m_快速打开_Buttondef, True)
leaky114's avatar
leaky114 已提交
805 806 807 808 809 810 811 812 813
                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_设置_Buttondef)
                        oButtonDefinitions.Add(m_工程图批量另存为_Buttondef)
                        oButtonDefinitions.Add(m_批量打印_Buttondef)
                        oButtonDefinitions.Add(m_还原旧图_Buttondef)
                        oButtonDefinitions.Add(m_清理旧版文件_Buttondef)
                        oButtonDefinitions.Add(m_帮助_Buttondef)
                        oButtonDefinitions.Add(m_关于_Buttondef)
leaky114's avatar
leaky114 已提交
814
                        oRibbonPanel.CommandControls.AddPopup(m_设置_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
815 816 817 818 819
                        '==========================================

                        '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                        '部件环境
leaky114's avatar
leaky114 已提交
820
                        oRibbon = oUserInterfaceManager.Ribbons.Item("Assembly")
leaky114's avatar
leaky114 已提交
821 822 823 824 825 826 827 828

                        '工具选项卡
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabTools")
                        '装配选项卡
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabAssemble")

                        ' Create a new panel on the Assemble tab.

leaky114's avatar
leaky114 已提交
829
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaAssemblyPanel", ClientID)
leaky114's avatar
leaky114 已提交
830
                        ' Add the buttons to the tab, with the first and last ones being large and the other two small.
leaky114's avatar
leaky114 已提交
831
                        oRibbonPanel.CommandControls.AddButton(m_快速打开_Buttondef, True)
leaky114's avatar
leaky114 已提交
832 833
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭_Buttondef, True)
                        oRibbonPanel.CommandControls.AddButton(m_打开工程图_Buttondef, True)
leaky114's avatar
leaky114 已提交
834 835 836 837 838 839

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_修改文件iProperty_Buttondef)
                        oButtonDefinitions.Add(m_修改部件iProperty_Buttondef)
                        oButtonDefinitions.Add(m_设置描述_Buttondef)
leaky114's avatar
leaky114 已提交
840
                       
leaky114's avatar
leaky114 已提交
841
                        oButtonDefinitions.Add(m_调整IPro顺序_Buttondef)
leaky114's avatar
leaky114 已提交
842
                        oRibbonPanel.CommandControls.AddPopup(m_修改文件iProperty_Buttondef, oButtonDefinitions, True)
leaky114's avatar
leaky114 已提交
843 844 845 846 847 848 849 850 851

                        '==========================================

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_更改文件名_Buttondef)
                        oButtonDefinitions.Add(m_更改镜像文件名_Buttondef)
                        oButtonDefinitions.Add(m_提取iPro修改文件名_Buttondef)
                        oButtonDefinitions.Add(m_部件替换文件名_Buttondef)
leaky114's avatar
leaky114 已提交
852
                        oRibbonPanel.CommandControls.AddPopup(m_更改文件名_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
853 854 855
                        '==========================================

                        '==========================================
leaky114's avatar
leaky114 已提交
856 857 858 859 860 861 862 863 864
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭所有部件_Buttondef, False)
                        'oButtonDefinitions.Clear()
                        'oButtonDefinitions.Add(m_保存关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有工程图_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有工程图_Buttondef)
                        'oRibbonPanel.CommandControls.AddPopup(m_保存关闭所有部件_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
865 866 867 868 869 870 871
                        '==========================================

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_检查是否有工程图_Buttondef)
                        'oButtonDefinitions.Add(m_打开全部工程图_Buttondef)
                        oButtonDefinitions.Add(m_打开指定工程图_Buttondef)
leaky114's avatar
leaky114 已提交
872
                        oRibbonPanel.CommandControls.AddPopup(m_检查是否有工程图_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
873 874
                        '==========================================

leaky114's avatar
leaky114 已提交
875 876 877 878 879 880 881 882
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_ERP材料编码_Buttondef)
                        oButtonDefinitions.Add(m_查询ERP编码_Buttondef)
                        oButtonDefinitions.Add(m_打开ERP数据文件_Buttondef)
                        oButtonDefinitions.Add(m_导入存货编码_Buttondef)
                        oRibbonPanel.CommandControls.AddPopup(m_ERP材料编码_Buttondef, oButtonDefinitions, False)


leaky114's avatar
leaky114 已提交
883 884 885 886 887 888 889 890 891 892 893 894 895 896
                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_打开文件夹_Buttondef)
                        'oButtonDefinitions.Add(m_查找部件_Buttondef)
                        oButtonDefinitions.Add(m_对齐原始坐标面_Buttondef)

                        oButtonDefinitions.Add(m_另存为Pdf_Buttondef)
                        oButtonDefinitions.Add(m_生成图号_Buttondef)
                        oButtonDefinitions.Add(m_设置BOM结构_Buttondef)
                        oButtonDefinitions.Add(m_导出平面BOM_Buttondef)
                        oButtonDefinitions.Add(m_刷新引用_Buttondef)
                        oButtonDefinitions.Add(m_移动指定文件_Buttondef)
                        oButtonDefinitions.Add(m_查找缺失文件的部件_Buttondef)
                        oButtonDefinitions.Add(m_统计质量面积_Buttondef)
leaky114's avatar
leaky114 已提交
897

leaky114's avatar
leaky114 已提交
898
                        oRibbonPanel.CommandControls.AddPopup(m_打开文件夹_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
899 900 901 902 903 904 905 906 907 908 909 910 911

                        '==========================================

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_设置_Buttondef)
                        oButtonDefinitions.Add(m_量产iPropertys_Buttondef)
                        oButtonDefinitions.Add(m_工程图批量另存为_Buttondef)
                        oButtonDefinitions.Add(m_批量打印_Buttondef)
                        oButtonDefinitions.Add(m_还原旧图_Buttondef)
                        oButtonDefinitions.Add(m_清理旧版文件_Buttondef)
                        oButtonDefinitions.Add(m_帮助_Buttondef)
                        oButtonDefinitions.Add(m_关于_Buttondef)
leaky114's avatar
leaky114 已提交
912
                        oRibbonPanel.CommandControls.AddPopup(m_设置_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
913 914 915 916 917
                        '==========================================

                        '+++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                        '零件环境
leaky114's avatar
leaky114 已提交
918
                        oRibbon = oUserInterfaceManager.Ribbons.Item("Part")
leaky114's avatar
leaky114 已提交
919 920 921 922 923 924 925

                        '工具选项卡
                        'oRibbonTab = oRibbon.RibbonTabs.Item("id_TabTools")

                        '模型选项卡
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabModel")

leaky114's avatar
leaky114 已提交
926
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaPartPanel", ClientID)
leaky114's avatar
leaky114 已提交
927

leaky114's avatar
leaky114 已提交
928
                        oRibbonPanel.CommandControls.AddButton(m_快速打开_Buttondef, True)
leaky114's avatar
leaky114 已提交
929 930
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭_Buttondef, True)
                        oRibbonPanel.CommandControls.AddButton(m_打开工程图_Buttondef, True)
leaky114's avatar
leaky114 已提交
931 932 933 934 935

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_修改文件iProperty_Buttondef)
                        oButtonDefinitions.Add(m_设置描述_Buttondef)
leaky114's avatar
leaky114 已提交
936 937 938
                        'oButtonDefinitions.Add(m_设置材料编码_Buttondef)
                        'oButtonDefinitions.Add(m_查询ERP编码_Buttondef)
                        'oButtonDefinitions.Add(m_打开ERP数据文件_Buttondef)
leaky114's avatar
leaky114 已提交
939
                        oButtonDefinitions.Add(m_调整IPro顺序_Buttondef)
leaky114's avatar
leaky114 已提交
940

leaky114's avatar
leaky114 已提交
941
                        oRibbonPanel.CommandControls.AddPopup(m_修改文件iProperty_Buttondef, oButtonDefinitions, True)
leaky114's avatar
leaky114 已提交
942 943 944
                        '==========================================

                        '==========================================
leaky114's avatar
leaky114 已提交
945 946 947 948 949 950 951 952 953
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭所有部件_Buttondef, False)
                        'oButtonDefinitions.Clear()
                        'oButtonDefinitions.Add(m_保存关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有工程图_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有工程图_Buttondef)
                        'oRibbonPanel.CommandControls.AddPopup(m_保存关闭所有部件_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
954 955
                        '==========================================

leaky114's avatar
leaky114 已提交
956 957 958 959 960 961 962 963
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_ERP材料编码_Buttondef)
                        oButtonDefinitions.Add(m_查询ERP编码_Buttondef)
                        oButtonDefinitions.Add(m_打开ERP数据文件_Buttondef)
                        oButtonDefinitions.Add(m_导入存货编码_Buttondef)
                        oRibbonPanel.CommandControls.AddPopup(m_ERP材料编码_Buttondef, oButtonDefinitions, False)


leaky114's avatar
leaky114 已提交
964 965 966 967
                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_打开文件夹_Buttondef)
                        oButtonDefinitions.Add(m_另存为Pdf_Buttondef)
leaky114's avatar
leaky114 已提交
968
                        oRibbonPanel.CommandControls.AddPopup(m_打开文件夹_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
969 970 971 972 973 974 975 976 977 978 979 980
                        '==========================================

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_设置_Buttondef)
                        oButtonDefinitions.Add(m_量产iPropertys_Buttondef)
                        oButtonDefinitions.Add(m_工程图批量另存为_Buttondef)
                        oButtonDefinitions.Add(m_批量打印_Buttondef)
                        oButtonDefinitions.Add(m_还原旧图_Buttondef)
                        oButtonDefinitions.Add(m_清理旧版文件_Buttondef)
                        oButtonDefinitions.Add(m_帮助_Buttondef)
                        oButtonDefinitions.Add(m_关于_Buttondef)
leaky114's avatar
leaky114 已提交
981
                        oRibbonPanel.CommandControls.AddPopup(m_设置_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
982 983 984 985 986
                        '==========================================

                        '钣金选项卡
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabSheetMetal")

leaky114's avatar
leaky114 已提交
987
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaPartPanel", ClientID)
leaky114's avatar
leaky114 已提交
988

leaky114's avatar
leaky114 已提交
989 990
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭_Buttondef, True)
                        oRibbonPanel.CommandControls.AddButton(m_打开工程图_Buttondef, True)
leaky114's avatar
leaky114 已提交
991 992 993 994 995

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_修改文件iProperty_Buttondef)
                        oButtonDefinitions.Add(m_设置描述_Buttondef)
leaky114's avatar
leaky114 已提交
996 997 998
                        'oButtonDefinitions.Add(m_设置材料编码_Buttondef)
                        'oButtonDefinitions.Add(m_查询ERP编码_Buttondef)
                        'oButtonDefinitions.Add(m_打开ERP数据文件_Buttondef)
leaky114's avatar
leaky114 已提交
999
                        oButtonDefinitions.Add(m_调整IPro顺序_Buttondef)
leaky114's avatar
leaky114 已提交
1000
                        oRibbonPanel.CommandControls.AddPopup(m_修改文件iProperty_Buttondef, oButtonDefinitions, True)
leaky114's avatar
leaky114 已提交
1001 1002 1003 1004

                        '==========================================

                        '==========================================
leaky114's avatar
leaky114 已提交
1005 1006 1007 1008 1009 1010 1011 1012 1013
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭所有部件_Buttondef, False)
                        'oButtonDefinitions.Clear()
                        'oButtonDefinitions.Add(m_保存关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有工程图_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有工程图_Buttondef)
                        'oRibbonPanel.CommandControls.AddPopup(m_保存关闭所有部件_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1014 1015
                        '==========================================

leaky114's avatar
leaky114 已提交
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025

                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_ERP材料编码_Buttondef)
                        oButtonDefinitions.Add(m_查询ERP编码_Buttondef)
                        oButtonDefinitions.Add(m_打开ERP数据文件_Buttondef)
                        oButtonDefinitions.Add(m_导入存货编码_Buttondef)
                        oRibbonPanel.CommandControls.AddPopup(m_ERP材料编码_Buttondef, oButtonDefinitions, False)



leaky114's avatar
leaky114 已提交
1026 1027 1028 1029
                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_打开文件夹_Buttondef)
                        oButtonDefinitions.Add(m_另存为Pdf_Buttondef)
leaky114's avatar
leaky114 已提交
1030
                        oRibbonPanel.CommandControls.AddPopup(m_打开文件夹_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
                        '==========================================

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_设置_Buttondef)
                        oButtonDefinitions.Add(m_量产iPropertys_Buttondef)
                        oButtonDefinitions.Add(m_工程图批量另存为_Buttondef)
                        oButtonDefinitions.Add(m_批量打印_Buttondef)
                        oButtonDefinitions.Add(m_还原旧图_Buttondef)
                        oButtonDefinitions.Add(m_清理旧版文件_Buttondef)
                        oButtonDefinitions.Add(m_帮助_Buttondef)
                        oButtonDefinitions.Add(m_关于_Buttondef)
leaky114's avatar
leaky114 已提交
1043
                        oRibbonPanel.CommandControls.AddPopup(m_设置_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1044 1045 1046 1047
                        '==========================================

                        '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                        '工程图环境
leaky114's avatar
leaky114 已提交
1048
                        oRibbon = oUserInterfaceManager.Ribbons.Item("Drawing")
leaky114's avatar
leaky114 已提交
1049 1050
                        'oRibbonTab = oRibbon.RibbonTabs.Item("id_TabPlaceViews")

1051 1052 1053
                        '在放置视图选项卡中添加

                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabPlaceViews")
leaky114's avatar
leaky114 已提交
1054
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaDrawingPanel", ClientID)
1055

leaky114's avatar
leaky114 已提交
1056
                        oRibbonPanel.CommandControls.AddButton(m_快速打开_Buttondef, True)
leaky114's avatar
leaky114 已提交
1057 1058
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭_Buttondef, True)
                        oRibbonPanel.CommandControls.AddButton(m_打开文件夹_Buttondef, True)
1059 1060 1061 1062 1063 1064

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_另存为Dwg_Buttondef)
                        oButtonDefinitions.Add(m_另存为Pdf_Buttondef)
                        oButtonDefinitions.Add(m_全部另存为_Buttondef)
leaky114's avatar
leaky114 已提交
1065
                        oRibbonPanel.CommandControls.AddPopup(m_另存为Dwg_Buttondef, oButtonDefinitions, False)
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
                        '==========================================

                        '==========================================
                        '日期popup  '签字popup
                        oButtonDefinitions.Clear()

                        oButtonDefinitions.Add(m_设置签字_Buttondef)
                        oButtonDefinitions.Add(m_清除签字_Buttondef)
                        oButtonDefinitions.Add(m_自定义签字_Buttondef)

leaky114's avatar
leaky114 已提交
1076
                        oRibbonPanel.CommandControls.AddPopup(m_设置签字_Buttondef, oButtonDefinitions, False)
1077 1078 1079
                        '==========================================

                        '在工具选项卡中添加
leaky114's avatar
leaky114 已提交
1080
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabTools")
leaky114's avatar
leaky114 已提交
1081
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaDrawingPanel", ClientID)
leaky114's avatar
leaky114 已提交
1082

leaky114's avatar
leaky114 已提交
1083
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭_Buttondef, True)
leaky114's avatar
leaky114 已提交
1084 1085 1086 1087 1088

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_修改文件iProperty_Buttondef)
                        oButtonDefinitions.Add(m_设置描述_Buttondef)
leaky114's avatar
leaky114 已提交
1089
                        oRibbonPanel.CommandControls.AddPopup(m_修改文件iProperty_Buttondef, oButtonDefinitions, True)
leaky114's avatar
leaky114 已提交
1090 1091
                        '==========================================

leaky114's avatar
leaky114 已提交
1092
                        oRibbonPanel.CommandControls.AddButton(m_打开文件夹_Buttondef)
leaky114's avatar
leaky114 已提交
1093 1094

                        '==========================================
leaky114's avatar
leaky114 已提交
1095 1096 1097 1098 1099 1100 1101 1102 1103
                        oRibbonPanel.CommandControls.AddButton(m_保存关闭所有部件_Buttondef, False)
                        'oButtonDefinitions.Clear()
                        'oButtonDefinitions.Add(m_保存关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_保存关闭所有工程图_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有部件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有零件_Buttondef)
                        'oButtonDefinitions.Add(m_关闭所有工程图_Buttondef)
                        'oRibbonPanel.CommandControls.AddPopup(m_保存关闭所有部件_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1104 1105 1106 1107 1108 1109 1110
                        '==========================================

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_另存为Dwg_Buttondef)
                        oButtonDefinitions.Add(m_另存为Pdf_Buttondef)
                        oButtonDefinitions.Add(m_全部另存为_Buttondef)
leaky114's avatar
leaky114 已提交
1111
                        oRibbonPanel.CommandControls.AddPopup(m_另存为Dwg_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140
                        '==========================================

                        '==========================================
                        'oButtonDefinitions.Clear()
                        'oButtonDefinitions.Add(m_对称件iProperty_Buttondef)
                        ''oButtonDefinitions.Add(m_设置比例_Buttondef)
                        'panel.CommandControls.AddPopup(m_对称件iProperty_Buttondef, oButtonDefinitions, False)
                        ''==========================================

                        ''----------------------------------------------------------------------------------
                        'oButtonDefinitions.Clear()
                        'oButtonDefinitions.Add(m_检查序号完整性_Buttondef)
                        'oButtonDefinitions.Add(m_新建序号_Buttondef)
                        'panel.CommandControls.AddPopup(m_检查序号完整性_Buttondef, oButtonDefinitions, False)

                        '----------------------------------------------------------------------------------
                        '日期popup  '签字popup
                        oButtonDefinitions.Clear()

                        oButtonDefinitions.Add(m_设置签字_Buttondef)
                        oButtonDefinitions.Add(m_清除签字_Buttondef)
                        oButtonDefinitions.Add(m_自定义签字_Buttondef)

                        'oButtonDefinitions.Add(m_设置日期_Buttondef)
                        'oButtonDefinitions.Add(m_清除日期_Buttondef)
                        'oButtonDefinitions.Add(m_自定义日期_Buttondef)

                        'panel.CommandControls.AddPopup(m_设置日期_Buttondef, oButtonDefinitions, False)

leaky114's avatar
leaky114 已提交
1141
                        oRibbonPanel.CommandControls.AddPopup(m_设置签字_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154

                        '----------------------------------------------------------------------------------

                        '==========================================
                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_设置_Buttondef)
                        oButtonDefinitions.Add(m_量产iPropertys_Buttondef)
                        oButtonDefinitions.Add(m_工程图批量另存为_Buttondef)
                        oButtonDefinitions.Add(m_批量打印_Buttondef)
                        oButtonDefinitions.Add(m_还原旧图_Buttondef)
                        oButtonDefinitions.Add(m_清理旧版文件_Buttondef)
                        oButtonDefinitions.Add(m_帮助_Buttondef)
                        oButtonDefinitions.Add(m_关于_Buttondef)
leaky114's avatar
leaky114 已提交
1155
                        oRibbonPanel.CommandControls.AddPopup(m_设置_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1156 1157 1158 1159 1160
                        '==========================================

                        '在标注选项卡中添加
                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabAnnotate")
                        '在尺寸栏添加
leaky114's avatar
leaky114 已提交
1161
                        oRibbonPanel = oRibbonTab.RibbonPanels.Item("id_PanelD_AnnotateDimension")
leaky114's avatar
leaky114 已提交
1162

leaky114's avatar
leaky114 已提交
1163 1164
                        oRibbonPanel.CommandControls.AddButton(m_添加直径_Buttondef)
                        oRibbonPanel.CommandControls.AddButton(m_尺寸圆整_Buttondef)
leaky114's avatar
leaky114 已提交
1165 1166

                        '在表格栏添加
leaky114's avatar
leaky114 已提交
1167 1168
                        oRibbonPanel = oRibbonTab.RibbonPanels.Item("id_PanelD_AnnotateTable")
                        oRibbonPanel.CommandControls.AddButton(m_设置对称件iProperty_Buttondef)
leaky114's avatar
leaky114 已提交
1169 1170 1171 1172 1173 1174 1175
                        'panel.CommandControls.AddButton(m_检查序号完整性_Buttondef)
                        'panel.CommandControls.AddButton(m_新建序号_Buttondef)

                        oButtonDefinitions.Clear()
                        oButtonDefinitions.Add(m_检查序号完整性_Buttondef)
                        oButtonDefinitions.Add(m_新建序号_Buttondef)
                        oButtonDefinitions.Add(m_插入序号_Buttondef)
leaky114's avatar
leaky114 已提交
1176
                        oButtonDefinitions.Add(m_重写BOM序号_Buttondef)
leaky114's avatar
leaky114 已提交
1177
                        oRibbonPanel.CommandControls.AddPopup(m_检查序号完整性_Buttondef, oButtonDefinitions, False)
leaky114's avatar
leaky114 已提交
1178 1179 1180 1181 1182

                        '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                        '二维草图

leaky114's avatar
leaky114 已提交
1183
                        oRibbon = oUserInterfaceManager.Ribbons.Item("Part")
leaky114's avatar
leaky114 已提交
1184 1185 1186

                        oRibbonTab = oRibbon.RibbonTabs.Item("id_TabSketch")

leaky114's avatar
leaky114 已提交
1187
                        oRibbonPanel = oRibbonTab.RibbonPanels.Add("InAI", "ShinMaywaSketchPanel", ClientID)
leaky114's avatar
leaky114 已提交
1188 1189 1190 1191 1192 1193

                        'panel.CommandControls.AddButton(m_绘制横直线_Buttondef)
                        'panel.CommandControls.AddButton(m_绘制竖直线_Buttondef)
                        'panel.CommandControls.AddButton(m_绘制圆_Buttondef)
                        'panel.CommandControls.AddButton(m_绘制槽孔_Buttondef)

leaky114's avatar
leaky114 已提交
1194
                    ElseIf oUserInterfaceManager.InterfaceStyle = InterfaceStyleEnum.kClassicInterface Then
leaky114's avatar
leaky114 已提交
1195 1196 1197 1198 1199 1200 1201

                    End If
                End If

                'If bfirstTime Then ' Get the part features command bar.
                '    Dim CommandBar As Inventor.CommandBar

leaky114's avatar
21.12.3  
leaky114 已提交
1202
                '    ' Add a button to the command bar, defaulting to the end position.
leaky114's avatar
leaky114 已提交
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240
                '    '部件环境
                '    CommandBar = ThisApplication.UserInterfaceManager.CommandBars.Item("AMxAssemblyPanelCmdBar")

                '    CommandBar.Controls.AddButton(m_修改文件iProperty_Buttondef)
                '    ''零件环境
                '    CommandBar = ThisApplication.UserInterfaceManager.CommandBars.Item("PMxPartFeatureCmdBar")
                '    ''工程图环境
                '    CommandBar = ThisApplication.UserInterfaceManager.CommandBars.Item("DLxDrawingAnnotationPanelCmdBar")

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        '------------------------------------------------------------
        '定义图标
        Private Function GetIcon(ByVal IconName As String) As Object
            Dim oStream As System.IO.Stream = Me.GetType().Assembly.GetManifestResourceStream(IconName)
            If oStream Is Nothing Then
                Return Nothing
            End If

            Dim oIcon As Icon = New Icon(oStream)
            Dim oIPictureDisp32 As Object = Microsoft.VisualBasic.Compatibility.VB6.Support.IconToIPicture(oIcon)
            Return oIPictureDisp32

        End Function

        '以下按钮事件
        '------------------------------------------------------
        Private Sub m_修改文件iProperty_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_修改文件iProperty_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1241 1242
                Dim InventorDocument As Inventor.Document      '当前文件
                InventorDocument = ThisApplication.ActiveEditDocument
leaky114's avatar
leaky114 已提交
1243

leaky114's avatar
leaky114 已提交
1244
                If SetDocumentIpropertyFromFileName(InventorDocument, False) Then
leaky114's avatar
leaky114 已提交
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265
                    SetStatusBarText("获取编辑中的文件名修改iProperty完成")
                    'MsgBox("获取编辑中的文件名修改iProperty完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_修改部件iProperty_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_修改部件iProperty_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1266 1267
                Dim InventorDocument As Inventor.Document     '当前文件
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1268

leaky114's avatar
leaky114 已提交
1269
                If InventorDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
1270 1271 1272 1273
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1274
                If SetDocumentsInAssIpropertyFromFileName(InventorDocument, False) Then
leaky114's avatar
leaky114 已提交
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296
                    SetStatusBarText("获取当前部件中的子集文件名修改iProperty完成")
                    'MsgBox("获取当前部件中的文件名修改iProperty完成", MsgBoxStyle.Information)

                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_设置描述_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_设置描述_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1297 1298
                Dim InventorDocument As Inventor.Document     '当前编辑文件
                InventorDocument = ThisApplication.ActiveEditDocument
leaky114's avatar
leaky114 已提交
1299

leaky114's avatar
leaky114 已提交
1300 1301
                Dim frmInputBox As New frmInputBox
                With frmInputBox
leaky114's avatar
leaky114 已提交
1302
                    .Text = "设置描述"
leaky114's avatar
leaky114 已提交
1303
                    .lblDescribe.Text = "输入描述,写到【iProperty】【项目】【描述】"
leaky114's avatar
leaky114 已提交
1304
                    .txtInPut.Text = GetPropitem(InventorDocument, "描述")
leaky114's avatar
leaky114 已提交
1305 1306 1307 1308
                    .StartPosition = FormStartPosition.CenterScreen
                    .ShowDialog()
                End With

leaky114's avatar
leaky114 已提交
1309
                If frmInputBox.DialogResult = Windows.Forms.DialogResult.OK Then
leaky114's avatar
leaky114 已提交
1310

leaky114's avatar
leaky114 已提交
1311
                    If SetPropitem(InventorDocument, "描述", frmInputBox.txtInPut.Text) Then
leaky114's avatar
leaky114 已提交
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326
                        SetStatusBarText("设置描述完成。")
                    Else
                        SetStatusBarText("错误")
                        MsgBox("错误", MsgBoxStyle.Exclamation)

                    End If
                Else
                    Exit Sub
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

leaky114's avatar
leaky114 已提交
1327
        Private Sub m_ERP材料编码_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_ERP材料编码_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1328 1329 1330 1331 1332 1333 1334
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1335 1336
                Dim InventorDocument As Inventor.Document     '当前编辑文件
                InventorDocument = ThisApplication.ActiveEditDocument
leaky114's avatar
leaky114 已提交
1337

leaky114's avatar
leaky114 已提交
1338 1339
                Dim frmInputBox As New frmInputBox
                With frmInputBox
leaky114's avatar
leaky114 已提交
1340
                    .Text = "设置材料编码"
leaky114's avatar
leaky114 已提交
1341
                    .lblDescribe.Text = "输入材料编码,写到【iProperty】【项目】【" & Map_PartNum & "】"
leaky114's avatar
leaky114 已提交
1342
                    .txtInPut.Text = GetPropitem(InventorDocument, Map_PartNum)
leaky114's avatar
leaky114 已提交
1343 1344 1345 1346
                    .StartPosition = FormStartPosition.CenterScreen
                    .ShowDialog()
                End With

leaky114's avatar
leaky114 已提交
1347
                If frmInputBox.DialogResult = Windows.Forms.DialogResult.OK Then
leaky114's avatar
leaky114 已提交
1348

leaky114's avatar
leaky114 已提交
1349
                    If SetPropitem(InventorDocument, Map_PartNum, frmInputBox.txtInPut.Text) Then
leaky114's avatar
leaky114 已提交
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372
                        SetStatusBarText("设置材料编码完成。")
                    Else
                        SetStatusBarText("错误")
                        MsgBox("错误", MsgBoxStyle.Exclamation)

                    End If
                Else
                    Exit Sub
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_更改文件名_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_更改文件名_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1373 1374
                Dim InventorDocument As Inventor.Document
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1375

leaky114's avatar
leaky114 已提交
1376
                If InventorDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
1377 1378 1379 1380
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information, "修改文件名")
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1381
                Dim OldComponentOccurrence As ComponentOccurrence   '选择的部件或零件
leaky114's avatar
leaky114 已提交
1382

leaky114's avatar
leaky114 已提交
1383
                If InventorDocument.SelectSet.Count <> 0 Then
leaky114's avatar
leaky114 已提交
1384
                    'For Each oSelect As Object In InventorDoc.SelectSet
leaky114's avatar
leaky114 已提交
1385
                    OldComponentOccurrence = InventorDocument.SelectSet(1)
leaky114's avatar
leaky114 已提交
1386 1387
                    'Next
                Else
leaky114's avatar
leaky114 已提交
1388
                    OldComponentOccurrence = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "选择要更改文件名的零件或部件")
leaky114's avatar
leaky114 已提交
1389 1390
                End If

leaky114's avatar
leaky114 已提交
1391
                If OldComponentOccurrence Is Nothing Then       '取消选择
leaky114's avatar
leaky114 已提交
1392 1393 1394
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1395
                Select Case OldComponentOccurrence.DefinitionDocumentType
leaky114's avatar
leaky114 已提交
1396 1397 1398 1399 1400 1401
                    Case kAssemblyDocumentObject, kPartDocumentObject

                        Dim NewFileName As String   '新文件仅文件名

                        Dim OldFullFileName As String   '被替换的旧文件全名
                        Dim OldFileName As String   '被替换的旧文件仅文件名
leaky114's avatar
leaky114 已提交
1402
                        OldFullFileName = OldComponentOccurrence.ReferencedDocumentDescriptor.FullDocumentName
leaky114's avatar
leaky114 已提交
1403 1404 1405 1406
                        OldFileName = GetFileNameInfo(OldFullFileName).ONlyName

                        NewFileName = InputBox("重命名 " & OldFullFileName, "重命名", OldFileName)  '输入新文件名

leaky114's avatar
leaky114 已提交
1407
                        If RenameAssPartDocumentName(InventorDocument, OldComponentOccurrence, NewFileName) Then
leaky114's avatar
leaky114 已提交
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432
                            SetStatusBarText("更改零件/部件文件名完成")
                            'MsgBox("更改零件/部件文件名完成", MsgBoxStyle.Information)

                        Else
                            SetStatusBarText("错误")
                            MsgBox("错误", MsgBoxStyle.Exclamation)

                        End If
                    Case Else

                End Select
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_提取iPro修改文件名_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_提取iPro修改文件名_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                '判断是否为 assdoc
leaky114's avatar
leaky114 已提交
1433
                Dim InventorDocument As Inventor.Document
leaky114's avatar
leaky114 已提交
1434

leaky114's avatar
leaky114 已提交
1435
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1436

leaky114's avatar
leaky114 已提交
1437
                If InventorDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
1438 1439 1440 1441
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1442
                Dim OldComponentOccurrence As ComponentOccurrence   '选择的部件或零件
leaky114's avatar
leaky114 已提交
1443

leaky114's avatar
leaky114 已提交
1444
                If InventorDocument.SelectSet.Count <> 0 Then
leaky114's avatar
leaky114 已提交
1445
                    'For Each oSelect As Object In InventorDoc.SelectSet
leaky114's avatar
leaky114 已提交
1446
                    OldComponentOccurrence = InventorDocument.SelectSet(1)
leaky114's avatar
leaky114 已提交
1447 1448
                    'Next
                Else
leaky114's avatar
leaky114 已提交
1449
                    OldComponentOccurrence = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "选择要更改文件名的的零件或部件")
leaky114's avatar
leaky114 已提交
1450 1451
                End If

leaky114's avatar
leaky114 已提交
1452
                If OldComponentOccurrence Is Nothing Then       '取消选择
leaky114's avatar
leaky114 已提交
1453 1454 1455
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1456
                If GetIpropertyToRename(InventorDocument, OldComponentOccurrence) Then
leaky114's avatar
leaky114 已提交
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
                    SetStatusBarText("提取iproperty更改文件名完成")
                    'MsgBox("提取iproperty更改文件名完成", MsgBoxStyle.Information)

                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_生成图号_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_生成图号_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1472
            Dim AutoPartNumber As New frmAutoPartNumber
leaky114's avatar
leaky114 已提交
1473
            AutoPartNumber.Show()
leaky114's avatar
leaky114 已提交
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483
        End Sub

        Private Sub m_更改镜像文件名_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_更改镜像文件名_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1484 1485
                Dim InventorDocument As Inventor.Document
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1486

leaky114's avatar
leaky114 已提交
1487
                If InventorDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
1488 1489 1490 1491
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1492
                Dim OldComponentOccurrence As ComponentOccurrence   '选择的部件或零件
leaky114's avatar
leaky114 已提交
1493

leaky114's avatar
leaky114 已提交
1494
                If InventorDocument.SelectSet.Count <> 0 Then
leaky114's avatar
leaky114 已提交
1495
                    'For Each oSelect As Object In InventorDoc.SelectSet
leaky114's avatar
leaky114 已提交
1496
                    OldComponentOccurrence = InventorDocument.SelectSet(1)
leaky114's avatar
leaky114 已提交
1497 1498
                    'Next
                Else
leaky114's avatar
leaky114 已提交
1499
                    OldComponentOccurrence = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "选择要更改文件名的的零件或部件")
leaky114's avatar
leaky114 已提交
1500 1501
                End If

leaky114's avatar
leaky114 已提交
1502
                If OldComponentOccurrence Is Nothing Then       '取消选择
leaky114's avatar
leaky114 已提交
1503 1504 1505
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1506
                Select Case OldComponentOccurrence.DefinitionDocumentType
leaky114's avatar
leaky114 已提交
1507 1508 1509 1510
                    Case kPartDocumentObject, kAssemblyDocumentObject      '选择的是部件或零件

                        Dim OldFullFileName As String   '被替换的旧文件全名
                        Dim OldFileName As String   '被替换的旧文件仅文件名
leaky114's avatar
leaky114 已提交
1511
                        OldFullFileName = OldComponentOccurrence.ReferencedDocumentDescriptor.FullDocumentName
leaky114's avatar
leaky114 已提交
1512 1513 1514 1515 1516 1517 1518 1519 1520 1521
                        OldFileName = GetFileNameInfo(OldFullFileName).ONlyName

                        Dim NewFileName As String   '新文件仅文件名
                        NewFileName = InputBox("重命名 " & OldFullFileName, "镜像重命名", OldFileName)  '输入新文件名

                        '取消输入
                        If NewFileName = "" Then
                            Exit Sub
                        End If

leaky114's avatar
leaky114 已提交
1522
                        If RenameMirrorAssPartDocumentName(InventorDocument, OldComponentOccurrence, NewFileName) Then
leaky114's avatar
leaky114 已提交
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547
                            SetStatusBarText("更改镜像零件/部件文件名完成")
                            'MsgBox("更改零件/部件文件名完成", MsgBoxStyle.Information)

                        Else
                            SetStatusBarText("错误")
                            MsgBox("错误", MsgBoxStyle.Exclamation)

                        End If
                    Case MsgBox("选择的文件不是零件或部件", MsgBoxStyle.Information)

                End Select
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_打开文件夹_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_打开文件夹_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1548 1549 1550 1551 1552
                Dim InventorDocument As Inventor.Document
                Dim InventorDocumentFileNameInfo As FileNameInfo
                InventorDocument = ThisApplication.ActiveEditDocument
                InventorDocumentFileNameInfo = GetFileNameInfo(InventorDocument.FullDocumentName)
                Process.Start(InventorDocumentFileNameInfo.Folder)
leaky114's avatar
leaky114 已提交
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_保存关闭_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_保存关闭_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                With ThisApplication.ActiveDocument
                    If IsFileExsts(.FullDocumentName) = True Then
                        .Save2(True)
                        .Close()
                    Else
                        .Save()
leaky114's avatar
leaky114 已提交
1574
                        .Close()
leaky114's avatar
leaky114 已提交
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
                    End If
                End With

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_另存为Pdf_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_另存为Pdf_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1592 1593
                Dim InventorDocument As Inventor.Document
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1594

leaky114's avatar
leaky114 已提交
1595 1596
                Dim PdfFullFileName As String

leaky114's avatar
leaky114 已提交
1597
                PdfFullFileName = SaveAsPdf(InventorDocument)
leaky114's avatar
leaky114 已提交
1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632

                If PdfFullFileName = "取消" Then
                    SetStatusBarText("另存为PDF完成")
                    Exit Sub
                End If

                If IsFileExsts(PdfFullFileName) Then
                    SetStatusBarText("另存为PDF完成")
                    If MsgBox("是否打开文件: " & PdfFullFileName, MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                        System.Diagnostics.Process.Start(PdfFullFileName)
                    End If
                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_另存为Dwg_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_另存为Dwg_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1633 1634
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1635 1636 1637

                Dim DwgFullFileName As String

leaky114's avatar
leaky114 已提交
1638
                DwgFullFileName = SaveAsDwg(InventorDrawingDocument)
leaky114's avatar
leaky114 已提交
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677

                Select Case DwgFullFileName
                    Case "非工程图"
                        SetStatusBarText("该文件非工程图。")
                        Exit Sub
                    Case "取消"
                        SetStatusBarText("取消。")
                        Exit Sub
                End Select

                If IsFileExsts(DwgFullFileName) Then
                    SetStatusBarText("另存为CAD-DWG完成")
                    If MsgBox("是否打开文件: " & DwgFullFileName, MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                        System.Diagnostics.Process.Start(DwgFullFileName)
                    End If
                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_设置BOM结构_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_设置BOM结构_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1678 1679
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
                InventorAssemblyDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1680

leaky114's avatar
leaky114 已提交
1681
                If SetBOMStructuret(InventorAssemblyDocument) Then
leaky114's avatar
leaky114 已提交
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707
                    SetStatusBarText(" 设置BOM结构完成")
                    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    'MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_设置比例_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_设置比例_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1708 1709
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1710

leaky114's avatar
leaky114 已提交
1711
                If SetDrawingScale(InventorDrawingDocument) Then
leaky114's avatar
leaky114 已提交
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732
                    SetStatusBarText("设置工程图自定义属性:比例完成")
                    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_设置对称件iProperty_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_设置对称件iProperty_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1733 1734
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1735

leaky114's avatar
leaky114 已提交
1736
                If SetDrawingMirPartIPro(InventorDrawingDocument) Then
leaky114's avatar
leaky114 已提交
1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762
                    SetStatusBarText("设置工程图自定义属性:对称件IPro")
                    'MsgBox("设置工程图自定义属性:对称件IPro", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_序号完整性_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_检查序号完整性_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1763 1764
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1765

leaky114's avatar
leaky114 已提交
1766
                If CheckSerialNumber(InventorDrawingDocument) Then
leaky114's avatar
leaky114 已提交
1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793
                    SetStatusBarText("检查序号完整性完成")
                    MsgBox("检查序号完整性完成", MsgBoxStyle.Information)
                Else

                    'SetStatusBarText("错误")
                    'MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_新建序号_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_新建序号_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1794 1795
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1796 1797

                '设置为一个动作,可一次撤销
leaky114's avatar
leaky114 已提交
1798 1799
                Dim oTransientGeometry As TransientGeometry
                oTransientGeometry = ThisApplication.TransientGeometry
leaky114's avatar
leaky114 已提交
1800 1801 1802 1803
                'start a transaction so the slot will be within a single undo step
                Dim createSlotTransaction As Transaction
                createSlotTransaction = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument, "重新设置序号")

leaky114's avatar
leaky114 已提交
1804
                If SetSerialNumber(InventorDrawingDocument) Then
leaky114's avatar
leaky114 已提交
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834
                    SetStatusBarText("重新设置序号完成")
                    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    'MsgBox("错误", MsgBoxStyle.Exclamation)

                End If

                'end the transactio
                createSlotTransaction.End()

            Catch ex As Exception
                'MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_插入序号_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_插入序号_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1835 1836
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1837 1838

                '设置为一个动作,可一次撤销
leaky114's avatar
leaky114 已提交
1839 1840
                Dim oTransientGeometry As TransientGeometry
                oTransientGeometry = ThisApplication.TransientGeometry
leaky114's avatar
leaky114 已提交
1841
                'start a transaction so the slot will be within a single undo step
leaky114's avatar
leaky114 已提交
1842

leaky114's avatar
leaky114 已提交
1843 1844 1845
                Dim createSlotTransaction As Transaction
                createSlotTransaction = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument, "插入序号")

leaky114's avatar
leaky114 已提交
1846
                If InsertSerialNumber(InventorDrawingDocument) Then
leaky114's avatar
leaky114 已提交
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875
                    SetStatusBarText("插入序号完成")
                    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    'MsgBox("错误", MsgBoxStyle.Exclamation)

                End If

                'end the transactio
                createSlotTransaction.End()

            Catch ex As Exception
                'MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_设置签字_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_设置签字_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1876 1877
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1878 1879 1880 1881 1882

                Dim Print_Day As String

                Print_Day = Today.Year & "." & Today.Month & "." & Today.Day

leaky114's avatar
leaky114 已提交
1883
                If SetSign(InventorDrawingDocument, EngineerName, Print_Day, True) Then
leaky114's avatar
leaky114 已提交
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907
                    SetStatusBarText("设置工程图属性:签字完成")
                Else
                    SetStatusBarText("错误")
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_清除签字_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_清除签字_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
1908 1909
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                InventorDrawingDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
1910

leaky114's avatar
leaky114 已提交
1911
                If SetSign(InventorDrawingDocument, "", "", False) Then
leaky114's avatar
leaky114 已提交
1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922
                    SetStatusBarText("清除工程图属性,签字完成")
                Else
                    SetStatusBarText("错误")
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_自定义签字_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_自定义签字_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1923 1924
            Dim frmSign As New frmSign
            frmSign.ShowDialog()
leaky114's avatar
leaky114 已提交
1925 1926 1927
        End Sub

        Private Sub m_设置_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_设置_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1928 1929
            Dim frmOption As New frmOption
            frmOption.ShowDialog()
leaky114's avatar
leaky114 已提交
1930 1931 1932
        End Sub

        Private Sub m_量产iPropertys_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_量产iPropertys_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1933 1934
            Dim frmiPoperties As New frmiPoperties
            frmiPoperties.ShowDialog()
leaky114's avatar
leaky114 已提交
1935 1936 1937
        End Sub

        Private Sub m_批量打印_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_批量打印_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1938 1939
            Dim frmPrint As New frmPrint
            frmPrint.ShowDialog()
leaky114's avatar
leaky114 已提交
1940 1941 1942
        End Sub

        Private Sub m_工程图批量另存为_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_工程图批量另存为_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1943
            Dim SaveAsDialog As New frmSaveAs
leaky114's avatar
leaky114 已提交
1944 1945 1946 1947
            SaveAsDialog.ShowDialog()
        End Sub

        Private Sub m_全部另存为_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_全部另存为_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
1948 1949
            Dim frmAllSaveAs As New frmAllSaveAs
            frmAllSaveAs.ShowDialog()
leaky114's avatar
leaky114 已提交
1950 1951 1952 1953 1954 1955 1956
        End Sub

        'Public oclsMousePosition As clsDrawSlot
        ' Private oMousePosition As Point2d

        Private Sub m_还原旧图_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_还原旧图_Buttondef.OnExecute
            '打开文件
leaky114's avatar
leaky114 已提交
1957
            Dim oOpenFileDialog As New OpenFileDialog '声名新open 窗口
leaky114's avatar
leaky114 已提交
1958

leaky114's avatar
leaky114 已提交
1959
            With oOpenFileDialog
leaky114's avatar
leaky114 已提交
1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
                .Title = "打开"
                .Filter = "AutoDesk Inventor 旧文件(*.old)|*.old" '添加过滤文件
                .Multiselect = True '多开文件打开
                If .ShowDialog = Windows.Forms.DialogResult.OK Then '如果打开窗口OK
                    If .FileName <> "" Then '如果有选中文件
                        Dim OldFullFileName As String
                        Dim NewFullFileName As String
                        For Each OldFullFileName In .FileNames
                            NewFullFileName = Left(OldFullFileName, Strings.Len(OldFullFileName) - 4)
                            Rename(OldFullFileName, NewFullFileName)
                        Next
                    End If
                    MsgBox("更改旧文件名完成。")
                End If
            End With

        End Sub

        Private Sub m_关于_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_关于_Buttondef.OnExecute
            'Dim HelpMessage As String = "当前版本:" & My.Application.Info.Version.ToString & GetBiaoQing()

            'MsgBox(HelpMessage, MsgBoxStyle.Information)

leaky114's avatar
leaky114 已提交
1983
            Dim frmAbout As New frmAbout
leaky114's avatar
leaky114 已提交
1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
            frmAbout.ShowDialog()

            '============================================================
            '测试代码

            '============================================================
        End Sub

        Private Sub m_帮助_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_帮助_Buttondef.OnExecute
            Dim HelpFullFileName As String
            HelpFullFileName = My.Application.Info.DirectoryPath & "\帮助.pdf"

            Process.Start(HelpFullFileName)

        End Sub

        Private Sub m_保存关闭所有部件_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_保存关闭所有部件_Buttondef.OnExecute

            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2009 2010
                Dim frmSaveAll As New frmSaveAll
                frmSaveAll.ShowDialog()
leaky114's avatar
leaky114 已提交
2011

leaky114's avatar
leaky114 已提交
2012 2013 2014 2015 2016 2017 2018 2019 2020 2021
                'For Each oInventorDocument As Inventor.Document In ThisApplication.Documents
                '    If oInventorDocument.DocumentType = kAssemblyDocumentObject Then
                '        With oInventorDocument
                '            If IsFileExsts(.FullDocumentName) = True Then
                '                .Save2(True)
                '                .Close()
                '            End If
                '        End With
                '    End If
                'Next
leaky114's avatar
leaky114 已提交
2022 2023 2024 2025 2026 2027

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

leaky114's avatar
leaky114 已提交
2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149
        'Private Sub m_保存关闭所有零件_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_保存关闭所有零件_Buttondef.OnExecute

        '    Try
        '        SetStatusBarText()

        '        If IsInventorOpenDoc() = False Then
        '            Exit Sub
        '        End If

        '        For Each oInventorDocument As Inventor.Document In ThisApplication.Documents
        '            If oInventorDocument.DocumentType = kPartDocumentObject Then
        '                With oInventorDocument
        '                    If IsFileExsts(.FullDocumentName) = True Then
        '                        .Save2(True)
        '                        .Close()
        '                    End If
        '                End With
        '            End If
        '        Next

        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try
        'End Sub

        'Private Sub m_保存关闭所有工程图_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_保存关闭所有工程图_Buttondef.OnExecute

        '    Try
        '        SetStatusBarText()

        '        If IsInventorOpenDoc() = False Then
        '            Exit Sub
        '        End If

        '        For Each oInventorDocument As Inventor.Document In ThisApplication.Documents
        '            If oInventorDocument.DocumentType = kDrawingDocumentObject Then
        '                With oInventorDocument
        '                    If IsFileExsts(.FullDocumentName) = True Then
        '                        .Save2(True)
        '                        .Close()
        '                    End If
        '                End With
        '            End If
        '        Next

        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try
        'End Sub


        'Private Sub m_关闭所有部件_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_关闭所有部件_Buttondef.OnExecute

        '    Try
        '        SetStatusBarText()

        '        If IsInventorOpenDoc() = False Then
        '            Exit Sub
        '        End If

        '        For Each oInventorDocument As Inventor.Document In ThisApplication.Documents
        '            If oInventorDocument.DocumentType = kAssemblyDocumentObject Then
        '                With oInventorDocument
        '                    If IsFileExsts(.FullDocumentName) = True Then
        '                        .Close(True)
        '                    End If
        '                End With
        '            End If
        '        Next

        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try
        'End Sub

        'Private Sub m_关闭所有零件_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_关闭所有零件_Buttondef.OnExecute

        '    Try
        '        SetStatusBarText()

        '        If IsInventorOpenDoc() = False Then
        '            Exit Sub
        '        End If

        '        For Each oInventorDocument As Inventor.Document In ThisApplication.Documents
        '            If oInventorDocument.DocumentType = kPartDocumentObject Then
        '                With oInventorDocument
        '                    If IsFileExsts(.FullDocumentName) = True Then
        '                        .Close(True)
        '                    End If
        '                End With
        '            End If
        '        Next

        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try
        'End Sub

        'Private Sub m_关闭所有工程图_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_关闭所有工程图_Buttondef.OnExecute

        '    Try
        '        SetStatusBarText()

        '        If IsInventorOpenDoc() = False Then
        '            Exit Sub
        '        End If

        '        For Each oInventorDocument As Inventor.Document In ThisApplication.Documents
        '            If oInventorDocument.DocumentType = kDrawingDocumentObject Then
        '                With oInventorDocument
        '                    If IsFileExsts(.FullDocumentName) = True Then
        '                        .Close(True)
        '                    End If
        '                End With
        '            End If
        '        Next

        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try
        'End Sub
leaky114's avatar
leaky114 已提交
2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182
        'Private Sub m_绘制横直线_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_绘制横直线_Buttondef.OnExecute
        '    Dim oclsDrawLine As clsDrawHLine
        '    oclsDrawLine = New clsDrawHLine(ThisApplication)

        'End Sub

        'Private Sub m_绘制竖直线_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_绘制竖直线_Buttondef.OnExecute
        '    Dim oclsDrawVLine As clsDrawVLine
        '    oclsDrawVLine = New clsDrawVLine(ThisApplication)

        'End Sub

        'Private Sub m_绘制圆_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_绘制圆_Buttondef.OnExecute
        '    Dim oclsDrwCircle As clsDrawCircle
        '    oclsDrwCircle = New clsDrawCircle(ThisApplication)

        'End Sub

        'Private Sub m_绘制槽孔_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_绘制槽孔_Buttondef.OnExecute
        '    Dim DrawSlotDialog As New DrawSlotDialog
        '    DrawSlotDialog.Show()

        'End Sub

        Private Sub m_添加直径_Buttondef_OnExecute() Handles m_添加直径_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                '判断是否为 assdoc
leaky114's avatar
leaky114 已提交
2183
                Dim InventorDocument As Inventor.Document
leaky114's avatar
leaky114 已提交
2184

leaky114's avatar
leaky114 已提交
2185
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2186

leaky114's avatar
leaky114 已提交
2187
                If InventorDocument.DocumentType <> kDrawingDocumentObject Then
leaky114's avatar
leaky114 已提交
2188 2189 2190 2191
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information, "添加Φ")
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2192
                If ADDFai(InventorDocument) Then
leaky114's avatar
leaky114 已提交
2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218
                    SetStatusBarText("添加直径符号Φ完成")
                    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    'MsgBox("错误", MsgBoxStyle.Exclamation)

                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_检查是否有工程图_Buttondef_OnExecute() Handles m_检查是否有工程图_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    'Return False
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2219 2220
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
                InventorAssemblyDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2221

2222 2223 2224
                Dim frmInputBox As New frmInputBox
999:
                With frmInputBox
leaky114's avatar
leaky114 已提交
2225
                    .txtInPut.Text = GetPropitem(InventorAssemblyDocument, Map_StochNum)
leaky114's avatar
leaky114 已提交
2226
                    .Text = "检查包号指定字符的工程图"
leaky114's avatar
leaky114 已提交
2227
                    .lblDescribe.Text = "输入要检查的部分图号的。" & vbCrLf & "如要检查全部GT100下的零件是否有工程图,输入GT100即可。"
leaky114's avatar
leaky114 已提交
2228 2229 2230 2231
                    .StartPosition = FormStartPosition.CenterScreen
                    .ShowDialog()
                End With

2232
                If (frmInputBox.DialogResult = Windows.Forms.DialogResult.OK) And (frmInputBox.txtInPut.Text <> "") Then
leaky114's avatar
leaky114 已提交
2233
                    If CheckIsInvHaveIdw(InventorAssemblyDocument, frmInputBox.txtInPut.Text) Then
leaky114's avatar
leaky114 已提交
2234 2235 2236 2237 2238
                        MsgBox("检查是否有工程图完成,打开了未找到工程图对应的模型文件。", MsgBoxStyle.Information)
                    Else
                        SetStatusBarText("错误")
                        'MsgBox("错误", MsgBoxStyle.Exclamation)
                    End If
2239 2240
                ElseIf frmInputBox.DialogResult = Windows.Forms.DialogResult.Cancel Then
                    Exit Sub
leaky114's avatar
leaky114 已提交
2241
                Else
leaky114's avatar
leaky114 已提交
2242 2243
                    MsgBox("请输入部分图号!", MsgBoxStyle.Information)
                    SetStatusBarText("错误")
2244
                    GoTo 999
leaky114's avatar
leaky114 已提交
2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293
                    Exit Sub
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        'Private Sub m_打开全部工程图_Buttondef_OnExecute() Handles m_打开全部工程图_Buttondef.OnExecute
        '    Try
        '        SetStatusBarText()

        '        If IsInventorOpenDoc() = False Then
        '            Exit Sub
        '        End If

        '        If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
        '            MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
        '            Exit Sub
        '        End If

        '        Dim AssDoc As AssemblyDocument
        '        AssDoc = ThisApplication.ActiveDocument

        '        If OpenAllDrwInAsm(AssDoc, "") Then
        '            MsgBox("打开了部件所有子集对应的工程图。", MsgBoxStyle.Information)
        '        Else
        '            SetStatusBarText("错误")
        '            'MsgBox("错误", MsgBoxStyle.Exclamation)

        '        End If
        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try
        'End Sub

        Private Sub m_打开指定工程图_Buttondef_OnExecute() Handles m_打开指定工程图_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2294 2295
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
                InventorAssemblyDocument = ThisApplication.ActiveDocument
2296 2297 2298
999:
                Dim frmInputBox As New frmInputBox
                With frmInputBox
leaky114's avatar
leaky114 已提交
2299
                    .txtInPut.Text = GetPropitem(InventorAssemblyDocument, Map_StochNum)
leaky114's avatar
leaky114 已提交
2300
                    .Text = "打开指定工程图"
leaky114's avatar
leaky114 已提交
2301
                    .lblDescribe.Text = "输入包含指定的字段的图号。" & vbCrLf & "如要打开 5183-9000000.aim 下的工程图,输入5183-9即可。"
leaky114's avatar
leaky114 已提交
2302 2303 2304 2305
                    .StartPosition = FormStartPosition.CenterScreen
                    .ShowDialog()
                End With

2306
                If (frmInputBox.DialogResult = Windows.Forms.DialogResult.OK) And (frmInputBox.txtInPut.Text <> "") Then
leaky114's avatar
leaky114 已提交
2307
                    If OpenAllDrwInAsm(InventorAssemblyDocument, frmInputBox.txtInPut.Text) Then
leaky114's avatar
leaky114 已提交
2308 2309 2310 2311
                        MsgBox("打开了部件所有子集对应的工程图。", MsgBoxStyle.Information)
                    Else
                        SetStatusBarText("错误")
                    End If
2312 2313
                ElseIf frmInputBox.DialogResult = Windows.Forms.DialogResult.Cancel Then
                    Exit Sub
leaky114's avatar
leaky114 已提交
2314
                Else
leaky114's avatar
leaky114 已提交
2315 2316
                    MsgBox("请输入部分图号!", MsgBoxStyle.Information)
                    SetStatusBarText("错误")
2317
                    GoTo 999
leaky114's avatar
leaky114 已提交
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356
                    Exit Sub
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_部件替换文件名_Buttondef_OnExecute() Handles m_部件替换文件名_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    'Return False
                    Exit Sub
                End If

                Dim OldName As String
                Dim NewName As String

                OldName = InputBox("输入:查找的内容")
                If OldName = "" Then
                    Exit Sub
                End If

                NewName = InputBox("输入:替换为")
                If NewName = "" Then
                    Exit Sub
                End If

                'OldName = "GT140"
                'NewName = "GT240"

leaky114's avatar
leaky114 已提交
2357 2358
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
                InventorAssemblyDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2359 2360 2361 2362

                Dim IsSaveAsOld As MsgBoxResult
                IsSaveAsOld = MsgBox("是否更改原文件为备份文件,扩展名增加 .old ?", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, "备份文件")

leaky114's avatar
leaky114 已提交
2363
                ReplaceNameInAsm(InventorAssemblyDocument, OldName, NewName, IsSaveAsOld)
leaky114's avatar
leaky114 已提交
2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380

                MsgBox("部件替换文件名完成。", MsgBoxStyle.Information)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        ' 导出BOM平面性
        Private Sub m_导出平面BOM_Buttondef_OnExecute() Handles m_导出平面BOM_Buttondef.OnExecute

            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2381
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
leaky114's avatar
leaky114 已提交
2382

leaky114's avatar
leaky114 已提交
2383
                InventorAssemblyDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2384

leaky114's avatar
leaky114 已提交
2385
                If InventorAssemblyDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
2386 2387 2388 2389 2390 2391
                    MsgBox("该功能仅适用于部件")
                    Exit Sub
                End If

                Dim ExcelFullFileName As String

leaky114's avatar
leaky114 已提交
2392
                ExcelFullFileName = My.Computer.FileSystem.SpecialDirectories.Desktop & "\" & GetFileNameInfo(InventorAssemblyDocument.FullFileName).ONlyName & "导出BOM.csv"
leaky114's avatar
leaky114 已提交
2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408

                If IsFileExsts(ExcelFullFileName) = True Then
                    DelFile(ExcelFullFileName, FileIO.RecycleOption.SendToRecycleBin)
                End If

                'If ExportBOMAsFlat(AssDoc, ExcelFullFileName) Then
                '    SetStatusBarText(" 导出BOM平面性完成")

                '    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)

                'Else
                '    SetStatusBarText("错误")
                '    'MsgBox("错误", MsgBoxStyle.Exclamation)

                'End If

leaky114's avatar
leaky114 已提交
2409
                ExportBOMAsFlat(InventorAssemblyDocument, ExcelFullFileName)
leaky114's avatar
leaky114 已提交
2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427
                SetStatusBarText(" 导出BOM平面性完成")
                Process.Start(ExcelFullFileName)

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        ' 刷新引用名称
        Private Sub m_刷新引用_Buttondef_OnExecute() Handles m_刷新引用_Buttondef.OnExecute

            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2428
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
leaky114's avatar
leaky114 已提交
2429

leaky114's avatar
leaky114 已提交
2430
                InventorAssemblyDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2431

leaky114's avatar
leaky114 已提交
2432
                If InventorAssemblyDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
2433 2434 2435 2436
                    MsgBox("该功能仅适用于部件")
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2437
                If RefreshShowName(InventorAssemblyDocument) Then
leaky114's avatar
leaky114 已提交
2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450
                    SetStatusBarText("刷新引用完成")
                    MsgBox("刷新引用完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_清理旧版文件_Buttondef_OnExecute() Handles m_清理旧版文件_Buttondef.OnExecute
            Try
leaky114's avatar
leaky114 已提交
2451

leaky114's avatar
leaky114 已提交
2452 2453 2454 2455
                Dim DestinationDirectory As String = Nothing
                Dim inf As FileAttributes
                Dim Present_Folder As String = Nothing

leaky114's avatar
leaky114 已提交
2456
                Dim FolderBrowserDialog As New FolderBrowserDialog
leaky114's avatar
leaky114 已提交
2457

leaky114's avatar
leaky114 已提交
2458
                With FolderBrowserDialog
leaky114's avatar
leaky114 已提交
2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500
                    .ShowNewFolderButton = False
                    .Description = "选择文件夹"
                    .RootFolder = System.Environment.SpecialFolder.Desktop
                    If .ShowDialog = DialogResult.OK Then
                        DestinationDirectory = .SelectedPath
                    Else
                        Exit Sub
                    End If
                End With

                'If DestinationDirectory = "" Then
                '    Exit Sub
                'End If

                Dim DeleteRecycleOption As Integer
                Select Case MsgBox("是否永久删除旧文件,而不是移动到回收站?", MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question + MsgBoxStyle.YesNo, "删除文件")
                    Case MsgBoxResult.Yes
                        DeleteRecycleOption = FileIO.RecycleOption.DeletePermanently
                    Case MsgBoxResult.No
                        DeleteRecycleOption = FileIO.RecycleOption.SendToRecycleBin
                End Select

                '是否为文件夹,在其后添加 \
                inf = VisualBasic.FileSystem.GetAttr(DestinationDirectory)

                If inf = FileAttributes.Directory Then
                    DestinationDirectory = DestinationDirectory + "\"
                End If

                DelOldDirectory(DestinationDirectory, DeleteRecycleOption)

                SetStatusBarText("就绪")
                MsgBox("清理旧版本文件完成!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "清理旧文件")

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_移动指定文件_Buttondef_OnExecute() Handles m_移动指定文件_Buttondef.OnExecute
            Try
leaky114's avatar
leaky114 已提交
2501

leaky114's avatar
21.12.3  
leaky114 已提交
2502
                ' 获取激活文档
leaky114's avatar
leaky114 已提交
2503 2504 2505
                Dim InventorAssemblyDocument As Inventor.AssemblyDocument
                InventorAssemblyDocument = ThisApplication.ActiveDocument

2506
999:
leaky114's avatar
leaky114 已提交
2507 2508
                Dim frmInputBox As New frmInputBox

2509
                With frmInputBox
leaky114's avatar
leaky114 已提交
2510
                    .txtInPut.Text = GetPropitem(InventorAssemblyDocument, Map_StochNum)
leaky114's avatar
leaky114 已提交
2511
                    .Text = "移动文件"
leaky114's avatar
leaky114 已提交
2512
                    .lblDescribe.Text = "将保存并关闭当前文档,移动指定的文件到当前部件文件夹。" & vbCrLf & "输入从第一个图号开始的筛选字段。"
leaky114's avatar
leaky114 已提交
2513 2514 2515 2516 2517
                    .StartPosition = FormStartPosition.CenterScreen
                    .ShowDialog()
                End With

                Dim sFilter As String
2518 2519 2520 2521
                If frmInputBox.DialogResult = Windows.Forms.DialogResult.OK And frmInputBox.txtInPut.Text <> "" Then
                    sFilter = frmInputBox.txtInPut.Text
                ElseIf frmInputBox.DialogResult = Windows.Forms.DialogResult.Cancel Then
                    Exit Sub
leaky114's avatar
leaky114 已提交
2522
                Else
leaky114's avatar
leaky114 已提交
2523 2524
                    MsgBox("请输入部分图号!", MsgBoxStyle.Information)
                    SetStatusBarText("错误")
2525
                    GoTo 999
leaky114's avatar
leaky114 已提交
2526 2527 2528
                    Exit Sub
                End If

leaky114's avatar
21.12.3  
leaky114 已提交
2529
                ' 获取所有引用文档
leaky114's avatar
leaky114 已提交
2530 2531
                Dim InventorDocumentsEnumerator As Inventor.DocumentsEnumerator
                InventorDocumentsEnumerator = InventorAssemblyDocument.AllReferencedDocuments
leaky114's avatar
leaky114 已提交
2532

leaky114's avatar
21.12.3  
leaky114 已提交
2533
                ' 遍历这些文档
leaky114's avatar
leaky114 已提交
2534

leaky114's avatar
leaky114 已提交
2535 2536
                Dim InvDocList(2000) As String

leaky114's avatar
leaky114 已提交
2537
                ReDim InvDocList(InventorDocumentsEnumerator.Count - 1)
leaky114's avatar
leaky114 已提交
2538 2539 2540

                Dim i As Integer = 0

leaky114's avatar
leaky114 已提交
2541
                For Each oReferencedDocument As Inventor.Document In InventorDocumentsEnumerator
leaky114's avatar
leaky114 已提交
2542 2543
                    Debug.Print(oReferencedDocument.FullFileName)
                    InvDocList(i) = oReferencedDocument.FullFileName
leaky114's avatar
leaky114 已提交
2544 2545 2546
                    i = i + 1
                Next

leaky114's avatar
leaky114 已提交
2547 2548 2549
                Dim oInventorAssemblyDocumentFullDocumentName As String
                oInventorAssemblyDocumentFullDocumentName = InventorAssemblyDocument.FullDocumentName

leaky114's avatar
leaky114 已提交
2550 2551
                '组件所在文件夹
                Dim oAsmDocFolder As String
leaky114's avatar
leaky114 已提交
2552 2553 2554 2555
                oAsmDocFolder = GetFileNameInfo(oInventorAssemblyDocumentFullDocumentName).Folder



leaky114's avatar
leaky114 已提交
2556
                '保存关闭组件
leaky114's avatar
leaky114 已提交
2557
                InventorAssemblyDocument.Close()
leaky114's avatar
leaky114 已提交
2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574

                Dim FileNameInfo As FileNameInfo

                For Each InvDoc As String In InvDocList
                    ThisApplication.StatusBarText = InvDoc
                    FileNameInfo = GetFileNameInfo(InvDoc)
                    If InStr(FileNameInfo.ONlyName, sFilter) = 1 Then
                        ReMoveFileToFolder(InvDoc, oAsmDocFolder)
                        Dim IdwDoc As String
                        IdwDoc = GetNewExtensionFileName(InvDoc, ".idw")
                        If IsFileExsts(IdwDoc) = True Then
                            ReMoveFileToFolder(IdwDoc, oAsmDocFolder)
                        End If

                    End If
                Next

leaky114's avatar
leaky114 已提交
2575 2576 2577 2578 2579 2580

                If MsgBox("移动指定文件完成,是否重新打开" & oInventorAssemblyDocumentFullDocumentName, MsgBoxStyle.YesNo + MsgBoxStyle.Question, "移动文件") = MsgBoxResult.Yes Then
                    ThisApplication.Documents.Open(oInventorAssemblyDocumentFullDocumentName)
                End If


leaky114's avatar
leaky114 已提交
2581

leaky114's avatar
leaky114 已提交
2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_对齐原始坐标面_Buttondef_OnExecute() Handles m_对齐原始坐标面_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                '判断是否为 assdoc
leaky114's avatar
leaky114 已提交
2596
                Dim InventorDocument As Inventor.Document
leaky114's avatar
leaky114 已提交
2597

leaky114's avatar
leaky114 已提交
2598
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2599

leaky114's avatar
leaky114 已提交
2600
                If InventorDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information, "对齐原始坐标面")
                    Exit Sub
                End If

                '设置为一个动作, 可一次撤销
                Dim transientGeometry As TransientGeometry
                transientGeometry = ThisApplication.TransientGeometry
                'start a transaction so the slot will be within a single undo step
                Dim createSlotTransaction As Transaction
                createSlotTransaction = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument, "重新设置序号")

                If FlushXYZPlane() Then
                    SetStatusBarText("对齐原始坐标面")
                    'MsgBox("设置工程图自定义属性:比例完成", MsgBoxStyle.Information)
                Else
                    SetStatusBarText("错误")
                    'MsgBox("错误", MsgBoxStyle.Exclamation)

                End If

                'end the transactio
                createSlotTransaction.End()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Private Sub m_查找缺失文件的部件_Buttondef_OnExecute() Handles m_查找缺失文件的部件_Buttondef.OnExecute
            Try
                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                SetStatusBarText()

leaky114's avatar
leaky114 已提交
2636 2637
                Dim InventorDocument As Inventor.Document     '当前文件
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2638

leaky114's avatar
leaky114 已提交
2639
                If InventorDocument.DocumentType <> kAssemblyDocumentObject Then
leaky114's avatar
leaky114 已提交
2640 2641 2642 2643
                    MsgBox("该功能仅适用于部件", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2644
                If GetUnkonwDocumentWithBOM(InventorDocument, False) Then
leaky114's avatar
leaky114 已提交
2645
                    SetStatusBarText("查找缺失文件的部件完成")
2646
                    MsgBox("查找缺失文件的部件完成", MsgBoxStyle.Information)
leaky114's avatar
leaky114 已提交
2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659
                Else
                    SetStatusBarText("错误")
                    MsgBox("错误", MsgBoxStyle.Exclamation)

                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

        Private Sub m_统计质量面积_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_统计质量面积_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
2660 2661
            Dim frmGetPart As New frmGetPart
            frmGetPart.Show()
leaky114's avatar
leaky114 已提交
2662 2663 2664
        End Sub

        Private Sub m_调整IPro顺序_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_调整IPro顺序_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
2665 2666
            Dim frmChangeIpro As New frmChangeIpro
            frmChangeIpro.ShowDialog()
leaky114's avatar
leaky114 已提交
2667 2668 2669 2670 2671 2672 2673
        End Sub

        Private Sub m_尺寸圆整_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_尺寸圆整_Buttondef.OnExecute
            SetDrawingDimPrecision()
        End Sub

        Private Sub m_导入存货编码_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_导入存货编码_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
2674 2675
            Dim frmInventoryCoding As New frmInventoryCoding
            frmInventoryCoding.Show()
leaky114's avatar
leaky114 已提交
2676 2677
        End Sub

leaky114's avatar
leaky114 已提交
2678

leaky114's avatar
leaky114 已提交
2679 2680 2681 2682 2683 2684 2685 2686 2687
        Private Sub m_打开工程图_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_打开工程图_Buttondef.OnExecute
            Try

                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2688 2689
                Dim InventorDocument As Inventor.Document
                InventorDocument = ThisApplication.ActiveDocument
leaky114's avatar
leaky114 已提交
2690 2691


leaky114's avatar
leaky114 已提交
2692
                If InventorDocument.SelectSet.Count <> 0 Then
leaky114's avatar
leaky114 已提交
2693
                    'For Each oSelect As Object In InventorDoc.SelectSet
leaky114's avatar
leaky114 已提交
2694
                    For Each ComponentOccurrence As ComponentOccurrence In InventorDocument.SelectSet()
leaky114's avatar
leaky114 已提交
2695 2696
                        'Next
                        'MsgBox(OldOcc.ReferencedDocumentDescriptor.FullDocumentName)
leaky114's avatar
leaky114 已提交
2697 2698
                        InventorDocument = ThisApplication.Documents.ItemByName(ComponentOccurrence.ReferencedDocumentDescriptor.FullDocumentName)
                        OpenDrawingDocument(InventorDocument)
leaky114's avatar
leaky114 已提交
2699 2700
                    Next
                Else
leaky114's avatar
leaky114 已提交
2701 2702
                    InventorDocument = ThisApplication.ActiveEditDocument
                    OpenDrawingDocument(InventorDocument)
leaky114's avatar
leaky114 已提交
2703 2704 2705 2706 2707 2708 2709
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

leaky114's avatar
leaky114 已提交
2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724
        'BOM表保存新的替换项和按序号排序

        Private Sub m_重写BOM序号_Buttondef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_重写BOM序号_Buttondef.OnExecute
            Try
                SetStatusBarText()

                If IsInventorOpenDoc() = False Then
                    Exit Sub
                End If

                If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
                    MsgBox("该功能仅适用于工程图", MsgBoxStyle.Information)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2725 2726
                Dim InventorDrawingDocument As Inventor.DrawingDocument
                Dim ActiveSheet As Sheet
leaky114's avatar
leaky114 已提交
2727

leaky114's avatar
leaky114 已提交
2728 2729
                InventorDrawingDocument = ThisApplication.ActiveDocument
                ActiveSheet = InventorDrawingDocument.ActiveSheet
leaky114's avatar
leaky114 已提交
2730

leaky114's avatar
leaky114 已提交
2731
                If ActiveSheet.PartsLists.Count = 0 Then
leaky114's avatar
leaky114 已提交
2732 2733 2734 2735
                    MsgBox("该工程图无明细表", MsgBoxStyle.Critical)
                    Exit Sub
                End If

leaky114's avatar
leaky114 已提交
2736 2737
                For Each InventorPartsListRow As Inventor.PartsListRow In ActiveSheet.PartsLists.Item(1).PartsListRows
                    InventorPartsListRow.SaveItemOverridesToBOM()
leaky114's avatar
leaky114 已提交
2738 2739
                Next

leaky114's avatar
leaky114 已提交
2740
                ActiveSheet.PartsLists(1).Sort("序号", True)
leaky114's avatar
leaky114 已提交
2741 2742 2743 2744 2745 2746 2747

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

        End Sub

leaky114's avatar
leaky114 已提交
2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760
        Private Sub m_打开ERP数据文件_Buttondef_OnExecute() Handles m_打开ERP数据文件_Buttondef.OnExecute
            Try
                If IsFileExsts(Excel_File_Name) Then
                    Process.Start(Excel_File_Name)
                Else
                    Process.Start(My.Application.Info.DirectoryPath)
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

leaky114's avatar
leaky114 已提交
2761
        Private Sub m_查询ERP编码_Buttondef_OnExecute() Handles m_查询ERP编码_Buttondef.OnExecute
leaky114's avatar
leaky114 已提交
2762 2763
            'Try
            SetStatusBarText()
leaky114's avatar
leaky114 已提交
2764

leaky114's avatar
leaky114 已提交
2765 2766 2767
            If IsInventorOpenDoc() = False Then
                Exit Sub
            End If
leaky114's avatar
leaky114 已提交
2768

leaky114's avatar
leaky114 已提交
2769 2770 2771

            Dim InventorDocument As Inventor.Document      '当前文件
            InventorDocument = ThisApplication.ActiveEditDocument
leaky114's avatar
leaky114 已提交
2772

leaky114's avatar
leaky114 已提交
2773 2774 2775
            Dim oPropSets As PropertySets
            Dim oPropSet As PropertySet
            Dim propitem As [Property]
leaky114's avatar
leaky114 已提交
2776

leaky114's avatar
leaky114 已提交
2777
            oPropSets = InventorDocument.PropertySets
leaky114's avatar
leaky114 已提交
2778
            oPropSet = oPropSets.Item(3)
leaky114's avatar
leaky114 已提交
2779

leaky114's avatar
leaky114 已提交
2780 2781 2782 2783 2784 2785 2786
            '获取iproperty
            Dim StockNumPartName As StockNumPartName = Nothing
            For Each propitem In oPropSet
                Select Case propitem.DisplayName
                    Case Map_StochNum
                        Dim StochNum As String
                        StochNum = propitem.Value
leaky114's avatar
leaky114 已提交
2787

leaky114's avatar
leaky114 已提交
2788
                        Dim PartNum As String = Nothing
leaky114's avatar
leaky114 已提交
2789

leaky114's avatar
leaky114 已提交
2790 2791 2792 2793
                        'Public Excel_File_Name As String       'excel文件名
                        'Public Sheet_Name As String          '搜索的表
                        'Public Table_Array As String            '搜索的范围
                        'Public Col_Index_Num As String        '搜索列
leaky114's avatar
leaky114 已提交
2794

leaky114's avatar
leaky114 已提交
2795
                        'PartNum = VLookUpValue(Excel_File_Name, StochNum, Sheet_Name, Table_Array, Col_Index_Num, 0)
leaky114's avatar
leaky114 已提交
2796

leaky114's avatar
leaky114 已提交
2797
                        PartNum = FindSrtingInSheet(Excel_File_Name, StochNum, Sheet_Name, Table_Arrays, Col_Index_Num, 0)
leaky114's avatar
leaky114 已提交
2798

leaky114's avatar
leaky114 已提交
2799 2800
                        If PartNum <> 0 Then
                            MsgBox("查询到ERP编码:" & PartNum, MsgBoxStyle.OkOnly, "查询ERP编码")
leaky114's avatar
leaky114 已提交
2801
                            SetPropitem(InventorDocument, Map_PartNum, PartNum)
leaky114's avatar
leaky114 已提交
2802 2803 2804 2805 2806 2807 2808 2809 2810
                        Else
                            MsgBox("未查询到ERP编码。", MsgBoxStyle.OkOnly, "查询ERP编码")
                        End If
                End Select
            Next

            'Catch ex As Exception
            '    MsgBox(ex.Message)
            'End Try
leaky114's avatar
leaky114 已提交
2811
        End Sub
leaky114's avatar
leaky114 已提交
2812

leaky114's avatar
leaky114 已提交
2813

leaky114's avatar
leaky114 已提交
2814 2815 2816 2817 2818 2819 2820 2821 2822
        Private Sub m_快速打开_Buttondef_OnExecute() Handles m_快速打开_Buttondef.OnExecute
            Try
                SetStatusBarText()

                Dim WorkSpaceFloder As String
                WorkSpaceFloder = ThisApplication.FileLocations.Workspace & "\"

                Dim FileName As String
                FileName = InputBox("查询文件夹:" & WorkSpaceFloder & vbCrLf & vbCrLf & "输入文件名,包含扩展名", "快速打开")
leaky114's avatar
leaky114 已提交
2823

leaky114's avatar
leaky114 已提交
2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852
                If FileName = "" Then
                    Exit Sub
                End If

                Dim files As ReadOnlyCollection(Of String)

                files = My.Computer.FileSystem.GetFiles(WorkSpaceFloder, FileIO.SearchOption.SearchAllSubDirectories, FileName)

                If files.Count <> 0 Then

                    If files.Count = 1 Then
                        For Each FullFileName As String In files
                            ThisApplication.Documents.Open(FullFileName)
                        Next
                    Else
                        Dim frmQuitOpen As New frmQuitOpen
                        For Each FullFileName As String In files
                            frmQuitOpen.lvwFileListView.Items.Add(FullFileName)
                        Next
                        frmQuitOpen.ShowDialog()
                    End If


                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
leaky114's avatar
leaky114 已提交
2853 2854 2855



leaky114's avatar
leaky114 已提交
2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876
        '--------------------------------------------------------------

        Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate

            ' This method is called by Inventor when the AddIn is unloaded.
            ' The AddIn will be unloaded either manually by the user or
            ' when the Inventor session is terminated.

            ' TODO:  Add ApplicationAddInServer.Deactivate implementation

            ' Release objects.
            Marshal.ReleaseComObject(ThisApplication)
            ThisApplication = Nothing

            System.GC.WaitForPendingFinalizers()
            System.GC.Collect()

        End Sub

        Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation

leaky114's avatar
21.12.3  
leaky114 已提交
2877
            ' This property is provided to allow the AddIn to expose an API
leaky114's avatar
leaky114 已提交
2878
            ' of its own to other programs. Typically, this  would be done by
leaky114's avatar
21.12.3  
leaky114 已提交
2879
            ' implementing the AddIn's API interface in a class and returning
leaky114's avatar
leaky114 已提交
2880 2881 2882 2883 2884 2885 2886 2887 2888 2889
            ' that class object through this property.

            Get
                Return Nothing
            End Get

        End Property

        Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand

leaky114's avatar
21.12.3  
leaky114 已提交
2890
            ' Note:this method is now obsolete, you should use the
leaky114's avatar
leaky114 已提交
2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980
            ' ControlDefinition functionality for implementing commands.

        End Sub

#End Region

#Region "COM Registration"

        ' Registers this class as an AddIn for Inventor.
        ' This function is called when the assembly is registered for COM.
        <ComRegisterFunctionAttribute()> _
        Public Shared Sub Register(ByVal t As Type)

            Dim clssRoot As RegistryKey = Registry.ClassesRoot
            Dim clsid As RegistryKey = Nothing
            Dim subKey As RegistryKey = Nothing

            Try
                clsid = clssRoot.CreateSubKey("CLSID\" + AddInGuid(t))
                clsid.SetValue(Nothing, "InventorAddIn")
                subKey = clsid.CreateSubKey("Implemented Categories\{39AD2B5C-7A29-11D6-8E0A-0010B541CAA8}")
                subKey.Close()

                subKey = clsid.CreateSubKey("Settings")
                subKey.SetValue("AddInType", "Standard")
                subKey.SetValue("LoadOnStartUp", "1")

                'subKey.SetValue("SupportedSoftwareVersionLessThan", "")
                subKey.SetValue("SupportedSoftwareVersionGreaterThan", "14..")
                'subKey.SetValue("SupportedSoftwareVersionEqualTo", "")
                'subKey.SetValue("SupportedSoftwareVersionNotEqualTo", "")
                'subKey.SetValue("Hidden", "0")
                'subKey.SetValue("UserUnloadable", "1")
                subKey.SetValue("Version", 0)
                subKey.Close()

                subKey = clsid.CreateSubKey("Description")
                subKey.SetValue(Nothing, "InventorAddIn")

            Catch ex As Exception
                System.Diagnostics.Trace.Assert(False)
            Finally
                If Not subKey Is Nothing Then subKey.Close()
                If Not clsid Is Nothing Then clsid.Close()
                If Not clssRoot Is Nothing Then clssRoot.Close()
            End Try

        End Sub

        ' Unregisters this class as an AddIn for Inventor.
        ' This function is called when the assembly is unregistered.
        <ComUnregisterFunctionAttribute()> _
        Public Shared Sub Unregister(ByVal t As Type)

            Dim clssRoot As RegistryKey = Registry.ClassesRoot
            Dim clsid As RegistryKey = Nothing

            Try
                clssRoot = Microsoft.Win32.Registry.ClassesRoot
                clsid = clssRoot.OpenSubKey("CLSID\" + AddInGuid(t), True)
                clsid.SetValue(Nothing, "")
                clsid.DeleteSubKeyTree("Implemented Categories\{39AD2B5C-7A29-11D6-8E0A-0010B541CAA8}")
                clsid.DeleteSubKeyTree("Settings")
                clsid.DeleteSubKeyTree("Description")
            Catch
            Finally
                If Not clsid Is Nothing Then clsid.Close()
                If Not clssRoot Is Nothing Then clssRoot.Close()
            End Try

        End Sub

        ' This property uses reflection to get the value for the GuidAttribute attached to the class.
        Public Shared ReadOnly Property AddInGuid(ByVal t As Type) As String
            Get
                Dim guid As String = ""
                Try
                    Dim customAttributes() As Object = t.GetCustomAttributes(GetType(GuidAttribute), False)
                    Dim guidAttribute As GuidAttribute = CType(customAttributes(0), GuidAttribute)
                    guid = "{" + guidAttribute.Value.ToString() + "}"
                Finally
                    AddInGuid = guid
                End Try
            End Get
        End Property

#End Region

    End Class

leaky114's avatar
21.12.3  
leaky114 已提交
2981
End Namespace