Add names of parts and subassemblies to list automatically

Add names of parts and subassemblies to list automatically

Darrell.johnson
Enthusiast Enthusiast
459 Views
2 Replies
Message 1 of 3

Add names of parts and subassemblies to list automatically

Darrell.johnson
Enthusiast
Enthusiast

Hi everybody,

 

I found this code from the iLogic Drawing Batch Tool 2015:

 

'check For Parameter And create If Not found
Try
	oTest = Parameter("ActionList") 
Catch
' Get the active document.  Assumes a part document is active.
    Dim partDoc As PartDocument
    partDoc = ThisApplication.ActiveDocument
    
    ' Get the UserParameters collection
    Dim userParams As UserParameters
    userParams = partDoc.ComponentDefinition.Parameters.UserParameters
	oParam = userParams.AddByValue("ActionList", "", UnitsTypeEnum.kTextUnits)
End Try

oApp = ThisApplication

Auto = iLogicVb.Automation
Dim iLogicAuto As Object
iLogicAuto = Auto
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oIndexNumber As Integer

'sets index number for the first run
If oIndexNumber < 0 Then
oIndexNumber = 0
End If

'create list and add default value
Dim oRuleList As New ArrayList

'get collection of rules
Dim ruleName As String
Dim rules As Object
rules = iLogicAuto.rules(oDoc)

'make sure there are rules in the file
'and then add them to the list
If Not (rules Is Nothing) Then
	For Each rule In rules
		ruleName = rule.Name
		If rule.Name.Contains("***") Then
		oRuleList.add(ruleName)
		'Set List
		MultiValue.List("ActionList") = oRuleList
		End If
	Next 
Else
'no rules found
Return 
End If

Is it possible to add the names of parts and subassemblies which are located in my main assembly to a list in a similar way?

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

chandra.shekar.g
Autodesk Support
Autodesk Support

@Darrell.johnson,

 

Hoping that partslist may be helpful to get the names of parts and subassembly. VBA sample code is available at below link.

 

http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-5B02B07C-FAEA-4107-A3AD-F6FFC317D134

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 3

Darrell.johnson
Enthusiast
Enthusiast
Accepted solution

Unfortunately this is not what I was looking for. But I figured it out for myself.

 

This is the code:

 

Dim MyArrayList1 As New ArrayList
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences
oComps = ThisDoc.Document.ComponentDefinition.Occurrences
For Each oComp In oComps
MyArrayList1.Add(oComp.Name)
Next
 
0 Likes