Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I found a code online in VBA that places every item from a content center family in a assembly (this works). I want make it so that it wil only place the items that are not suppressed. I found this in a post but i cant figure out how to add it in the code that i already have. some help would be appreciated
the code that i found + link:
If Not oFamily.TableRows.Item(i).IsSuppressed Then strContentPartFileName = oFamily.CreateMember(i, ErrorType, strErrorMessage)
End If
The code i found online that works:
Public Sub PlaceFromContentCenter() 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. Dim hexHeadNode As ContentTreeViewNode Set hexHeadNode = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Washers").ChildNodes.Item("Plain") ' 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 = "Sluitring th.vz." Then Set family = checkFamily Exit For End If Next Dim i As Integer If Not family Is Nothing Then ' Place one instance of each member. Dim offset As Double offset = 0 Dim row As ContentTableRow For Each row In family.TableRows ' Create the member (part file) from the table. Dim failureReason As MemberManagerErrorsEnum Dim failureMessage As String Dim memberFilename As String memberFilename = family.CreateMember(row, failureReason, failureMessage, kRefreshOutOfDateParts) ' 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 End Sub
With kind regards,
Frank.
Solved! Go to Solution.