Inventor и 1С

Автор Тема: Inventor и 1С  (Прочитано 1687 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн blackdewАвтор темы

  • ADN OPEN
  • Сообщений: 2
  • Карма: 0
Inventor и 1С
« : 09-12-2019, 08:39:25 »
Всем доброго дня.
Стоит задача выгружать/связать спецификации из АИ с 1С.
Можно выгружать в exel, а затем подгружать в 1С, но хотелось бы этот процесс автоматизировать и при выгрузке добавить возможность выбора компонентов и подуровней.

Оффлайн mikazakov

  • ADN
  • *
  • Сообщений: 751
  • Карма: 195
  • Skype: mikazakov@mail.ru
Re: Inventor и 1С
« Ответ #1 : 09-12-2019, 08:57:03 »
Всем доброго дня.
Стоит задача выгружать/связать спецификации из АИ с 1С.
Можно выгружать в exel, а затем подгружать в 1С, но хотелось бы этот процесс автоматизировать и при выгрузке добавить возможность выбора компонентов и подуровней.
Если прямиком считывать данные, то можно и без инвентора, через Апрентис Сервер. Почитать можно здесь
https://drive.google.com/file/d/12ru-xsimKmHBSqoxLVTCosZrS4OviQko/view

Так же, в хэлпе есть пример доступа к данным сборки:

Код - Visual Basic [Выбрать]
  1. Public Sub BOMQuery()
  2.     ' Set a reference to the assembly document.
  3.    ' This assumes an assembly document is active.
  4.    Dim oDoc As AssemblyDocument
  5.     Set oDoc = ThisApplication.ActiveDocument
  6.  
  7.     Dim FirstLevelOnly As Boolean
  8.     If MsgBox("First level only?", vbYesNo) = vbYes Then
  9.         FirstLevelOnly = True
  10.     Else
  11.         FirstLevelOnly = False
  12.     End If
  13.    
  14.     ' Set a reference to the BOM
  15.    Dim oBOM As BOM
  16.     Set oBOM = oDoc.ComponentDefinition.BOM
  17.    
  18.     ' Set whether first level only or all levels.
  19.    If FirstLevelOnly Then
  20.         oBOM.StructuredViewFirstLevelOnly = True
  21.     Else
  22.         oBOM.StructuredViewFirstLevelOnly = False
  23.     End If
  24.    
  25.     ' Make sure that the structured view is enabled.
  26.    oBOM.StructuredViewEnabled = True
  27.    
  28.     'Set a reference to the "Structured" BOMView
  29.    Dim oBOMView As BOMView
  30.     Set oBOMView = oBOM.BOMViews.Item("Structured")
  31.        
  32.     Debug.Print "Item"; Tab(15); "Quantity"; Tab(30); "Part Number"; Tab(70); "Description"
  33.     Debug.Print "----------------------------------------------------------------------------------"
  34.  
  35.     'Initialize the tab for ItemNumber
  36.    Dim ItemTab As Long
  37.     ItemTab = -3
  38.     Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab)
  39. End Sub
  40.  
  41. Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long)
  42.     ItemTab = ItemTab + 3
  43.     ' Iterate through the contents of the BOM Rows.
  44.    Dim i As Long
  45.     For i = 1 To oBOMRows.Count
  46.         ' Get the current row.
  47.        Dim oRow As BOMRow
  48.         Set oRow = oBOMRows.Item(i)
  49.  
  50.         'Set a reference to the primary ComponentDefinition of the row
  51.        Dim oCompDef As ComponentDefinition
  52.         Set oCompDef = oRow.ComponentDefinitions.Item(1)
  53.  
  54.         Dim oPartNumProperty As Property
  55.         Dim oDescripProperty As Property
  56.  
  57.         If Typeof oCompDef Is VirtualComponentDefinition Then
  58.             'Get the file property that contains the "Part Number"
  59.            'The file property is obtained from the virtual component definition
  60.            Set oPartNumProperty = oCompDef.PropertySets _
  61.                 .Item("Design Tracking Properties").Item("Part Number")
  62.  
  63.             'Get the file property that contains the "Description"
  64.            Set oDescripProperty = oCompDef.PropertySets _
  65.                 .Item("Design Tracking Properties").Item("Description")
  66.  
  67.             Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
  68.                 oPartNumProperty.Value; Tab(70); oDescripProperty.Value
  69.         Else
  70.             'Get the file property that contains the "Part Number"
  71.            'The file property is obtained from the parent
  72.            'document of the associated ComponentDefinition.
  73.            Set oPartNumProperty = oCompDef.Document.PropertySets _
  74.                 .Item("Design Tracking Properties").Item("Part Number")
  75.  
  76.             'Get the file property that contains the "Description"
  77.            Set oDescripProperty = oCompDef.Document.PropertySets _
  78.                 .Item("Design Tracking Properties").Item("Description")
  79.  
  80.             Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
  81.                 oPartNumProperty.Value; Tab(70); oDescripProperty.Value
  82.            
  83.             'Recursively iterate child rows if present.
  84.            If Not oRow.ChildRows Is Nothing Then
  85.                 Call QueryBOMRowProperties(oRow.ChildRows, ItemTab)
  86.             End If
  87.         End If
  88.     Next
  89.     ItemTab = ItemTab - 3
  90. End Sub
  91.  

Оффлайн blackdewАвтор темы

  • ADN OPEN
  • Сообщений: 2
  • Карма: 0
Re: Inventor и 1С
« Ответ #2 : 09-12-2019, 08:59:06 »
Спасибо - буду изучать.
Появилась задача, а в этом пока совсем ноль.
Михаил, приятно снова "услышать" знакомый голос ;)