Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Change a parameter in certain parts in assembly with ilogic

Anonymous

Change a parameter in certain parts in assembly with ilogic

Anonymous
Not applicable

Hi,

 

We use a lot of ilogic and rules but I can't figure how to get this process to work, I hope you can help me.

 

Intended workflow - ilogic rule to run in an assembly

 

  1. Opens up a detailed BOM list (shows multiple instances of the same part, 1.1, 1.2 etc.) and allows selection of the parts required
  2. The parts selected are highlighted in the assembly window
  3. When a button is clicked the below happens for each selected part
    • the parameter called "Status" is changed to "In Production"
    • A rule called "UnitStatus" is run

 

This is all run in Vault and so in an ideal world I would like to also run the below when the button is clicked on each selected part

  1. Change to 'In Design' if not already
  2. Checkout part to allow change to be saved

I realise this might be asking a lot but even if I can manually select them in the window or type the item numbers into a text box it'd be a great time saver

 

This is my code so far but it doesn't work and obviously I'm working on the basic window selection version.

 

Dim oDoc As Document
Dim oPart As AssemblyComponentDefinition
oDoc = ThisApplication.ActiveDocument
oPart = oDoc.ComponentDefinition

'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection


'Check that at least 1 is selected
If oDoc.SelectSet.Count = 0 Then
    'MessageBox.Show("Please select a component.", "iLogic")
    Exit Sub 'bail out
End If


'add to Object Collection

For i = 1 To oDoc.SelectSet.Count
    If TypeOf oDoc.SelectSet.Item(i) Is ComponentOccurrence Then
        oSelected.Add (oDoc.SelectSet.Item(i))
    End If
Next

Dim Occ As ComponentOccurrence


    If oSelected.Count >= 1 Then
        For i =1 To oSelected.Count
        
			Try
			Parameter.Param("Status").Expression = "In Production"
			iLogicVb.RunRule(Occ, "UnitStatus")

			Catch

            End Try
        Next
    End If

 

Any help is welcome, thanks

 

Adam

 

 

0 Likes
Reply
Accepted solutions (1)
1,551 Views
4 Replies
Replies (4)

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Please provide non confidential sample assembly to check the feasibility.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

Anonymous
Not applicable

Hi Chandra,

 

Thanks for helping, please see the attached assembly and parts.

 

Adam

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous 

 

Sorry for late reply,

 

iLogic rule inside parts are successfully executed and custom iProperty is also changed for selected component

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

Anonymous
Not applicable
Accepted solution

I have managed to find a solution myself with some help from our resellers and to help anyone in the future it is below.

 

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection
'Check that at least 1 is selected
If oDoc.SelectSet.Count = 0 Then
    MessageBox.Show("Please select a component.", "iLogic")
    Exit Sub 'bail out
End If
Dim oValueList As New ArrayList
    oValueList.Add("Awaiting Approval")
    oValueList.Add("In Production")
    oValueList.Add("Stock")
    oValueList.Add("On Hold")
    oValueList.Add("Site Measure")
Dim oValue As String = InputListBox("Select one option", oValueList, "In Production", "Set Status", "Available Selections")
'add to Object Collection
For i = 1 To oDoc.SelectSet.Count
    If TypeOf oDoc.SelectSet.Item(i) Is ComponentOccurrence Then
        oSelected.Add (oDoc.SelectSet.Item(i))
    End If
Next
Dim Occ As Inventor.ComponentOccurrence
If oSelected.Count >= 1 Then
        For i =1 To oSelected.Count
        
            Occ=oSelected.Item(i)
                       Parameter(Occ.Name, "Status") = oValue
iLogicVb.RunRule(Occ.Name, "Unit Status")
Next
    End If
0 Likes