It didn't keep the constraints to begin with, but I figured that out eventually. This is what I ended up with that worked:
ThisAssembly.BeginManage
If Driving_parameter = 1 ul Then
Nut_dim = "M8"
Washer_dim = 8
Nut_Name = "ISO 4032 M8:1"
Washer_name= "ISO 7089 8:1"
End If
If Driving_parameter = 2 ul Then
Nut_dim = "M10"
Washer_dim = 10
Nut_Name = "ISO 4032 M10:1"
Washer_name= "ISO 7089 10:1"
End If
If Driving_parameter = 3 ul Then
Nut_dim = "M12"
Washer_dim = 12
Nut_Name = "ISO 4032 M12:1"
Washer_name= "ISO 7089 12:1"
End If
If Driving_parameter = 4 ul Then
Nut_dim = "M16"
Washer_dim = 16
Nut_Name = "ISO 4032 M16:1"
Washer_name= "ISO 7089 16:1"
End If
If Driving_parameter = 5 ul Then
Nut_dim = "M20"
Washer_dim = 20
Nut_Name = "ISO 4032 M20:1"
Washer_name= "ISO 7089 20:1"
End If
Dim ISO_4032_M8_1_0Pos = ThisAssembly.Geometry.Matrix(0, 0, -1, 0,
0, 1, 0, 0,
1, 0, 0, -12,
0, 0, 0, 1)
Dim ISO_4032_M8_1_0 = Components.AddContentCenterPart(Nut_Name,
"LMV komponenter:Nuts:Hex",
"ISO 4032",
Nut_dim,
ISO_4032_M8_1_0Pos)
Dim ISO_7089_8_1_0Pos = ThisAssembly.Geometry.Matrix(0, -1, 0, 0,
0, 0, 1, 0,
-1, 0, 0, -12,
0, 0, 0, 1)
Dim ISO_7089_8_1_0 = Components.AddContentCenterPart(Washer_name,
"LMV komponenter:Diverse:Plain",
"ISO 7089", Washer_dim,
ISO_7089_8_1_0Pos)
offset=headheight+Parameter(Nut_Name, "d1")+2
Constraints.AddMate("Mate:1", Nut_Name, "Proxy:Face2", "",
"Z Axis",
e1InferredType := InferredTypeEnum.kInferredLine,
e2InferredType := InferredTypeEnum.kNoInference,
solutionType := MateConstraintSolutionTypeEnum.kAlignedSolutionType)
Constraints.AddFlush("Flush:1", Nut_Name, "YZ Plane", "",
"XY Plane", offset)
Constraints.AddByiMates("Insert:2", Washer_name, "Insert In1",
Nut_Name, "Insert Back1")
ThisAssembly.EndManage