iLogic transcription BOM item number of part to custom properties of same part

iLogic transcription BOM item number of part to custom properties of same part

Anonymous
Not applicable
1,800 Views
7 Replies
Message 1 of 8

iLogic transcription BOM item number of part to custom properties of same part

Anonymous
Not applicable

Hello all,

 

we would like see a position number of part in description of view in idw. My idea is write this number automaticly from assembly to all parts as custome properties and after that we can get this number to View description.


I maked some examples of code but every time the "program" write me only last position number from the BOM to properties of the main assembly.

 

 

I need something like "look on Item number & Part Number to BOM and write Item Number to "Custome properties" of part with exact Part Number. And make for all parts in Assembly."

 

 

Is there somebody who can help me with this?

 

Thank you,

Kind Regards,

Martin.

Accepted solutions (1)
1,801 Views
7 Replies
Replies (7)
Message 2 of 8

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

Are you looking for something like this?

It will create/edit a custom property named ItemNumber in your components based on the structured BOM-view 🙂

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oAsm.ComponentDefinition
Dim oBOM As BOM = oDef.BOM
oBOM.StructuredViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews(2) 'Structured View
For Each oRow As BOMRow In oBOMView.BOMRows
	For Each rDef As ComponentDefinition In oRow.ComponentDefinitions
		If TypeOf (rDef) Is VirtualComponentDefinition Then Continue For
		Try
			rDef.Document.PropertySets("Inventor User Defined Properties")("ItemNumber").Value = oRow.ItemNumber.ToString()
		Catch
			rDef.Document.PropertySets("Inventor User Defined Properties").Add(oRow.ItemNumber.ToString, "ItemNumber")
		End Try
	Next
Next
Message 3 of 8

Anonymous
Not applicable

@JhoelForshav  Thank you again! It is fantastic!

Message 4 of 8

istvan.ilg
Explorer
Explorer

Hi,

I tried this code, but I've got an error message:

 

Error in rule: ItemNumber, in document: Part6.ipt

Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.AssemblyDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D465-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

Could you help me?

 

Thanks

Istvan

0 Likes
Message 5 of 8

JhoelForshav
Mentor
Mentor

Hi @istvan.ilg 

That error message indicates that you're running the rule in a part document. The rule is written to be ran in the assembly containing all the parts 🙂

0 Likes
Message 6 of 8

istvan.ilg
Explorer
Explorer

Thank you very much!

I drugged the rule from parts. It works.

Could it work with 'Parts Only View' too?

0 Likes
Message 7 of 8

istvan.ilg
Explorer
Explorer

Thank you very much!

I drugged the rule from parts. It works.

Could it work with 'Parts Only View' too?

0 Likes
Message 8 of 8

Victor.Tuguinay
Enthusiast
Enthusiast

Hi JhoelForshav,

 

I am looking to have a modified version of your code to retrieve the item numbers of the parts that are in my sub assemblies and make a custom iproperty that list those item numbers. I will explain below.

 

So I have my main assembly with a number of subassemblies. Each of those subassemlies is composed of two parts - called "Flange" and "Pipe". I would like a "Flange Item" and "Pipe Item" custom iproperty created in each of the subassemblies. The value of these will be equal to the item number of the part as listed in the Part Only BOM view of the main assembly.

 

Can you please help me with this? Thanks in advance!

 

@JhoelForshav 

 

 

0 Likes