Hi @WIRMNS. Below is an example iLogic rule which includes a custom Sub routine just for the task of copying the 'Custom' PropertySet from one document to another document. It is currently opening another document, then copying the custom properties from that document to the current document, then updating and saving the current document, but that part can be changed as needed. This is also a fairly basic example routine, and would likely need to be developed further for dealing with more complex scenarios, such as with referenced documents within a large assembly where multiple ModelStates are being used within the components.
If any of the properties in the source PropertySet is not already present in the destination PropertySet, it will be created, and if it already exists, its value will be changed. However, this method will not delete any already existing properties in the destination PropertySet that have different names than the ones in the source PropertySet. If that deletion functionality is needed, we would need to delete all existing properties from the destination PropertySet before copying the properties to it from the source.
Sub Main
Dim oThisDoc As Document = ThisDoc.Document
Dim oOtherDoc As Document = ThisApplication.Documents.Open("C:\Temp\OtherDoc.ipt")
CopyCustomPropertySet(oOtherDoc, oThisDoc)
If oThisDoc.RequiresUpdate Then oThisDoc.Update2(True)
If oThisDoc.Dirty Then oThisDoc.Save
oOtherDoc.Close(True) 'True = skip save
End Sub
Sub CopyCustomPropertySet(oFromDoc As Document, oToDoc As Document)
If oFromDoc Is Nothing OrElse oToDoc Is Nothing OrElse oToDoc.IsModifiable = False Then Return
Dim oFromSet As PropertySet = oFromDoc.PropertySets.Item(4)
If oFromSet.Count = 0 Then Return
Dim oIDs() As Integer = {}
Dim oNames() As String = {}
Dim oValues() As Object = {}
Try : oFromSet.GetPropertyInfo(oIDs, oNames, oValues) : Catch : End Try
If oNames Is Nothing OrElse oNames.Length = 0 Then Return
Dim oToSet As PropertySet = oToDoc.PropertySets.Item(4)
Try
oToSet.SetPropertyValues(oNames, oValues)
Catch oEx As Exception
Logger.Error("Error copying 'Custom' PropertySet from: " & vbCrLf & _
oFromDoc.FullDocumentName & vbCrLf & _
"To: " & vbCrLf & _
oToDoc.FullDocumentName)
End Try
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)