I have the exact same issue. This macro is NOT working. It should replace block20.sldprt with bagel.sldprt, but is not doing anything. Hope somebody from SolidWorks API Support can review this.
I even try to change "Assem20-3@Drawing View1/block20-1@assem20" to "Assem20-3@Drawing View1" to select assembly only but is not working either
I can check it tomorrow only as I'm about to sleep.
I contacted email@example.com and they found an error on this example. They sent me a correction, i haven't tested yet, but i assume it should work now.
Sorry about the issue with that help example. I opened SPR 818790 to modify the example by our documentation team. We will try to get that into the next service pack of SolidWorks 2014.
Here is the code as it should be:
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim draw As SldWorks.DrawingDoc
Dim selMgr As SldWorks.SelectionMgr
Dim vViews As Variant
Dim viewArray(0) As Object
Dim vInstances As Variant
Dim InstanceArray(0) As Object
Dim boolstatus As Boolean
Dim drComp As SldWorks.DrawingComponent
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set draw = Part
boolstatus = Part.ActivateView("Drawing View1")
' Select the view in which to replace the model
boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Set selMgr = Part.SelectionManager
Set viewArray(0) = selMgr.GetSelectedObject6(1, -1)
vViews = viewArray
' Select the instance of the model to replace
boolstatus = Part.Extension.SelectByID2("Assem20-3@Drawing View1/block20-1@assem20", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Set InstanceArray(0) = selMgr.GetSelectedObject6(1, -1)
Set drComp = InstanceArray(0)
Set InstanceArray(0) = drComp.Component
vInstances = InstanceArray
boolstatus = draw.ReplaceViewModel("C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\samples\tutorial\api\bagel.sldprt", (vViews), (vInstances))
I hope this helps.
Sr. API Support Engineer
Dassault Systèmes SolidWorks Corp.
Great, thanks for sharing