/// <summary> /// Copy port to target element. It port exists it don't copy it. The Ports are locked against changes. /// Note: hoTools don't copy tagged values /// </summary> /// <param name="rep"></param> /// <param name="srcPort"></param> /// <param name="trgEl"></param> public static void CopyPort(EA.Repository rep, Element srcPort, Element trgEl) { bool isUpdated = false; if (srcPort.Type != "Port") { return; } // check if port already exits foreach (Element trgtPort in trgEl.EmbeddedElements) { // the target port already exists in source (Target Port PDATA3 contains ea_guid of source port the port is dependant from) if (srcPort.ElementGUID == trgtPort.MiscData[2]) { isUpdated = true; break; } } // Source port isn't available in target Part if (isUpdated == false) { // Create new Port and set the properties according to source port var newPort = (Element)trgEl.EmbeddedElements.AddNew(srcPort.Name, "Port"); trgEl.EmbeddedElements.Refresh(); newPort.Stereotype = srcPort.Stereotype; newPort.Notes = srcPort.Notes; newPort.PropertyType = srcPort.PropertyType; newPort.Update(); // Link Port to the source Port of property type HoUtil.SetElementPdata3(rep, newPort, srcPort.ElementGUID); //newPort.Locked = true; } }