iLogic - Replace ITEM property with custom property

iLogic - Replace ITEM property with custom property

goran.jutrisa
Participant Participant
370 Views
4 Replies
Message 1 of 5

iLogic - Replace ITEM property with custom property

goran.jutrisa
Participant
Participant

Hello,

 

I have assembly made of parts and sub-assemblies and I would like to change all ITEM (property) numbers to be equal to my new predefined custom property POS for each part, sub-assembly, assembly.

Does anyone know the code for iLogic to change all ITEM number to be equal to custom property POS?

Thanks

 

Btw understanding what i am interested in see example below:

goranjutrisa_0-1626686505551.png

 

0 Likes
371 Views
4 Replies
Replies (4)
Message 2 of 5

JhoelForshav
Mentor
Mentor

Hi @goran.jutrisa 

Try this iLogic code. I think it's what youre looking for 🙂

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oBOM As BOM = oAsm.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
For Each oRow As BOMRow In oBOM.BOMViews.Item(3).BOMRows
	On Error Resume Next
	oRow.ItemNumber = oRow.ComponentDefinitions(1).Document.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")("Pos.").Value
Next

EDIT: I just saw it was the parts only view you were working on so I changed the code to handle that instead of structured as in my original post..

0 Likes
Message 3 of 5

goran.jutrisa
Participant
Participant

Thanks, i tried it but I am getting error message:

goranjutrisa_0-1626689436742.png

 

0 Likes
Message 4 of 5

goran.jutrisa
Participant
Participant

I am working in parts only view. but also I would like to have that ITEM is changed to Pos. in parts and in assemblies.

0 Likes
Message 5 of 5

JhoelForshav
Mentor
Mentor

@goran.jutrisa 

Seems like we need to enable both structured and parts only for it to work... I also added code to update both of these views.

Try this:

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oBOM As BOM = oAsm.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.PartsOnlyViewEnabled = True
For Each oRow As BOMRow In oBOM.BOMViews.Item(2).BOMRows
	On Error Resume Next
	oRow.ItemNumber = oRow.ComponentDefinitions(1).Document.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")("Pos.").Value
Next
For Each oRow As BOMRow In oBOM.BOMViews.Item(3).BOMRows
	On Error Resume Next
	oRow.ItemNumber = oRow.ComponentDefinitions(1).Document.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")("Pos.").Value
Next