Sub PlaceFromContentCenter_2()
'новая сборка
Dim asmDoc As AssemblyDocument
Set asmDoc = ThisApplication.Documents.Add(kAssemblyDocumentObject)
'определение сборки
Dim asmDef As AssemblyComponentDefinition
Set asmDef = asmDoc.ComponentDefinition
' Get the node in the content browser based on the names of the nodes in the hierarchy.
' найдем узел в браузере CC по именам узлов в иерархической цепочке
Dim hexHeadNode As ContentTreeViewNode
Set hexHeadNode = ThisApplication.ContentCenter.TreeViewTopNode _
.ChildNodes.Item("Fasteners") _
.ChildNodes.Item("Bolts") _
.ChildNodes.Item("Hex Head")
' Find a specific family. In this case it's using the display name,
' but any family characteristic could be searched for.
' Найдем конкретное семейство. Здесь ищем по отображаемому имени.
' Можно искать и по другим характеристикам.
Dim family As ContentFamily
Dim checkFamily As ContentFamily
For Each checkFamily In hexHeadNode.Families
If checkFamily.DisplayName = "DIN EN 24016" Then
Set family = checkFamily
Exit For
End If
Next
If Not family Is Nothing Then
' Place one instance of each member.
' вставка членов семейства CC
Dim offset As Double
offset = 0
Dim row As ContentTableRow
'корневое имя вех деталей. Здесь это просто временная папка.
'к имени будет подставляться индекс, напр. NewPart-4, NewPart-5 и т.д.
Dim filename As String
filename = "c:\TEMP\AAA\NewPart-"
'вставим в свою демо-сборку первые несколько членов семейства
Dim i As Integer
For i = 1 To 5 'family.TableRows.Count
Set row = family.TableRows.Item(i)
' Create the member (part file) from the table.
' Генерация детали, определяемой параметрами в строке row
Dim failureReason As MemberManagerErrorsEnum
Dim failureMessage As String
Dim memberFilename As String
memberFilename = family.CreateMember(row, _
failureReason, failureMessage, kRefreshOutOfDateParts, _
True, filename & CStr(i) & ".ipt")
' Place the part into the assembly.
' вставляем деталь в сборку
Dim transMatrix As Matrix
Set transMatrix = ThisApplication.TransientGeometry.CreateMatrix
transMatrix.Cell(2, 4) = offset
Dim Occ As ComponentOccurrence
Set Occ = asmDef.Occurrences.Add(memberFilename, transMatrix)
' Compute the position for the next placement based on the size of the part just placed.
' вычисляем смещение для следующего компонента. Используется размер предыдущего компонента.
Dim minY As Double
Dim maxY As Double
minY = Occ.RangeBox.MinPoint.y
maxY = Occ.RangeBox.MaxPoint.y
offset = offset + ((maxY - minY) * 1.1)
Next
End If
Beep
ThisApplication.ActiveView.Fit
End Sub