Create/Place Content Center Part with user inputs to Assembly

Create/Place Content Center Part with user inputs to Assembly

pmartick
Advocate Advocate
514 Views
2 Replies
Message 1 of 3

Create/Place Content Center Part with user inputs to Assembly

pmartick
Advocate
Advocate

I'm stuck trying to figure out what seems to be a simple iLogic function: Place a box of a certain size from Content Center into the assembly.

 

In Content Center I have a child node called "Features", in there is a family called "Shipping Box"

 

There are 3 parameters, "Length", "Height", and "Depth", each have a minimum of 1 inch and only allow increments of 1 inch.

 

pmartick_0-1660131648423.png

 

The problem as far as I can tell is that using the API to find and place Content Center parts is entirely dependent on finding a specific pre-defined row in that content center family.  Obviously this isn't feasible for my use case, I don't want to spend time generating millions of unique rows in this table, I'm not even sure the software could handle that.

 

Hopefully it's just a simple thing I'm missing.  Thanks for your help.

 

iLogic snippet:

Components.AddContentCenterPart("Shipping Box-1-1-1:1", "Features", "Shipping Box", {"Length", 1, "Height", 1, "Depth", 1 }, position := Nothing, grounded := True, visible := True)

pmartick_1-1660131951353.pngpmartick_2-1660131961399.png

 

API route:

 

Dim oReason As MemberManagerErrorsEnum
Dim mValues As NameValueMap
Dim oRefresh As ContentMemberRefreshEnum
mValues.Add("Length", 1)
mValues.Add("Height", 1)
mValues.Add("Depth", 1)
ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("Features").Families.Item("Shipping Box").CreateMember(1, oReason, "Some Failure Occurred", oRefresh, , , mValues)

pmartick_3-1660132002824.pngpmartick_4-1660132015199.png

 

0 Likes
Accepted solutions (1)
515 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

This part of the API is not well documented and iLogic hasn't some shortcuts for this task. Here is sample how to create new file from content center library. This snippet doesn't create new occurrence in the assembly, but only creates new file on the disk. 

You need to change how to get your own content family and how to prepare parameters.

ContentFamily.CreateMember Method is the core of this snippet (Line 39).

 

'Prerequisites:
' - ISO content center library is attached to the active project
' - Content center language is set to English
' - Directory C:\Temp exists and is not write protected
' - File ISO657-100.ipt doesn't exists in C:\Temp

'Following line is culture specific!
Dim iBeams As ContentFamiliesEnumerator = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes("Structural Shapes").ChildNodes("I-Beams").Families
Dim iso657 As ContentFamily
For Each iBeamFamily As ContentFamily In iBeams
    If iBeamFamily.DisplayName = "ISO 657/15" Then
        iso657 = iBeamFamily
        Exit For
    End If
Next
Logger.Debug(iso657.DisplayName)

'Prepare parameters
Dim length As Double = 100 ' [current length units]

'Create file name - mandatory for custom families
Dim fileName As String = "C:\Temp\ISO657-" & length & ".ipt"

'Create custom inputs - mandatory for custom families
Dim customInput As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
customInput.Add("B_L", length)

'You need to create custom member
Dim custom As Boolean = True

'Other argumnets
Dim failureReason As MemberManagerErrorsEnum
Dim failureMessage As String = ""
Dim refresh As ContentMemberRefreshEnum = ContentMemberRefreshEnum.kUseDefaultRefreshSetting


Try
    'Create new custom content center file
    Dim memberFileName As String = iso657.CreateMember(1, failureReason, failureMessage, refresh, custom, fileName, customInput)
    Logger.Info("Success")
    Logger.Info(memberFileName)
Catch ex As Exception
    Logger.Error(ex.Message)
End Try

 

0 Likes
Message 3 of 3

pmartick
Advocate
Advocate
@Michael.Navara As it turns out I was just missing 3 things. I needed to Create the NameValueMap, the ContentMemberRefreshEnum needed a value, and apparently while you can get a ChildNode with a string, you can only use an integer to get a ContentFamily.

Dim oApp As Inventor.Application = ThisApplication
Dim oReason As MemberManagerErrorsEnum
Dim mValues As NameValueMap = oApp.TransientObjects.CreateNameValueMap
Dim oRefresh As ContentMemberRefreshEnum = ContentMemberRefreshEnum.kUseDefaultRefreshSetting
mValues.Add("Length", 4)
mValues.Add("Height", 4)
mValues.Add("Depth", 4)
oApp.ContentCenter.TreeViewTopNode.ChildNodes.Item("Features").Families.Item(1).CreateMember(1, oReason, "Some Failure Occurred", oRefresh, False, , mValues)
0 Likes