Message 1 of 2
API Place custom c/c part

Not applicable
09-11-2014
03:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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!