22-11-2012 11:31 AM
Hi all,
related to my previous topic, I 'am looking for a solution to get "Current Diagram Name" in my macro
Context : my macro is triggered on DiagramTypelinkstyle Master Condition and depending on the return value (0/1)
I can apply or not a specific MetaPicture for each DiagramTypelink
Macro type :
Function MetaViewCheck(oObject As MegaObject, Ctx As Object) As Boolean
..............
to set relevant return value i need to get, amongst other things, "Current Diagram Name"
..............
End function
Thanks for your help
Rgds
Jacques
Solved! Go to Solution.
22-11-2012 04:13 PM
Lionel
Perfect. It's now clear about how to differentiate type of each Drawing object
Sorry, my intention is obviously to modify link aspect (not DiagramTypeLink)
Thanks to confirm that "macro is performed at diagram opening". Because I thought observing a conversely process but I'm doing others tests.
In any cases, Thanks for your help. I have now enough information to progress.
Bregds
Jacques
22-11-2012 03:40 PM
Hello Jacques,
the macro is already performed at diagram opening.
In any cases, it was not supposed to help you modify DiagramTypeLink, but to modify links yourself according to whatever condition you wanted (it was an alternative solution to what I thougt was your problem).
Concerning your last question, I had noticed that my modification was done for every object and not only for applications, so I edited and modified my post by adding the following :
If oDrawingobject.SegId = oDrawing.GetRoot.getObjectFromId("~MrUiM9B5iyM0[Application]").getId Then
Is that what you wanted ?
22-11-2012 03:20 PM - edited 22-11-2012 03:22 PM
--> To Lionel Mazurie
Hello dear namesake
I am afraid that triggering a macro on whatever modification you would do on a certain type of object is not possible.
The only thing you could do is create as many macros as how many metaAttributes can be modified by users.
Each macro will manage propertypage modifications on a specific metaAttribute (the macro is linked to your metaAttribute by the MetaAttributeUpdateTool link).
--> you can find examples of this kind of macros in the "Macro for an attribute updating the same attribute" topic.
Since I'm not sure if this really answers your question, please do not hesitate to tell me exactly what you need to do.
If you do so, please create a new topic
Regards,
Lionel
22-11-2012 02:50 PM
Hello Lionel,
very interesting post (I'm sure I will have furthur usages)
But for this situation it partially works .
It works for changing shape, color of DiagramTtypeObject.
However I still need to parameter link condition to modify DiagramTypeLink and unfortunately these conditions are performed BEFORE execution of our new Macro (Sub OnLoadDrawing)
Do you know if there's a possibility to" force" the new macro to perform in first (at diagram open)
My last question. In the new macro (Sub OnLoadDrawing), what will be the syntax to get Type of oDrawingObject
Thanks in advance
Jacques
22-11-2012 01:53 PM
Hello Lionel,
Just linked with this need / question have we got the same behaviour to trigger a macro when an instance of Metaclass is "opened" ?
I know to call a specific macro at the creation of an object but not at every event on the object except defining a rule associated with it (an highjacked way to do it !)
Thanks
Lionel
22-11-2012 12:36 PM - edited 22-11-2012 02:17 PM
Hello Jacques,
I might be wrong, but I do not think it is possible to retrieve the current diagramme name from your macro.
As this is related to your last post, I now understand better what you want to do and why my previous suggestion was useless.
But maybe running a macro each time you open a specific kind of diagram would be the solution ?
To do so, create a vbs macro in MEGA with the OnLoadDrawing Sub, and save it with a specific name :
'MegaContext(Fields,Types) 'Uses(Standard) 'Uses(Drawing) 'Uses(Components) 'Uses(Extensions) Option Explicit Sub OnLoadDrawing(oDrawing As MegaDrawing) End Sub
Then, in the properties of the DiagramTypeParam you want to work with, add a section [Macros] in which you will indicate 1=<IdAbsOfYourMacro> in the _Settings text attribute (you can also copy/paste your macro object instead of writing the absolute identifier) :
Your macro will be launched every time you open a diagram of the desired kind, which will allow you to do almost whatever you want (modifying shapes according to master application for example...). In the below example, it will modify the shape for all applications on the diagram.
'MegaContext(Fields,Types)
'Uses(Toolkit)
'Uses(Standard)
'Uses(Drawing)
'Uses(WEBAccess)
'Uses(WEBUtilities)
'Uses(CodeGeneration)
'Uses(ExchangeGeneration)
'Uses(Components)
'Uses(Extensions)
Option Explicit
Sub OnLoadDrawing(oDrawing As MegaDrawing)
dim oDrawingObject as MegaDrawingObject
For Each oDrawingObject in oDrawing.DrawingObjects
If oDrawingobject.SegId = oDrawing.GetRoot.getObjectFromId("~MrUiM9B5iyM0[Application]").getId Then
odrawingobject.Shape = "D:\program files\MEGA\Standard\Mega_usr\appl_spreadout.mgs"
End If
Next
End Sub
I hope that helps, even if I know that diagram APIs are not very simple to use
Lionel