2 Replies Latest reply on Jan 21, 2013 8:38 AM by D. L

    ReplaceReference Method (ISwDMDocument) not work correctly

    D. L

      good morning everyone,


      i have a problem with the replace function of the document manager api.


      i use the the following code for replacing references:


        public static void SetReferences(SWDocument document)


                  _factory =





                  if (_factory != null)

                      _application =




                  if (_factory == null || _application == null)




                      _document = (ISwDMDocument13)_application.GetDocument(document.Destination, _type, false, out _errors);




                  if (_document == null)





                  var r = _document.GetAllExternalReferences(_application.GetSearchOptionObject());



                  if (r == null)


                      foreach (var result in document.Children)


                          _document.ReplaceReference(result.Source, result.Destination);





                      foreach (var result in (new List<string>(r)))


                          var find = document.Children.Find(x => x.Source.ToLower() == result.ToLower() || x.Destination.ToLower() == result.ToLower());



                          if (find == null)




                          _document.ReplaceReference(result, find.Destination);






                  _factory = null;

                  _application = null;

                  _document = null;



      when i tried to replace a reference on a sw part then it works correctly. but when i try to replace a din part reference it not work.


      ..\SolidWorks Data\browser\DIN\bolts and screws\socket set screw cone point_din.sldprt (original reference)


      should replace to


      ..\Temp\temp_socket set screw cone point_din


      it is the same part but with different filename.


      can anyone help me?