2 Replies Latest reply on Jan 12, 2015 2:05 AM by Josemi Antelo

    ICustomPropertyManager::Get5 Don't works

    Josemi Antelo

      Hello

       

         I'm trying to use ICustomPropertyManager::Get5 but don't Works.

         To you it Works?

       

         Could you pass me an example?

       

      I use VS2013 C++

       

      Many thanks in advance

        • Re: ICustomPropertyManager::Get5 Don't works
          Keith Rice

          Josemi,

           

          Not many people here use C++ with the API, so it would be best if you clarified which of these is your problem:

           

          1. I do not know how to use ICustomPropertyManager::Get5 at all, in any language.

          2. I am able to use ICustomPropertyManager::Get5 in VBA (or some other language), but I am not able to get it to work in C++.

           

          I don't have time right now to set up a stand-alone to verify #2, but as for #1, here is how you would use it in a C# macro:

           

          using SolidWorks.Interop.sldworks;
          using SolidWorks.Interop.swconst;
          using System.Runtime.InteropServices;
          using System.Diagnostics;
          
          namespace Macro1.csproj
          {
              public partial class SolidWorksMacro
              {
                  public void Main()
                  {
                      ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;
                      CustomPropertyManager swCustPropMgr = swModel.Extension.get_CustomPropertyManager(null);
                      string valOut;
                      string resolvedValOut;
                      bool wasResolved;
                      swCustPropMgr.Get5("Revision", false, out valOut, out resolvedValOut, out wasResolved);
                      Debug.Print("Value: " + valOut + System.Environment.NewLine +
                                        "Resolved value: " + resolvedValOut + System.Environment.NewLine +
                                        "Was the value evaluated? " + wasResolved.ToString());
                  }
          
                  public SldWorks swApp;
              }
          }
          

           

          Note that this method uses "out" arguments, meaning that information is given back to you rather than you passing information in. Basically, it allows a function to return multiple values without having to use a string array.

           

          Explanation of arguments:

           

          The "value" and the "resolved value" correspond to these two highlighted boxes in the custom properties dialog in the UI:

           

           

          Notice that for Material, the value and the evaluated value are different.

           

          As for the "wasResolved" out argument, this indicates whether the value successfully evaluated.

           

          Keith

          SolidWorks API Tutorials

            • Re: ICustomPropertyManager::Get5 Don't works
              Josemi Antelo

              Hi Keith

              First of all, thank you very much for answering my question.

              The question, really, is that in C ++ the Get5 does not work and wanted to know if there was someone who worked him. The output parameters are (BSRT *) and as much as I've tried, the function aborts. I sincerely believe that the problem is Solidworks. In the end I had to use the obsolete function Get.

               

              Yours sincerely

              Josemi