We have been using following piece of code in order to generate application tree diagrams.
It has been working fine with MEGA 2009 SP2 CP3, but does not work anymore with MEGA 2009 SP5 CP6 Release Pack 6.
Link points positions are not saved correctly:
Set oApp1 = Application.Create Set oApp2 = oApp1.GetCollection("Composante").Create Set oDiagram = oApp1.GetCollection("Description").Create("Nature", "ARBRE-APPLICATIF") Set oDrawing = oDiagram.Drawing("RW") Set oAppItem1 = oDrawing.MegaObjectInsert(oApp1) Set oAppItem2 = oDrawing.MegaObjectInsert(oApp2) oAppItem1.SetPos 1000, 1000, 3000, 2000 oAppItem2.SetPos 4000, 4000, 6000, 5000 Set oTk = GetRoot.CurrentEnvironment.Toolkit For Each oLink In oDrawing.DrawingLinks If oTk.SameId(oLink.DirectLegId, "~isUijEB5i4M3[Composee]") Then Set oLinkItem = oLink.DrawingItem Set cLinePoints = oLinkItem.ItemProperty("DrwLine_Points") While cLinePoints.Count < 3 Call cLinePoints.InsertPointBefore(1,0,0) Wend While cLinePoints.Count > 3 Call cLinePoints.RemovePoint(3) Wend cLinePoints.Abscissa(0) = 2000 cLinePoints.Ordinate(0) = 2000 cLinePoints.Abscissa(1) = 2000 cLinePoints.Ordinate(1) = 4500 cLinePoints.Abscissa(2) = 4000 cLinePoints.Ordinate(2) = 4500 oLinkItem.ItemProperty("DrwLine_Points") = cLinePoints Set cLinePoints = oLinkItem.ItemProperty("DrwLine_Points") For iPoint = 0 To cLinePoints.Count - 1 Print cLinePoints.Abscissa(iPoint) & "," & cLinePoints.Ordinate(iPoint) Next Set cLinePoints = Nothing Set oLinkItem = Nothing End If Next Set oTk = Nothing Set oAppItem2 = Nothing Set oAppItem1 = Nothing oDrawing.Flush Set oDrawing = Nothing Set oDiagram = Nothing Set oApp2 = Nothing Set oApp1 = Nothing
Is there a way to fix that situation?
Solved! Go to Solution.
I confirm change of behaviour.
This issue has been escaladed to MEGA R&D for further investigation (CR 31423).
It has been qualified as a limit of the current platform.
After investigation, this appears to be a known issue.
No change is expected in a future version.
However it possible to secure the code by keeping in the collection the first and the last point.
See also http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=501D00000010cJBIAY
Thank you Jérôme,
Link positions are valid when keeping first and last default points.
I will adjust existing scripts in order to take that piece of advice into account.