@gildas.lincot have a try of this (code below). I was having issues unless I explicity named the parameters as belonging to the flat pattern but this seems to work.
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oDoc.ComponentDefinition
Dim oUserP As UserParameter
If oSMDef.FlatPattern Is Nothing Then
'tell the user there is no flat pattern
MessageBox.Show("This file has no flat pattern", "iLogic")
Else
oSMDef.FlatPattern.Edit
Try
t = oSMDef.FlatPattern.Parameters.UserParameters.Item("FileStatus")
oSMDef.FlatPattern.Parameters.UserParameters.Item("FileStatus").Value = iProperties.Value("Project", "Part Number") & " - " & iProperties.Value("Project", "Revision Number")
Catch ' create parameter
oUserP = oSMDef.FlatPattern.Parameters.UserParameters.AddByValue("FileStatus",iProperties.Value("Project", "Part Number") & " - " & iProperties.Value("Project", "Revision Number"),kTextUnits)
End Try
'oSMDef.FlatPattern.ExitEdit
End If
It will check if there is a flat pattern. The parameter created is called "FileStatus"
Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399