Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add names of parts and subassemblies to list automatically

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Darrell.johnson
354 Views, 2 Replies

Add names of parts and subassemblies to list automatically

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?

2 REPLIES 2
Message 2 of 3

@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



Message 3 of 3

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
 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report