Message 1 of 4
Changing BOM Structure of an Assembly to Purchased using iLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a rule that triggers every time a new part or assembly is started. It pops up a form for the user to select Manufactured, Purchased or Stock. If the user selects Purchased, I want the BOM structure for that part/assembly to change to Purchased.
What I have works great with a part, but when I start a new assembly, I get this error.
Here is my current rule.
SyntaxEditor Code Snippet
'The Try/Catch looks to see if the parameter M_P_S exists...if not, the Catch imports the .xml file Try M = Parameter("M_P_S") Catch 'Import custom parameter iLogicVb.Automation.ParametersXmlLoad(ThisDoc.Document, "L:\Autodesk Software\iLogic Rules\NuTec M_P_S Custom Parameter.xml") End Try iLogicForm.ShowGlobal("NuTec (M,P,S)", FormMode.Modal) 'This calls the current value of the M_P_S parameter and truncates the value to 1 character iProperties.Value("Custom", "Mfg, Purchase, Stock") = Left(Parameter("M_P_S"), 1) 'This changes the BOM Structure for this part/assembly to Purchased if M_P_S = P (Purchased) 'Else it changes the BOM Structure to Normal Dim oDoc As Document = ThisApplication.ActiveDocument If Parameter("M_P_S") = "P (Purchased)" Then oDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure Else oDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure End If 'kDefaultBOMStructure 51969 The default structure type. 'kInseparableBOMStructure 51974 The inseparable structure type. 'kNormalBOMStructure 51970 The normal structure type. 'kPhantomBOMStructure 51971 The phantom structure type. 'kPurchasedBOMStructure 51973 The purchased structure type. 'kReferenceBOMStructure 51972 The reference structure type. 'kVariesBOMStructure 51975 The structure type varies amongst references. InventorVb.DocumentUpdate()