iLogic to change the Bom Structure of Suppressed parts.

iLogic to change the Bom Structure of Suppressed parts.

Anonymous
Not applicable
1,382 Views
6 Replies
Message 1 of 7

iLogic to change the Bom Structure of Suppressed parts.

Anonymous
Not applicable

I am trying to change the BOM Structure of parts that are suppressed to reference using the code below, however I can not get it to function.  Can any one help me out (Error message posted below the code)?

 

Dim doc As AssemblyDocument
doc = ThisDoc.Document
For Each oOcc In doc.ComponentDefinition.Occurrences
	If oOcc.Suppressed Then
		oOcc.BOMStructure = 51972 'reference
	Else
		oOcc.BOMStructure = 51969 'default
	End If
Next

 

Error in rule: LNSJ20.580_BURNER_UNIT, in document: LEB248691.IAM

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType)
at LmiRuleScript.Sub9(Object oPane)
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

0 Likes
Accepted solutions (1)
1,383 Views
6 Replies
Replies (6)
Message 2 of 7

Scott_Stubbington
Advocate
Advocate

Hello,

I ran your code in an Assembly document with no Part/Assembly Suppressed and the code worked fine, I then ran the code with a Part/Assembly Suppressed and it failed.  Manually, I tried to change the BOM structure of a Suppressed Part/Assembly and I am unable to, the option has now been removed due to the Part/Assembly being Suppressed which makes sense to me.

 

Good luck

 

Scott

0 Likes
Message 3 of 7

philip1009
Advisor
Advisor

You have to make the code un-suppress the part first, change the structure, then suppress the part again.  I'm curious as to why you want to do this, suppressed parts don't appear on BOMs just like reference parts.

0 Likes
Message 4 of 7

Anonymous
Not applicable

 Maybe I posted this in error. The code I used suppresses all parts in a folder ( rather than there “is not active”)  and when I looked at the bill material I thought the parts suppressed were still showing up. I’m out of the office for the next week so I’ll have to check once I get back to confirm. Thank you!

Message 5 of 7

Anonymous
Not applicable
Accepted solution

After testing I still found the suppressed items in the BOM (without using the code below).

As mentioned above; if the part is suppressed the code is not able to change the BOM Structure to Reference. Adding an unsuppress before changing the item to Reference, the returning the item to Suppressed state after looks to be successful.

 

Dim doc As AssemblyDocument

doc = ThisDoc.Document

For Each oOcc In doc.ComponentDefinition.Occurrences

   If oOcc.Suppressed Then

           oOcc.UnSuppress

          oOcc.BOMStructure = 51972 'reference

          oOcc.Suppress

    Else

        oOcc.BOMStructure = 51969 'default 

   End If

Next

Message 6 of 7

R.Mabery
Advocate
Advocate

Yes, what you're doing there is correct.  You need to unsuppress, change it's BOMStructure, then suppress back.

 

If a component is suppressed with code, it won't show up in the BOM as it's BOMStructure is changed to Reference.

If a component is manually suppressed, it still shows up in the BOM as it's BOMStructure is not changed.

 

Hope that helps.

 

 


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
0 Likes
Message 7 of 7

Anonymous
Not applicable

Thank you

0 Likes