access assembly bom from part

access assembly bom from part

cadman777
Advisor Advisor
746 Views
6 Replies
Message 1 of 7

access assembly bom from part

cadman777
Advisor
Advisor

Hey guys,

I'm an ilogic hack job trying to cobble together an external rule that runs from within a part.

I can't figure out how to get the total quantity from the assembly bom that way.

Can you tell me if this is possible using ilogic?

If so, is it difficult?

If not, can you direct me to anything I can read to see how it's done?
Thanx!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Accepted solutions (1)
747 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor
Accepted solution

What I've seen others do is when the Assembly is open, use some code to push data from the BOM to custom iProperties (or similar) within the Parts/subassemblies.  This is best when the parts are only used within that one assembly.  If the parts are used in several assemblies, you might have to put assembly name/number in with the data you push to the parts.  Then from the part, it will know what assembly it is being used in by the custom iProperties.

There may be ways through Vault to reverse find what assemblies a part is being referenced in from the part, but other than that, I don't know of another easy way.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

cadman777
Advisor
Advisor

Thanx WC.

Maybe I wasn't clear enough.

I have a part open that occurs in a top-level assembly.

I need to access that top-level assembly to get the part's total quantity from the assembly bom.

The assembly is not open.

Any chance I can get that 'total quantity' from the assembly with the assembly not open?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

Here's a quickie code, for if you already have the file name of the assembly.

One way or another, I believe the Assembly will have to be opened to access its BOM data.

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition

Dim oFound As Boolean = False
Dim oADocName As String = "C:\Temp\Asembly.iam" 'or InputBox()
Dim oADoc As AssemblyDocument
For Each oRefDoc As Document In ThisApplication.Documents
	If oRefDoc.FullFileName = oADocName Then
		oADoc = oRefDoc
		oADoc.Activate
		oFound = True
	End If
Next
If oFound = False Then
	oADoc = ThisApplication.Documents.Open(oADocName, False)
End If
Dim oBOM As BOM = oADoc.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = True
Dim oStView As BOMView
For Each oBView As BOMView In oBOM.BOMViews
	If oBView.ViewType = BOMViewTypeEnum.kStructuredBOMViewType And
		oBView.Name = "Structured" Then
		oStView = oBView
	End If
Next
Dim oTQty As String
For Each oBRow As BOMRow In oStView.BOMRows
	If oBRow.ReferencedFileDescriptor.FullFileName = oPDoc.FullFileName Then
		oTQty = oBRow.TotalQuantity
	End If
Next
		

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

cadman777
Advisor
Advisor

Thanx.

Let me try it.

I just was reading how to check and push near iProps into parts from assembly.

Some of it was your contributions too.

So now I have a lot to work with to see if I can do this.

I don't mind pushing a custom  iProp into all the parts, so maybe I'll do that instead of trying to do it my way.

Every time I want to do something simple, it turns out to be something a C# programmer needs to write!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 6 of 7

cadman777
Advisor
Advisor

This is the best one I found:

https://forums.autodesk.com/t5/inventor-forum/ilogic-to-create-custom-iproperty-in-sub-component/td-...

It's BRILLIANT!

Now I have to add that to my main rule to extract that iProp and put it into the filename

The main Rule exports the sheetmetal flatpattern to DXF from within the PART file

But I needed the Total Quantity to show in the file name

There's probably 6 different forum posts that I clipped pieces off of to make this rule

Talk about a hack job!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 7 of 7

cadman777
Advisor
Advisor

WC,

Thanx for the useful idea!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes