Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Change value in part list

tcaG6GZK
Contributor

Change value in part list

tcaG6GZK
Contributor
Contributor

Hello

 

to "crack" a content center profile in an assembly i have this ilogic routine:

 

Sub Main()
Dim asmDoc As AssemblyDocument = ThisDoc.Document
BU2Each(asmDoc)
End Sub
Sub BU2Each(ByVal asm As AssemblyDocument)
	For Each oRefDoc As Document In asm.AllReferencedDocuments
		If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject AndAlso asm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count > 0
			If oRefDoc.PropertySets.PropertySetExists("ContentCenter")
				Try
					oRefDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)
				Catch
				End Try
			End If
		End If
	Next
End Sub

 but now i want another one - with the same function - but instead of "each" there should be the variable "B_L"

can someone pls. tell me how this value needs to be??

 

thx in advance

TC

0 Likes
Reply
Accepted solutions (1)
435 Views
6 Replies
Replies (6)

dalton98
Collaborator
Collaborator

In order for a parts list row to show up, its value has to be in the custom properties tab

daltonparrish_0-1651579830041.png

This can be done manually in the 'Parameters' > check the box 'Export Parameter' > right click to customize

Replace this code with the one in your try/catch:

Dim paramBL As Inventor.Parameter
paramBL = oRefDoc.ComponentDefinition.Parameters.Item("B_L")
paramBL.ExposedAsProperty = True

'paramBL.CustomPropertyFormat.PropertyType = kTextPropertyType
'parambl.CustomPropertyFormat.ShowUnitsString = False

'paramBL.CustomPropertyFormat.PropertyType = kNumberPropertyType

 

0 Likes

tcaG6GZK
Contributor
Contributor

you mean this??

Sub Main()
Dim asmDoc As AssemblyDocument = ThisDoc.Document
BU2Each(asmDoc)
End Sub
Sub BU2Each(ByVal asm As AssemblyDocument)
	For Each oRefDoc As Document In asm.AllReferencedDocuments
		If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject AndAlso asm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count > 0
			If oRefDoc.PropertySets.PropertySetExists("ContentCenter")
				Try
					Dim paramBL As Inventor.Parameter
					paramBL = oRefDoc.ComponentDefinition.Parameters.Item("B_L")
					paramBL.ExposedAsProperty = True

					'paramBL.CustomPropertyFormat.PropertyType = kTextPropertyType
					'parambl.CustomPropertyFormat.ShowUnitsString = False

					'paramBL.CustomPropertyFormat.PropertyType = kNumberPropertyType
				Catch
				End Try
			End If
		End If
	Next
End Sub

I´m sorry but it does not work..... :disappointed_face:

0 Likes

dalton98
Collaborator
Collaborator

Does it create a custom iproperty value called "B_L" in that part? Thats what I was trying to get it to do

0 Likes

tcaG6GZK
Contributor
Contributor

the value B_L already exists

i want to change the value "each" into "B_L" or better "G_L" (its existing also)

thx

0 Likes

dalton98
Collaborator
Collaborator

I know it already exists but in order to pass it to the custom iproperties tab and then to a parts list/BOM you have to export it. If you want to use "G_L" you wouldn't need to use any code unless you want to get rid of the unit string or change the dimension to fractions.

 

There are two ways to add "G_L" to the parts list...

1. Change parts lists through style editor

Styles Editor > Parts List > Column Chooser > New > 'G_L'

Then save the style editor and do Yes to 'Save to Library?'

This way it will always show up in parts lists you create

 

2. You can manually add it by by double clicking on the parts list and following the same steps above

0 Likes

tcaG6GZK
Contributor
Contributor
Accepted solution

Hello all!

 thx for everything - but i have the solution

 


Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

Dim oOcc As ComponentOccurrence
For Each oOcc In oDoc.ComponentDefinition.Occurrences
oPartDoc = oOcc.Definition.Document
Try
'try to get the value of the parameter
Dim sName As String
sName = "G_L"
oValue = oPartDoc.ComponentDefinition.Parameters.Item(sName).Value
'i = MessageBox.Show(oValue, "Mein iLogic-Dialogfeld", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)

p = oPartDoc.ComponentDefinition.Parameters.UserParameters.Item(sName)
oPartDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kParameterBOMQuantity, p)

Catch
End Try

Next

 

Thx for everything

Tom

0 Likes