I've written an VBS-macro in MEGA/HOPEX. This macro performs some actions on several class within a Package. Now I've been asked to create/add a similar project that does the same but only from a single class. I would like to reuse some functions that I use in the first script without just taking a copy of the original macro but I would like to create a macro with some shared functions. I would like to call these shared functions then in the original script and in the newly created script. Can someone tell me how to call these shared functions in a macro? I've tried the following but without success: Dim SharedFunctionsMacro
SharedFunctionsMacro = myRoot.GetObjectFromID("68146F565D9D3D76")
If SharedFunctionsMacro.Check_Association_composed(Report, aClass, True) = True Then
End If Where Check_Association_composed is a function in the shared script: Function Check_Association_composed(Report, aClass, bClassDiagramIteration)' As Boolean
End Function tnx...
... View more
Hi Jerome, thank you for the response. We will discuss the proposed solution. But given your answer that the name is changed to '(unitialised)' when the data type is changed, i've also tested another workaround: 'ExpressionType
if exptype.count = 1 then
aDuplicateAttribute.SetProp "Local Name", iAttr.GetProp("Local Name")' Reset the name after the attributes was connected to the TypeClass. This also works. So we will see what's the best solution for now. Kind regards, Jeroen.
... View more
***UPDATE*** ***UPDATE*** ***UPDATE*** The problem seems not to be with the function GetObjectFromIDn but with the MegaObjectType Diagram when the macro is called from within the VB.NET project: For testing purposes I've written a simple macro that makes collections of 2 types of MegaObjectTypes, macros and diagrams: myRoot = GetRoot oObjects = myRoot.Getcollection("Macro") msgbox oObjects.Count & " Macros" oObjects = myRoot.Getcollection("Diagram") msgbox oObjects.Count & " diagrams" When I launch the macro from within MEGA I get the correct result for macros (6474) AND diagrams (. When I call the macro from VB.NET I get the correct result for macros (6474), but I get no diagrams. If go further and try to count other object, I try queries (2 times succesfull), next I try Database (only lucky within MEGA, and not via VB.NET) It seems that the currentenvironment is not properly loaded when I perform my GetRoot in the called macro. All objects that are shared in different repositories (query, macro, ...) can be selected, all objects that belong to the currentrepository can not be selected... I'm calling my macro from VB.NET using the following code (written by an external consultant of MEGA who helped us with our migration from MEGA 6.1 towards MEGA 2009) oMacro = MyRoot.GetSelection("Select [Macro] where [_hexaidabs] =" + DQ + sIdMacro + DQ)
If oMacro.Count = 1 Then
aMacro = oMacro(1)
pMacro = MyRoot.CurrentEnvironment.GetMacro(aMacro.GetProp("name"))
oResult = pMacro.GetType().InvokeMember(sMacroFunction, BindingFlags.InvokeMethod, defaultBinder, pMacro, Nothing) Where sMacroFunction is the function within the macro that serves as starting point.
... View more