Community
Hi,
I'm looking for a way to place a custom content-center part in my assembly by rule.
Is this possible?
I found this code in the "programming help" but i cannot get it to work. And i guess it's for standard parts?
Sub PlaceContentCenterPart() ' Set a reference to the active assembly document. Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument ' Set a reference to the ContentCenter object. Dim oContentCenter As ContentCenter Set oContentCenter = ThisApplication.ContentCenter ' Get the content node (category) "Fasteners:Bolts:Hex Head" Dim oContentNode As ContentTreeViewNode Set oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Bolts").ChildNodes.Item("Hex Head") ' Get the "ISO 4015" Family object. Dim oFamily As ContentFamily For Each oFamily In oContentNode.Families If oFamily.DisplayName = "ISO 4015" Then Exit For End If Next ' Create a member based on the first row of the family. Dim error As MemberManagerErrorsEnum Dim strContentPartFileName As String Dim strErrorMessage As String strContentPartFileName = oFamily.CreateMember(1, error, strErrorMessage) Dim oMat As Matrix Set oMat = ThisApplication.TransientGeometry.CreateMatrix ' Insert an instance of the content center member in the assembly. Call oDoc.ComponentDefinition.Occurrences.Add(strContentPartFileName, oMat) End Sub
I'm getting these errors.
Rule Compile Errors in Plaats part, in Plaatsen van content center parts.iam Error on Line 22 : Keyword is not valid as an identifier. Error on Line 25 : Expression expected.
So I'm kinda stuck on this one. Getting this to work would save me loads of time in the future!
Oké,
The first obvious error is out.. My bad.. adjusted the API sample a little and got it to work. Got a Standard Bolt (first size available) placed in my assembly.
How can i get the Bolt to be placed as a custom part?
' Set a reference to the active assembly document. Dim oDoc As AssemblyDocument oDoc = ThisApplication.ActiveDocument ' Set a reference to the ContentCenter object. Dim oContentCenter As ContentCenter oContentCenter = ThisApplication.ContentCenter ' Get the content node (category) "Fasteners:Bolts:Hex Head" Dim oContentNode As ContentTreeViewNode oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Bolts").ChildNodes.Item("Hex Head") ' Get the "ISO 4015" Family object. Dim oFamily As ContentFamily For Each oFamily In oContentNode.Families If oFamily.DisplayName = "DIN 931" Then Exit For End If Next ' Create a member based on the first row of the family. Dim oError As MemberManagerErrorsEnum Dim strContentPartFileName As String Dim strErrorMessage As String strContentPartFileName = oFamily.CreateMember(1, oError, strErrorMessage) Dim oMat As Matrix oMat = ThisApplication.TransientGeometry.CreateMatrix ' Insert an instance of the content center member in the assembly. Call oDoc.ComponentDefinition.Occurrences.Add(strContentPartFileName, oMat)
Can't find what you're looking for? Ask the community or share your knowledge.