Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic System Architect (steve huntington)
Decrease font size
Increase font size
Topic Title: VBA macro newbie tips
Topic Summary: A topic to record suggestions for using SA VBA effectively
Created On: 1-Oct-2007 12:58
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 1-Oct-2007 12:58
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

This topic is aimed at newbies like myself, and aims to collect tips to aid newbies getting over the initial frustrating hump.  Please add your suggestions on issues that you found difficult initially.  Please add improvements and corrections in a positive manner.  Please take opinions into other threads.

Expose the constants so they can be used in expressions eg
    Set usecaseSymbol = usecaseDiagram.CreateSymbol(usecasename, ETOOUSECASE)
Drag the following files from
C:\Program Files\Telelogic\System Architect Suite\System Architect
into the VB Modules explorer
'DEFNS.bas
'diagrams.bas
'rels.bas
'Symbols.bas


Creating a usecase diagram and moving it into a Package
eg create the diagram abc under package 'a package'
The complexity is that the string Property 'Package' seems to need quotes in the package name string
dim diag as Diagram
packageName = "a package"
quotedName = """" & packageName & """" 
Set diag = Application.Encyclopedia.CreateDiagram("abc", GTOOUSECASE)
diag.SetProperty "Package", quotedName
diag.Save
Set diag = Nothing


Creating a package under a package
assume parentPackage is set to the existing package
This seems to work without requiring quotes around the "Parent Package" name in the SetProperty statement.
Dim parentPackage as Definition
set parentPackage = ...
Dim newPkg as Definition
newPackageName = "a new package"
Set newPkg = Application.Encyclopedia.CreateDefinition(newPackageName, DFXOOPACKAGE)
newPkg.SetProperty "Parent Package", parentPackage.name


Create a usecase symbol on a Usecase diagram
This assumes the definition does not already exist.  The definition will be stored in the same package as the diagram is in.
The definition does not seem to be automatically created when a new symbol is added.
Assuming the diagram is referenced by usecaseDiagram
and the diagrams package is referenced by diagramsPackage
The code first creates the definition and then creates the usecase symbol.  The linkage seems to occur because the names are the same.
Dim diagramsPackage as Definition
set diagramsPackage = ...
Dim usecaseDiagram as Diagram
set usecaseDiagram = ...
Dim usecaseDefinition As Definition
usecaseName = "NounVerb"
Set usecaseDefinition = Application.Encyclopedia.CreateDefinition(usecaseName, DFXOOUSECASE)
'the definition seems to need the quoted package name. The quoted name is available from the diagram
quotedPackageName = usecaseDiagram.GetProperty("Package")
Call usecaseDefinition.SetProperty("Package", quotedPackageName)
usecaseDefinition.Save
Set usecaseDefinition = Nothing
'creating the symbol of the same name as the definition seems to link it.
Dim usecaseSymbol as Symbol
Set usecaseSymbol = usecaseDiagram.CreateSymbol(usecaseName, ETOOUSECASE)
Call usecaseSymbol.SetProperty("Package", strPackage)
usecaseSymbol.Save
usecaseDiagram.Save
set usecaseSymbol = Nothing
set usecaseDiagram = Nothing
set diagramsPackage = Nothing

All corrections and improvements would be welcome.
Thanks

Report this to a Moderator Report this to a Moderator
 17-Oct-2007 13:07
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

Relationships
To find the relationships available between two objects in the encyclopedia, populate the Metamodel diagram with the two objects and their relationships will be described.  This is described in the Guidebook here:
C:\Program Files\Telelogic\System Architect Suite\System Architect\Guidebooks\Generic\metamodeldiagram.htm


To find the data instantiating the relationships between two objects tailor and run the following
'This only discovers relations where the relation has already been populated with data.
'The relation type name definitions are in the file:
'C:\Program Files\Telelogic\System Architect Suite\System Architect\rels.bas
'This code currently only works on UML usecases
Sub exposeInstantiatedRelations()
    Dim def As Definition
    Dim allDefs As SAObjects
    Set allDefs = Application.Encyclopedia.GetFilteredDefinitions("", DFXOOUSECASE)
    Call allDefs.ReadAll
    Set def = allDefs.Item(1) 'only provide 1st for illustration purposes
    Debug.Print "*** Instantiated Relations for "; def.name
   
    'output the related objects
    Dim j As Long
    For j = 1 To 141 ' there are 141 relations defined in RELS.BAS
        Set allDefs = def.GetRelatedObjects(j)'eg RELKEYEDBY
        Call allDefs.ReadAll
        For i = 1 To allDefs.Count
            Debug.Print "rel "; j, allDefs.Item(i).TypeName, allDefs.Item(i).name
        Next i
    Next j
End Sub


Getting a writable reference to the related definition of a symbol can be achieved thus
    Dim sym As Symbol
    Dim idx As Long
    idx = sym.Definition.ddId
    Set def = Application.Encyclopedia.GetDefinitionById(idx)

Report this to a Moderator Report this to a Moderator
 22-Jul-2008 17:38
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

The maximum length of a package name is 80 characters. If you have spaces in the name the internal quotes, needed to surround this, reduce this to 78. I recommend truncating all package names to 78 characters.
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic System Architect forum.
There are currently 1 users logged in.
The most users ever online was 16 on 30-Oct-2008 at 14:46.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.