The solution I'm importing IO tags is to use .xml files
Its advantage is that it can access and set the properties of IO tags, such as IO tagstable's name, datatypename, externalaccessible, externalvisible, externalwritable, logicaladdress, tagName, comment.
For Example .xml
<?xml version="1.0" encoding="utf-8"?>
<Document>
<Engineering version="V16" />
<SW.Tags.PlcTagTable ID="0">
<AttributeList>
<Name>IO Table</Name>
</AttributeList>
<ObjectList>
<SW.Tags.PlcTag ID="1" CompositionName="Tags">
<AttributeList>
<DataTypeName>Bool</DataTypeName>
<ExternalAccessible>true</ExternalAccessible>
<ExternalVisible>true</ExternalVisible>
<ExternalWritable>true</ExternalWritable>
<LogicalAddress>%I0.0</LogicalAddress>
<Name>Tag</Name>
</AttributeList>
<ObjectList>
<MultilingualText ID="2" CompositionName="Comment">
<ObjectList>
<MultilingualTextItem ID="3" CompositionName="Items">
<AttributeList>
<Culture>en-US</Culture>
<Text>Tag</Text>
</AttributeList>
</MultilingualTextItem>
</ObjectList>
</MultilingualText>
</ObjectList>
</SW.Tags.PlcTag>
</ObjectList>
</SW.Tags.PlcTagTable>
</Document>
You only need to modify the tags attribute in. XML, including the ID value. For example, first tag ID = 1, and the second tag ID = 2.ID's value is not repeatable!
For Example .cs
var fileInfo = new FileInfo(@"IO MAP.xml");
SoftwareContainer softwareContainer = Project.Devices[0].DeviceItems[1].GetService<SoftwareContainer>();
Software softwareBase = softwareContainer.Software;
PlcSoftware plcSoftware = softwareBase as PlcSoftware;
PlcTagTableGroup PlcTagTableGroup = plcSoftware.TagTableGroup;
PlcTagTableGroup.TagTables.Import(fileInfo, ImportOptions.Override);
You only need to modify the target of SoftwareContainer , which depends on the PLC model you use, in the case of s7-1516.
If you have any questions, please contact me。