3 Replies Latest reply on Jul 11, 2018 2:20 AM by Gang S.

    how to break external reference via VBA

    Gang S.

      hi there! i got a problem when i import an UG part file into Solidworks.

      i want to break relationship up between UG and SW, i know i can right click the reference node then click "break link", but how should i do it via VBA or C#?  i have searched the API help, and find a method "BreakAllExternalFileReferences2 Method (IModelDocExtension)", but it doesn't work.

      give me some tips . thanks.

      S]`0QP}G)Y_59(KHGALEN}R.pngW4V6}B_[F(D5R{UG_4M4ESM.png

        • Re: how to break external reference via VBA
          Gang S.

          i have wrote The following scripts to test this puzzle , it doesn't work.

          public void Main()

                  {           

                      ModelDoc2 swDoc = null;

                      PartDoc swPart = null;

                      DrawingDoc swDrawing = null;

                      AssemblyDoc swAssembly = null;

                      bool boolstatus = false;

                      int longstatus = 0;

                      int longwarnings = 0;

                      //

                      // Open

                      swDoc = ((ModelDoc2)(swApp.OpenDoc6("C:\\Users\\Administrator\\Desktop\\123.SLDPRT", 1, 192, "", ref longstatus, ref longwarnings)));         

                      swDoc.Extension.BreakAllExternalFileReferences2(false);     //this method doesn't work no matter how i set the bool parameter to "ture" or "false".      

                

                  }

          • Re: how to break external reference via VBA
            Rob Edwards

            Hi Gang

             

            Try this method, it worked for me

            2016 SOLIDWORKS API Help - UpdateExternalFileReferences Method (IFeature)

             

             

            Here's a snip from my code

              • Re: how to break external reference via VBA
                Gang S.

                Hi Rob .

                Thank you for your help

                I tried the method you recommended, but it still doesn't work.

                the method "UpdateExternalFileReferences" is related to the UI command "List Ext Refs" -->"Break all " or "lock all ".like the figure illustrated.  it seems this method is valid for components and features, but valid for external third party Parts.

                1531289528(1).png