Method: AddProperties for Properties <Data>
- Updated2024-09-12
- 2 minute(s) read
Internal Data > Methods > Method: AddProperties for Properties <Data>
Method: AddProperties for Properties <Data>
Adds copies of existing properties to the properties of an element (root, channel group, or channel), in the script interface for internal data.
Object.AddProperties(Properties, Prefix)
Object | Properties <Data> Object with this method |
Properties | Properties <Data> Specifies which properties to copy. |
Prefix | Variant Specifies which prefix DIAdem adds in the Data Portal to the name of the copied properties. |
![]() | Note If the property with the specified name exists, DIAdem does not overwrite this property but retains the original property including its value. |
The following example adds the properties of the first channel group to the properties of the first channel of the second channel group. The example does not overwrite existing properties:
VBScript | Python |
Dim oMyProperties, oMyChannel Set oMyProperties = Data.Root.ChannelGroups(1).Properties Set oMyChannel = Data.Root.ChannelGroups(2).Channels(1) Call oMyChannel.Properties.AddProperties(oMyProperties)
The following example adds the properties of the first channel group to the properties of the first channel of the second channel group and overwrites any existing properties:
VBScript | Python |
Dim oMySourceProperties, oMyDestinationChn Set oMySourceProperties = Data.Root.ChannelGroups(1).Properties Set oMyDestinationChn = Data.Root.ChannelGroups(2).Channels(1) Call AddOverwriteProperties(oMySourceProperties, oMyDestinationChn) Sub AddOverwriteProperties(oSourceProperties, oDestinationChn) Dim oDestinationProperties, oProperty, PropertyName Set oDestinationProperties = oDestinationChn.Properties For Each oProperty in oSourceProperties PropertyName = oProperty.Name If oDestinationProperties.Exists(PropertyName) Then If (oProperty.DataType = oDestinationProperties(PropertyName).DataType) Then Call oDestinationProperties.Add(oProperty.Name, oProperty.Value) Else Call MsgBox ("Please change the datatype of the property: " & PropertyName) End If Else Call oDestinationProperties.Add(oProperty.Name, oProperty.Value) End If Next End Sub