![]() |
Telelogic System Architect (steve huntington) | ![]() |
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 |
![]() |
![]()
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
Relationships
|
|
![]() |
|
![]() |
|
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.
|
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.