The follwing snippet shows how to perform a replace to next version for a part using the SystemWeaver API.


IswLibrary library = SWConnection.Instance.Broker.GetLibrary(SWHandleUtility.ToHandle("x13000000000DEFA0"));

// Create a Component
IswItem component = library.CreateItem("ARAP", "Component");

// Create an Interface
IswItem interfaceItemVersion1 = library.CreateItem("ARSI", "Interface");

// Release an Interface
interfaceItemVersion1.Status = SWItemStatus.Released;

// Create the Part with SID="ARRP" on component that points to interfaceItem. AddPart is used when Part multiplicity is *
IswPart receivePort = component.AddPart("ARRP", interfaceItemVersion1);

// Create a new version of the interface
IswItem interfaceItemVersion2 = interfaceItemVersion1.NewVersion();

// Update the component's interface to the next version
receivePort.DefObj = interfaceItemVersion2;