Logic to navigate to specific Content Centre category

Logic to navigate to specific Content Centre category

waynehelley
Collaborator Collaborator
301 Views
4 Replies
Message 1 of 5

Logic to navigate to specific Content Centre category

waynehelley
Collaborator
Collaborator

Hi all,

 

I know that it's possible to open the 'Place from Content Centre' dialogue using the command manager.

 

ThisApplication.CommandManager.ControlDefinitions.Item("CCV2PlaceButtonCM")

 

I really need to be able to open this dialogue and then navigate to a specific category.  Is this possible?

 

Many thanks

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes
302 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

That command is not very useful beyond that dialog launch by code as it doesn't have the ability to browse for a family.

There is build in methods for adding content center parts by ilogic and the API.

 

Ilogic Add:

This method is by far the easiest for placing from content center. Found in the ilogic editor browser menu. Simply place the family member you need in the assembly and use capture snippet and add. Post here showing how to use this functionality

 

API Add:

Here is the sample for placing content center part written in VBA. It is a much longer route than using ilogic short snippet.

 

API Replace:

Replace an existing CC member.

Here is a starting point for you, it will choose the first occurrence in the assembly and select another member of the same family. Original code posted here.

 

'This iLogic demo replaces the given standard component
'with another member from same family.

' row number of the new family member .
Dim NewRow As Integer = 4

'active assembly s
Dim oMainAsm As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition

' get the occurrence by its position in the occurrences collection
Dim oOcc As ComponentOccurrence = oAsmDef.Occurrences.Item(1)
Dim oDef As PartComponentDefinition = oOcc.Definition
Dim oDoc As PartDocument = oDef.Document

'reference to the CC properties - oProps
Dim oPropSets As PropertySets = oDoc.PropertySets
Dim oProps As PropertySet = oPropSets.Item("Content Library Component Properties")

' family id
Dim oProp As Inventor.Property = oProps.Item("FamilyId")
Dim FamilyId As String = oProp.Value
'MsgBox("FamilyId: " + FamilyId)

'reference to the ContentFamily
Dim oContentCenter As ContentCenter = ThisApplication.ContentCenter
Dim oFamily As ContentFamily = oContentCenter.GetContentObject("v3#" + FamilyId + "#")  
'MsgBox("Content Family DisplayName:  " + oFamily.DisplayName & vbNewLine & _
'	    "Rows in Family:  " & oFamily.TableRows.Count )

'create new member file
Dim ErrorType As MemberManagerErrorsEnum
Dim strContentPartFileName As String
Dim strErrorMessage As String
strContentPartFileName = oFamily.CreateMember(NewRow, ErrorType, strErrorMessage)

'replace the existing component with the new one
oOcc.Replace(strContentPartFileName, False)

Beep
'------------------------

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 5

wayne.helleyY67EK
Enthusiast
Enthusiast
Thanks for your reply A.Acheson.

It's not quite what I'm looking for though. I don't want to trigger any adding or replacing of components.

I literally just need to open the dialogue, navigate to a specific category, then leave the user to go from there.
0 Likes
Message 4 of 5

A.Acheson
Mentor
Mentor

Unfortunately opening the content center window is only as far as you can go with that command. So I think the only option is via the API but you would either need to supply CC path and family information hard coded or in a small list  or try and recreate  the existing dialogue box functionality which would be a big project. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 5

A.Acheson
Mentor
Mentor

Another method you can try is to pick on the browser node/ part and then launch the place from content center command. This works to find the same family in Inventor when you do it manually so by code should be no different. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes