Getting data from Content Center

You can use GetContentObject() of ContentCenter to get data about an occurrence that was placed from content center. There are two samples that use the ContentCenter object in the API help file, however there is not an example of using GetContentObject(). If you are trying to use this method it will help to know how to create the string so it will return what you need.   

In a recent case my colleague Xiaodong Liang explained that if the MemberId is included in the string parameter, GetContentObject() returns the ContentTableRow and if the MemberId is not provided, the method returns the ContentFamily. To get the MemberId you access a PropertySet of the PartDocument. (Use the Definition of the occurrence).

PartDocument->PropertySets->Content Library Component Properties>item[MemberId].Value.

VBA Example. (Please keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production).

Sub GetContentObject_Test()
    Dim oOcc As ComponentOccurrence
    Set oOcc = ThisApplication.CommandManager.Pick _
    (kAssemblyOccurrenceFilter, "Pick occurrence")
   
    If oOcc.DefinitionDocumentType <> _
                   kPartDocumentObject Then
        MsgBox _
        "The occurrence is not a CC part."
        Exit Sub
    End If
   
    Dim oOccDef As PartComponentDefinition
    Set oOccDef = oOcc.Definition
   
    If Not oOccDef.IsContentMember Then
        MsgBox _
        "The occurrence is not a CC part."
        Exit Sub
    End If
   
    ‘ Set a reference to the ContentCenter object.
    Dim oContentCenter As ContentCenter
    Set oContentCenter = _
            ThisApplication.ContentCenter
 
    ‘ Reference "CC Library Component
    ‘ Properties’ propertyset
    Dim propSet As PropertySet
    Set propSet = _
        oOccDef.Document.PropertySets.Item _
        ("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
   
    ‘ Get FamilyId property
    Dim familyId As Property
    Set familyId = propSet.Item("FamilyId")
  
   ‘ Get MemberId property
    Dim strMemberId As String
    strMemberId = propSet("MemberId").Value
   
    Dim msgBoxResult As VbMsgBoxResult
    msgBoxResult = MsgBox _
   ("Get Family ?", vbYesNo, "Yes=Family No=Row")
   
    If msgBoxResult = vbYes Then
      ‘ Get family, (Not including memberId)
       Dim oContentFamily As ContentFamily
       Set oContentFamily = _
            oContentCenter.GetContentObject _
                 ("v3#" & familyId.Value & "#")
 
       MsgBox "family display name: " _
        & oContentFamily.DisplayName & vbCr & _
         "family LibraryName name: " & _
                  oContentFamily.LibraryName
      Else
        ‘ Get Table Row, (Including memberId)
         Dim oContentTableRow As ContentTableRow
         Set oContentTableRow = _
              oContentCenter.GetContentObject _
     ("v3#" & familyId.Value & "#" & strMemberId)
       
         Dim str As String
         str = "Data from cells in Table Row" & vbCr
        ‘ Debug.Print oContentTableRow.count
         For i = 1 To oContentTableRow.count
          ‘ Debug.Print i 
      ‘ Debug.Print oContentTableRow.GetCellValue(i) 
      str = str & oContentTableRow.GetCellValue(i)
         Next
         MsgBox str
    End If
End Sub

Wayne Brill


Comments

2 responses to “Getting data from Content Center”

  1. Peter Wang Avatar
    Peter Wang

    Hi Wayne,
    Is there an example how to place a steel structure from CC? I know there is one in the sample code to place a bolt. Follow that, I can choose which Row to place, but I can’t work out how to set the length of that occurrence.
    Thanks a lot
    Peter

  2. Alessandro Avatar
    Alessandro

    Brian it is possible to open the screen of the “Place iLogic Component” through the API using C#? it created an application and want to open this screen and the object escolhor well throw it in assembly using the Place iLogic Component if you can help me I am very grateful. Alessandro Brazil
    e-mail — projetech.eng@gmail.com

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading