Generic table, display elements

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Generic table, display elements

Postby » Thu Jan 21, 2021 12:33 pm

I have created a Generic Table which doesn't display the column header and rows unless I go to the Select Element Type drop-down and click on the Element types and the Scope (optional) drop down and click on the messages. How can I display these components programmatically?
Forum Newbie
Forum Newbie
Posts: 1
Posts Rating:0
Joined: Thu Jan 21, 2021 11:52 am

Re: Generic table, display elements

Postby » Mon Apr 10, 2023 1:20 pm

You could do something like below...
Note using Jython for solution

Code: Select all

from com.nomagic.generictable import GenericTableManager as GTM
root = project.project
mainModel = project.getPrimaryModel()
fileName = "filename" 

def createBlock(name_of_block, block_package):       
            block = self.factory.createClassInstance()
            StereotypesHelper.addStereotypeByString(block, "Block")
            return block

       resultsTable = GTM.createGenericTable(root, fileName)
       # creating the results package
        results = self.factory.createPackageInstance()
        # calling function and assigning it to owningBlock
        self.owningBlock = createBlock(fileName, results)
        # setting results owner
        # naming results package as "Results" // in the future could name this something related to the .dat file name

You want to use the follow to set up the type of the generic table..

Code: Select all
  element = Finder.byQualifiedName().find(self.root,"QualifiedName of StereoType" )
  # appending the element stereoType to the list elementTypes
  elementType = [element]
  # setting Element Type in the Generic Table as the QualifiedName Stereotype
  GTM.setTableElementTypes(resultsTable, elementType)
Forum Newbie
Forum Newbie
Posts: 11
Posts Rating:2
Joined: Mon Nov 28, 2022 9:16 am

Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests