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

@_bmiller_ 

 

Do you truly need the parameters, or are they being created just to get the information into iProperties?

 

If you don't need them you can do something like this example:

 

' Loop through all components in the active assembly
For Each comp As ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences
	' Check if the component occurrence is a part document and a sheet metal part
	If Not comp.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then Continue For
		
	Dim partDoc As PartDocument = comp.Definition.Document

	If Not partDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For' Check if sheet metal part

	Dim oCompDef As SheetMetalComponentDefinition = partDoc.ComponentDefinition

	If oCompDef.HasFlatPattern = False Then
		oCompDef.Unfold
		oCompDef.FlatPattern.ExitEdit
	End If

	iProperties.Value(comp.Name, "Custom", "DIMA") = "=<Sheet Metal Length>"
	iProperties.Value(comp.Name, "Custom", "DIMB") = "=<Sheet Metal Width>"

Next

 

 

If you do need the parameters, you can do something like this example:

 

' Loop through all components in the active assembly
For Each comp As ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences
	' Check if the component occurrence is a part document and a sheet metal part
	If Not comp.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then Continue For

	Dim partDoc As PartDocument = comp.Definition.Document

	If Not partDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For' Check if sheet metal part

	Dim oCompDef As SheetMetalComponentDefinition = partDoc.ComponentDefinition

	If oCompDef.HasFlatPattern = False Then
		oCompDef.Unfold
		oCompDef.FlatPattern.ExitEdit
	End If
	
	oFlat_Length = oCompDef.FlatPattern.Length
	oFlat_Wdith = oCompDef.FlatPattern.Width

	' Get the parameters of the component definition
	Dim params As Parameters = oCompDef.Parameters

	' Check if parameters "DIMA" and "DIMB" exist, update or add them
	Try
		params.UserParameters.Item("DIMA").Value = oFlat_Length
	Catch
		params.UserParameters.AddByExpression("DIMA", oFlat_Length, "in")
	End Try
	Try
		params.UserParameters.Item("DIMB").Expression = oFlat_Wdith
	Catch
		params.UserParameters.AddByExpression("DIMB", oFlat_Wdith, "in")
	End Try

	' Set parameters to be exposed as properties
	params.Item("DIMA").ExposedAsProperty = True
	params.Item("DIMB").ExposedAsProperty = True

	iProperties.Value(comp.Name, "Custom", "DIMA") = "=<Sheet Metal Length>"
	iProperties.Value(comp.Name, "Custom", "DIMB") = "=<Sheet Metal Width>"

Next

' Update the active assembly after Parameter changes
ThisApplication.ActiveDocument.Update

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com