Samples | PLC Adding references The ITcPlcLibraryManager class provides two methods for adding a library or placeholder reference to a PLC project: AddLibrary() and AddPlaceholder() . A library can be added by specifying the library name, version, and distributor, or by using the library's display name. Adding libraries C#: ITcSmTreeItem references = systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References "); ITcPlcLibraryManager libManager = (ITcPlcLibraryManager) references; libManager.AddLibrary("Tc2_MDP", "*", "Beckhoff Automation GmbH"); // name, version, distributor libManager.AddLibrary("Tc2_Math, * (Beckhoff Automation GmbH)"); // display name PowerShell:
$references = $systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References") $references.AddLibrary("Tc2_MDP", "*", "Beckhoff Automation GmbH") $references.AddLibrary("Tc2_Math, * (Beckhoff Automation GmbH)") Adding placeholders C#: ITcSmTreeItem references = systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References "); ITcPlcLibraryManager libManager = (ITcPlcLibraryManager) references; libManager.AddPlaceholder("Tc2_MC2_Camming"); // add existing placeholder by name libManager.AddPlaceholder("Placeholder_NC", "Tc2_NC", "*", "Beckhoff Automation GmbH"); PowerShell:
$references = $systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References") $references.AddPlaceholder("Tc2_MC2_Camming") $references.AddPlaceholder("Placeholder_NC", "Tc2_NC", "*", "Beckhoff Automation GmbH") Removing references To remove a reference, use the ITcPlcLibraryManager::RemoveReference() method. C#: ITcSmTreeItem references = systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References "); ITcPlcLibraryManager libManager = (ITcPlcLibraryManager) references; libManager.RemoveReference("Tc2_Math"); // remove library libManager.RemoveReference("Placeholder_NC"); // remove placeholder PowerShell:
$references = $systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References") $references.RemoveReference("Tc2_Math") $references.RemoveReference("Placeholder_NC") Finding available libraries To search the system for all available PLC libraries, use the ITcPlcLibraryManager::ScanLibraries() method. C#: ITcSmTreeItem references = systemManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References "); ITcPlcLibraryManager libManager = (ITcPlcLibraryManager) references; ITcPlcReferences libraries = libManager.ScanLibraries(); foreach(ITcPlcLibrary library in libraries) { // do something } PowerShell: TE1000 243 Version: 1.7.0