Message 1 of 2
iLogic user parameter + assembly issue

Not applicable
04-01-2021
10:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I have a piece of code that I would like to understand why it doesn't work.
The code should look for the parameter user parameter called "TypePiece", and if it doesn't find it, it should create it as a multivalue list. I modified the original code a tiny bit, because I would sometime have an error popping up when it was trying to populate an assembly document's user parameters, so I declared _Piece and _Asm as PartDocument and AssemblyDocument, to stop that error.
Now, It won't populate my assembly, but it does populate parts. Is there a reason? If so, how can I correct it please? Thanks!
Try
Parameter("TypePiece") = Parameter("TypePiece")
Catch
If _FichierType = "Pièce" Then
_Piece = ThisApplication.ActiveDocument
For Each oParam As UserParameter In _Piece.ComponentDefinition.Parameters.UserParameters
DefinitionParametre = _Piece.ComponentDefinition.Parameters.UserParameters
oTypePiece = oParam.Value
Try
Parameter("TypePiece") = Parameter("TypePiece")
Catch
ParametresPiece = DefinitionParametre.AddByValue("TypePiece", oTypePiece, UnitsTypeEnum.kTextUnits)
MultiValue.SetList("TypePiece", "Principale", "GalvPeint", "Securite", "Grillage", "Usinage", "TraySol", "Autre1", "Autre2", "Autre3", "Autre4", "NonPeint")
End Try
Next
Else If _FichierType = "Assemblage" Then
_Asm = ThisApplication.ActiveDocument
For Each oParam As UserParameter In _Asm.ComponentDefinition.Parameters.UserParameters
DefinitionParametre = _Asm.ComponentDefinition.Parameters.UserParameters
oTypePiece = oParam.Value
Try
Parameter("TypePiece") = Parameter("TypePiece")
Catch
ParametresPiece = DefinitionParametre.AddByValue("TypePiece", oTypePiece, UnitsTypeEnum.kTextUnits)
MultiValue.SetList("TypePiece", "Principale", "GalvPeint", "Securite", "Grillage", "Usinage", "TraySol", "Autre1", "Autre2", "Autre3", "Autre4", "NonPeint")
End Try
Next
End If
End Try