The documentation for the tree nodes and the tree node manager is basically non existent! It seems that it offers some powerful functionality but a decent understand of what it does and how it works alludes me. I am going to investigate it and experiment as much i can; findings to follow. In the mean time if anyone has any examples or knowledge of the matter a post would be much appreciated!
The only links of any use I can find are:
Some nice but limited examples: https://forum.oberonplace.com/showthread.php?t=6823
Wiki Page on the tree data structure: https://en.wikipedia.org/wiki/Tree_(data_structure) (Not sure how relevant this is)
My goal is to make a function that reduces the undo steps on long operations by moving the shapes to a temp document, doing its thing then bringing the shapes back to the original
document and replacing the original shapes with the processed ones. Effectively making a undo with 1000's of steps into one shape swap. I think their might be value in tree nodes, the tree node manger and virtual shapes.
Thanks
While doing some experimentation I came across a bug (?) that kinda makes the original idea useless
After running the macro the newly processed shapes are not logged on the undo history and if I do go back an undo corel crashes completely when I try to close the document down.
Any ideas why this is? (code below)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
Sub MoveToNewDoc() Dim S1 As Shape, S2 As Shape Dim SR1 As ShapeRange, SR2 As ShapeRange Dim CDoc As Document, NDoc As Document Dim TNode As TreeNode Dim I As Integer Set CDoc = ActiveDocument CDoc.BeginCommandGroup "TEST" CDoc.SaveSettings CDoc.PreserveSelection = False EventsEnabled = False Set SR1 = ActiveSelectionRange Set NDoc = SR1.CreateDocumentFrom(False) 'Tempdocs are useless? SR1.Delete 'Purge Old files Set SR2 = NDoc.SelectableShapes.All 'Process every shape on the new document: For I = 1 To SR2.Shapes.Count Set S1 = SR2(I) 'Do Your Tang to the Shape: S1.Fill.UniformColor.CMYKAssign 50, 50, 0, 0 S1.Rotate 90 'Post changes return to document: Set TNode = S1.TreeNode.GetCopy With TNode .UnLink .LinkAsChildOf CDoc.ActivePage.ActiveLayer.TreeNode SR1.Add .Shape End With Set S1 = Nothing: Set TNode = Nothing Next I SR2.Delete: Set SR2 = Nothing Set SR1 = Nothing NDoc.Close: Set NDoc = Nothing CDoc.Activate CDoc.PreserveSelection = True CDoc.RestoreSettings EventsEnabled = True Application.Refresh ActiveWindow.Refresh Set CDoc = Nothing End Sub