I have been trying to use example in API help file to see how this works. Although I can do what is below as a user in SW, when I try the example equivalent (below) the code does seen to work. Both returns for selection come back true (although I don't know why the block20/part portion is required to select the Assembly above it), but the final call to ReplaceModelView always comes back false (although new doc load event fires). Anyone try this yet, and have experience or comments? Thanks in Advance.
============================= API Example =========================================
partial class SolidWorksMacro
{
ModelDoc2 Part;
DrawingDoc draw;
SelectionMgr selMgr;
object[] vViews = new object[1];
object[] vInstances = new object[1];
bool boolstatus;
public void Main()
{
Part = (ModelDoc2)swApp.ActiveDoc;
draw = (DrawingDoc)Part;
// Select the view in which to replace the model
boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);
selMgr = (SelectionMgr)Part.SelectionManager;
vViews[0] = selMgr.GetSelectedObject6(1, -1);
// 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, null, 0);
vInstances[0] = selMgr.GetSelectedObject6(1, -1);
boolstatus = draw.ReplaceViewModel("C:\\Program Files\\SolidWorks Corp\\SolidWorks\\samples\\tutorial\\api\\bagel.sldprt", vViews, vInstances);
}
}
}