cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Problem with creating/modifying parameter with VBA

cstarnes
12-Amethyst

Problem with creating/modifying parameter with VBA

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

...

...


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
0 REPLIES 0
Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags