Ilogic to Identify ContentTreeViewNode of the selected content center component

Ilogic to Identify ContentTreeViewNode of the selected content center component

Anonymous
Not applicable
2,057 Views
6 Replies
Message 1 of 7

Ilogic to Identify ContentTreeViewNode of the selected content center component

Anonymous
Not applicable

Hi,

 

I would like to know, is there any possible way to identify the Tree View names of the selected part.

 

We can assaign Tree view node,

Dim oContentNode As ContentTreeViewNode
oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Tube & Pipe").ChildNodes.Item("Conduits").ChildNodes.Item("Pipes")
DimoFamilyAsContentFamily
ForEachoFamilyInoContentNode.Families
IfoFamily.DisplayName= "ANSI/ASME B36.19M Pipe" Then
ExitFor
EndIf
Next

but i would like to get the details of the selected part.

 

Dim oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select Component to replace:")

ie, i would like to get the selected part  - ContentTreeViewNode details.

 

Thanks in advance

 

0 Likes
2,058 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

To add more...do check out the ilogic code below......i would like to modify the code to check for selected component in an assembly

 

Sub Main()
G_GetPropertiesNames()
End Sub

Public Sub G_GetPropertiesNames()
On Error Resume Next
Dim ListBx As New ArrayList
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oProperties As Inventor.PropertySets = oDoc.PropertySets
For Each P As Inventor.PropertySet In oProperties
ListBx.Add(P.Name)
For Each I As Inventor.Property In P
ListBx.Add(Space(12) & I.Name)
ListBx.Add(Space(24) & I.Value)
Next
Next
ListBx = InputListBox("Prompt", ListBx, ListBx, Title := "Title", ListName := "List")

End Sub

 

0 Likes
Message 3 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

I wrote a code as below. Hope it is what you need.

 

Sub Main()
   
    Dim doc as AssemblyDocument
    doc = ThisApplication.ActiveDocument
	
	Dim oAssDef As AssemblyComponentDefinition
    oAssDef = doc.ComponentDefinition 
	
	Dim oObj As Object  
	
	oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select Component to replace:")
	If oObj Is Nothing Then
	
	Else
	    G_GetPropertiesNames(oObj.Definition.Document) 
	End If
    
End Sub

Public Sub G_GetPropertiesNames(oDoc) 
 
Dim ListBx As New ArrayList 
Dim oProperties As Inventor.PropertySets = oDoc.PropertySets 
    For Each P As Inventor.PropertySet In oProperties 
        ListBx.Add(P.Name) 
        For Each I As Inventor.Property In P 
		    ' filter out the property which is Thumbnail
            If   I.Name <> "Thumbnail" Then		
            ListBx.Add(Space(12) & I.Name)
            ListBx.Add(Space(24) & I.Value)
			End If
        Next 
    Next 
ListBx = InputListBox("Prompt", ListBx, ListBx, Title := "Title", ListName := "List")



End Sub 

 

Message 4 of 7

Anonymous
Not applicable

Dear Sir,

 

I got the below code (bit modified - to suit ilogic) from 

http://modthemachine.typepad.com/my_weblog/2012/02/getting-data-from-content-center.html

 

 

Sub Main()

GetContentObject_Test()

End Sub

Sub GetContentObject_Test()
Dim oOcc As ComponentOccurrence
oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Pick occurrence")

If oOcc.DefinitionDocumentType <> kPartDocumentObject Then
MsgBox ("The occurrence is not a CC part.")
Exit Sub
End If

Dim oOccDef As PartComponentDefinition
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
oContentCenter = ThisApplication.ContentCenter

' Reference "CC Library Component
' Properties' propertyset
Dim propSet As PropertySet
propSet = oOccDef.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")

' Get FamilyId property
'Dim familyId1 As Property
familyId1 = propSet.Item("FamilyId")


' Get MemberId property
Dim strMemberId As String
strMemberId = propSet("MemberId").Value
'MsgBox(strMemberId)
'Dim msgBoxResult As VbMsgBoxResult
'msgBoxResult = MsgBox _
'("Get Family ?", vbYesNo, "Yes=Family No=Row") ,
j = MessageBox.Show("Get Family??; Yes=Family;No=Row", "My iLogic Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)

If j = vbYes Then
' Get family, (Not including memberId)
Dim oContentFamily As ContentFamily
oContentFamily = oContentCenter.GetContentObject("v3#" & familyId1.Value & "#")
MsgBox("family display name: " +oContentFamily.DisplayName +vbCr +"family LibraryName name: " +oContentFamily.LibraryName)
Else
' Get Table Row, (Including memberId)
Dim oContentTableRow As ContentTableRow
oContentTableRow = oContentCenter.GetContentObject("v3#" & familyId1.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

I can get Table data by the above code (as shown in the below image)CC Table Data.png

Whether it is possible to get RowStatus Number and also Column name by ilogic code.

 

 

 

0 Likes
Message 5 of 7

Anonymous
Not applicable

Hi, Got Row Status No. by dividing strMemberId by 10.

MsgBox("RowString No :" &strMemberId/10)

Need some help on how to find column name

Message 6 of 7

JBEDsol
Collaborator
Collaborator

I'm using VB.net, I'm getting stuck at 

 

Dim propFamilyID As [Property]
propFamilyID = psPropertySet.Item("FamilyId")

 

When I try to define the property I get something weird ("[" brackets).  I'm assuming I can't declare a variable as a Property in VB.net.  What would I need to do?

0 Likes
Message 7 of 7

A.Acheson
Mentor
Mentor

Hi @JBEDsol 

Can you supply the complete code your using an a image of any error messages?  Little difficult make out the context of your question. 

 

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