Search code examples
vbacatia

how do i get the value of a parameter in a CATDrawing and edit it


I want to be able to get the value of the parameter CATDWG_SH_NO. and add the value of Totalsheets1 to it. So the final strparam1.Value will give me the total of the 2 mentioned before. The code I have right now only updated the parameter value to the totalsheets1 value. Another issue I faced was that the code will only update the value when the value existed in the parameters multiple value drop-down list, i.e. if the value 10 was not inside the drop-down list, it will fail to update the parameter. Any help will be appreciated. Thank you.

Function SheetNoUpdate(odoc As Document)

Dim parameters1 As Parameters

Set parameters1 = odoc.Parameters

Set strparam1 = parameters1.Item("CATDWG_REV")
strparam1.Value = "A"
Set strparam1 = parameters1.Item("CATDWG_SH_NO.")
strparam1.Value = Totalsheets1.Value

End Function

Solution

  • I'm not sure if I interpret you question correct: If you like to add the values try:

    strparam1.Value = strparam1.Value + Totalsheets1.Value
    'or if both are strings
    strparam1.Value = CStr(CInt(strparam1.Value) + CInt(Totalsheets1.Value))
    

    Or do you want to create a formula?
    On an multi-value parameter you can get the values (array) with GetEnumerateValues and SetEnumerateValues to assign an array.