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

Change value in part list

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

dalton98
in reply to: tcaG6GZK

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

 

tcaG6GZK
in reply to: dalton98

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:

dalton98
in reply to: tcaG6GZK

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

tcaG6GZK
in reply to: tcaG6GZK

the value B_L already exists

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

thx

dalton98
in reply to: tcaG6GZK

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

tcaG6GZK
in reply to: tcaG6GZK

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