0 Replies Latest reply on Jul 23, 2015 1:02 PM by MD Afzalul Karim

    Replace reference drawing with new part

    MD Afzalul Karim

      Hi,

       

      I am new in solidowrks api.I want to create a macro which will create new solidworks drawing from an existing drawing document having all the dimensions and views as like as in reference document.I use "replacereferncedocument"  in my macro but it does not works.I created a part and make a drawing from that.Than I create another part and want similar drawing like the previous one using my macro.Here is my macro:

       

      ------replace drawing with new model------

       

       

      Option Explicit

      Const sReferencingDoc       As String = "K:\Product Lines\SolidWorks Automation\Automation Library\block1_a.slddrw"

      Const sOldDoc               As String = "K:\Product Lines\SolidWorks Automation\Automation Library\block1_a.sldprt"

      Const sNewDoc               As String = "K:\Product Lines\SolidWorks Automation\Automation Library\block2_a.sldprt"

      Sub main()

         Dim swApp               As solidworks.solidworks

         Dim bRet                As Boolean

              Set swApp = CreateObject("SldWorks.Application")

              bRet = swApp.ReplaceReferencedDocument(sReferencingDoc, sOldDoc, sNewDoc)

              Debug.Print bRet

      End Sub

       

      ---------------------

       

      But it seems not working.Please can anyone help me to find out the problem?