By Adam Nagy
You can insert Content Center parts programmatically. The following sample is looking through the whole Content Center content in order to find a specific part based on its display name.
Public Function GetFamily( _ name As String, node As ContentTreeViewNode) _ As ContentFamily Dim cc As ContentCenter Set cc = ThisApplication.ContentCenter If node Is Nothing Then Set node = cc.TreeViewTopNode Dim cf As ContentFamily For Each cf In node.Families If cf.DisplayName = name Then Set GetFamily = cf Exit Function End If Next Dim child As ContentTreeViewNode For Each child In node.ChildNodes Set cf = GetFamily(name, child) If Not cf Is Nothing Then Set GetFamily = cf Exit Function End If Next End Function Public Sub CcTest() Dim asm As AssemblyDocument Set asm = ThisApplication.ActiveDocument Dim cf As ContentFamily Set cf = GetFamily("CCPart", Nothing) Dim member As String Dim ee As MemberManagerErrorsEnum member = cf.CreateMember(1, ee, "Problem") Dim tg As TransientGeometry Set tg = ThisApplication.TransientGeometry Call asm.ComponentDefinition.Occurrences.Add( _ member, tg.CreateMatrix()) End Sub
The API Help File (C:\Users\Public\Documents\Autodesk\Inventor 2017\Local Help\admapi_21_0.chm) also contains a couple of samples concerning this topic:
- Place Content Center Parts API Sample
- Replace content center part API Sample