1 Reply Latest reply on Jul 7, 2016 7:14 PM by Viktor Bovzdarenko

    Comparing Custom Properties

    Jean-Baptiste Bouckaert

      Hi, I'm writing a macro to edit the custom properties in a drawing.


      These custom properties can vary from drawing to drawing so I made a few documents, one for each possible combination of properties. Now I'd like to write a macro with wich I can read wich properties are present in the "standardized" document and then compare these to the original document and delete what I don't need and I add what I do need. I don't really know where to start from here.


      I'm kinda thinking it has something to do with


         ' For each custom property, print its type, value, and resolved value

          For j = 0 To nNbrProps - 1

              lRetVal = cusPropMgr.GetAll2(vPropNames, vPropTypes, vPropValues, resolved)

              custPropType = cusPropMgr.GetType2(vPropNames(j))

              Debug.Print "    Name, swCustomInfoType_e value, and resolved value:  " & vPropNames(j) & ", "; custPropType & ", " & ResolvedValOut

          Next j


      As explained in the article: 2014 SOLIDWORKS API Help - Get Custom Properties for Configuration Example (VBA)


      But I really don't know for sure.



        • Re: Comparing Custom Properties
          Viktor Bovzdarenko

          Hi Jean

          You are definitely on the right track

          I'd get the names of properties for your template drawing : lRetVal = cusPropMgr.GetAll2(vTEMPLATEPropNames, vPropTypes, vPropValues, resolved)

          names of properties for your active drawing : lRetVal = cusPropMgr.GetAll2(vACTIVEPropNames, vPropTypes, vPropValues, resolved)

          and make a double loop and get two collections of names of properties. One is to add to your active drawing and another to delete from your active drawing:

          For i= 0 To UBound(vACTIVEPropNames)

               For j = 0 To UBound(vTEMPLATEPropNames)

                         'compare names here

                         If vACTIVEPropNames(i) = vTEMPLATEPropNames(j ) Then


                         End If

               Next j

                    'if none of the names matched then add to collection to remove the property

          Next i