- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Community,
I am trying to place Content Center parts into a subassembly.
The following iLogic code works well to place a part with a known Stock Number into a top-level assembly:
' Specify language
Components.ContentCenterLanguage = "en-US"
' Add hardware component
Dim oBolt1Pos = ThisAssembly.Geometry.Point(0.0, 0.0, 0.0)
Dim compBolt1 = Components.AddContentCenterPart("Bolt1", "Fasteners:Bolts:Hex Head", "Hex Cap Screw - Inch", {"StockNumber", "123-1234" }, oBolt1Pos)
To my knowledge, the API must be used to place a content Center part into a subassembly.
I do not know how to obtain the component by its Stock Number using the API.
What I have pieced together from other forum posts:
' Get the node in the content browser based on the names of the nodes in the hierarchy.
Dim SpringWasherNode As ContentTreeViewNode = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Washers").ChildNodes.Item("Spring")
' Find a specific family.
Dim family As ContentFamily
Dim checkFamily As ContentFamily
For Each checkFamily In SpringWasherNode.Families
If checkFamily.DisplayName = "Lock Washer - Inch" Then
family = checkFamily
Exit For
End If
Next
If Not family Is Nothing Then
'''
''' GET COMPONENT BY ITS STOCK NUMBER. NEED HELP HERE.
'''
' Create the member (part file) from the table.
Dim failureReason As MemberManagerErrorsEnum
Dim failureMessage As String
Dim memberFilename As String
memberFilename = family.CreateMember(????????, failureReason, failureMessage, kRefreshOutOfDateParts)
' Place the part into the assembly.
Dim transMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix
transMatrix.Cell(2, 4) = offset
Try
Dim Occ As ComponentOccurrence = subasmDef.Occurrences.Add(memberFilename, transMatrix)
Catch
End Try
End If
Of course to test this code, you will need to modify to match names within your content center library.
Any assistance to identify the CC part by its stock number would be appreciated.
If there is a better method to place CC parts into a subassembly, I welcome your suggestions.
BTW- I tried using Edit and ExitEdit, but that resulted in noticeable flickering as assemblies were edited and exited.
Thank you for your time and attention. I look forward to your replies.
Regards,
Jerry
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Solved! Go to Solution.