Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
I'm working on an Excel sheet that creates or updates parameters in all of the models in an assembly, but have a couple of issues.
1). How do I get, create, or change a parameter that belongs to an instance of a family table?
2). I can read and write some assembly parameters, but not all of them...even though I'm using the same code. For example, I can read an create/update a text parameter called "UPDATED", but not one called "PART_NUMBER"...even though they are both strings and both use the same code. The only thing I can think of is that the assembly in question belongs to an interchange assembly, but that doesn't explain why some parameters can be writeen and some can't.
EDIT: Also, I can't edit delete or modify the paramter in Creo either, even though it isn't used in a relation and is unlocked.
Here are some code snippets of what I'm doing:
' Get parameters
...
...
For i = 1 To (params.Count - 1)
Set param = params(i)
Set ParamValue = param.Value
Set ParamName = param
If ParamName.Name = "PART_NUMBER" Then .Cells(iRow, colOriginalPartNumber).Value = ParamValue.StringValue
...
...
Next i
' get material
If mdl.Type = EpfcModelType.EpfcMDL_PART Then
On Error Resume Next
Set part = mdl
Set material = part.CurrentMaterial
.Cells(iRow, colOriginalMaterial).Value = material.Name
...
...
' Update paramaters
...
...
' PART_NUMBER
NewPartNumber = .Cells(iRow, colNewPartNumber).Value
If chkUpdatePN And NewPartNumber <> "" Then
ParamName = "PART_NUMBER"
Set oModelItem = New CMpfcModelItem
Set oParamValue = oModelItem.CreateStringParamValue(NewPartNumber)
' Try to create the parameter. If it already exists, modify it
On Error Resume Next
Set oParam = oParamOwner.CreateParam(ParamName, oParamValue)
Set oParam = oParamOwner.GetParam(ParamName)
oParam.Value = oParamValue
On Error GoTo 0
End If
...
...