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: Macro access to symbol size
Topic Summary: programmatically set the length and width of process symbol
Created On: 19-Jun-2007 14:43
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.
Answer This question was answered by Matt Sheranko, on Friday, June 22, 2007 4:33 PM

Answer:

The following sample code shows one way to do this.  Standard disclaimers apply...AS IS WITHOUT WARRANTY FOR ANY USE...Try/test it on a sample diagram with similar complexity before using in PROD etc.

MattS

' TOC
Option Explicit
'
'Dim GLOBAL vars here


'
'
Sub Main()
    'init SA Application
    Dim saApp As SA2001.Application
    Set saApp = New SA2001.Application
   
    ' strDbPathName = Trim(Application.CurrentProject.Path) & "\" & Trim(Application.CurrentProject.Name)
   
    Dim intMsgBoxResult As Integer
    Dim strMsgBoxMsg1 As String
                                   
    strMsgBoxMsg1 = "Click YES to run Symbol Resize Macro.  This Macro resizes all" & vbCrLf + _
                                "selected symbols to the same size." & vbCrLf + _
                                "Size is passed in when SymbolResize is called from MAIN."
                               
    intMsgBoxResult = MsgBox(strMsgBoxMsg1, vbYesNo, "Symbol Resize")
   

    If intMsgBoxResult = vbYes Then
        'Do something
        Call SymbolResize("300 200")
    End If

    Set saApp = Nothing
End Sub

Sub SymbolResize(strXYSize As String)
'   Open a diagram with symbols of desired type.  I used a BPMN Business Process diagram and selected only the Prosess symbols.
'   Run MAIN.  All Process symbols (type 777) are resized to 300 X 200.  Note the default size for Process symbol is 125 X 75 in my current config.
'   Need some additional logic to reposition symbols to a relative center after resizing.

    Dim strErrorMsg As String
   
    Dim saApp As SA2001.Application
    Dim curDiagram As SA2001.Diagram
    Dim colSymbols As SAObjects
   
    Dim strSymbolName As String
    Dim strSymbolSize As String
    Dim strSymbolType As String
       
    Dim lngCounter As Long
    Dim strProcName As String
   
    On Error GoTo myError
    strProcName = "SymbolResize"
 
    ' get the appliation object
100 Set saApp = New SA2001.Application
   
    Set curDiagram = saApp.Encyclopedia.GetCurrentDiagram '  get currently open diagram
200 ' Set colSymbols = curDiagram.GetAllSymbols ' use this to get all symbols
210 Set colSymbols = curDiagram.GetFilteredSymbols("*", 777) ' only grab symbols of a specific type, 777 is a BPMN Process
    Call colSymbols.ReadAll     ' this is required to make the col of symbols accessable
   
    ' some general info
    Debug.Print "*******************"
    Debug.Print "Diagram Name: " & curDiagram.GetProperty("Name")
    Debug.Print "Total Selected Symbol Count: " & colSymbols.Count
   
300 For lngCounter = 1 To colSymbols.Count

400     strSymbolName = colSymbols.Item(lngCounter).GetProperty("Name")
        strSymbolSize = colSymbols.Item(lngCounter).GetField(SYMFLD_SIZE)
        strSymbolType = colSymbols.Item(lngCounter).GetField(SYMFLD_TYPE)

500     Debug.Print "Symbol Name: " & strSymbolName & ", " & "Original Size: " & strSymbolSize & ", " & "New Size: " & strXYSize & ", " & "Symbol Type: " & strSymbolType
       
        ' set new size for this symbol
        ' XYSize is passed in from MAIN
600     Call colSymbols.Item(lngCounter).SetField(SYMFLD_SIZE, strXYSize)

700 Next lngCounter
   
1000 exit_routine:
    ' take out the trash
    ' If Not curDiagram Is Nothing Then Set saObjsCol = Nothing
    ' If Not saApp Is Nothing Then Set saApp = Nothing
    Exit Sub

1100 myError:
    strErrorMsg = Err.Number & vbCrLf & Err.Description & vbCrLf & "Line: " & Erl & "Module:" & Err.Source & "Procedure Name: " & strProcName
    ' MsgBox strErrorMsg
    Debug.Print strErrorMsg
    GoTo exit_routine
   
End Sub

 19-Jun-2007 14:43
User is offline View Users Profile Print this message


Matt Sheranko

Posts: 82
Joined: 7-Oct-2005

Is there a way to select all symbols of a certain type and then set a common size to all of them.  For example, I want to select all Process symbols on a BPMN diagram and programmatically set the length and width parameters to all symbols.


 


>>>  EDIT  >>>



XSize and YSize



-------------------------
Thanks,

MattS

Edited: 19-Jun-2007 at 16:00 by Matt Sheranko
Report this to a Moderator Report this to a Moderator
 22-Jun-2007 16:33
User is offline View Users Profile Print this message


Matt Sheranko

Posts: 82
Joined: 7-Oct-2005

Answer Answer

The following sample code shows one way to do this.  Standard disclaimers apply...AS IS WITHOUT WARRANTY FOR ANY USE...Try/test it on a sample diagram with similar complexity before using in PROD etc.

MattS

' TOC
Option Explicit
'
'Dim GLOBAL vars here


'
'
Sub Main()
    'init SA Application
    Dim saApp As SA2001.Application
    Set saApp = New SA2001.Application
   
    ' strDbPathName = Trim(Application.CurrentProject.Path) & "\" & Trim(Application.CurrentProject.Name)
   
    Dim intMsgBoxResult As Integer
    Dim strMsgBoxMsg1 As String
                                   
    strMsgBoxMsg1 = "Click YES to run Symbol Resize Macro.  This Macro resizes all" & vbCrLf + _
                                "selected symbols to the same size." & vbCrLf + _
                                "Size is passed in when SymbolResize is called from MAIN."
                               
    intMsgBoxResult = MsgBox(strMsgBoxMsg1, vbYesNo, "Symbol Resize")
   

    If intMsgBoxResult = vbYes Then
        'Do something
        Call SymbolResize("300 200")
    End If

    Set saApp = Nothing
End Sub

Sub SymbolResize(strXYSize As String)
'   Open a diagram with symbols of desired type.  I used a BPMN Business Process diagram and selected only the Prosess symbols.
'   Run MAIN.  All Process symbols (type 777) are resized to 300 X 200.  Note the default size for Process symbol is 125 X 75 in my current config.
'   Need some additional logic to reposition symbols to a relative center after resizing.

    Dim strErrorMsg As String
   
    Dim saApp As SA2001.Application
    Dim curDiagram As SA2001.Diagram
    Dim colSymbols As SAObjects
   
    Dim strSymbolName As String
    Dim strSymbolSize As String
    Dim strSymbolType As String
       
    Dim lngCounter As Long
    Dim strProcName As String
   
    On Error GoTo myError
    strProcName = "SymbolResize"
 
    ' get the appliation object
100 Set saApp = New SA2001.Application
   
    Set curDiagram = saApp.Encyclopedia.GetCurrentDiagram '  get currently open diagram
200 ' Set colSymbols = curDiagram.GetAllSymbols ' use this to get all symbols
210 Set colSymbols = curDiagram.GetFilteredSymbols("*", 777) ' only grab symbols of a specific type, 777 is a BPMN Process
    Call colSymbols.ReadAll     ' this is required to make the col of symbols accessable
   
    ' some general info
    Debug.Print "*******************"
    Debug.Print "Diagram Name: " & curDiagram.GetProperty("Name")
    Debug.Print "Total Selected Symbol Count: " & colSymbols.Count
   
300 For lngCounter = 1 To colSymbols.Count

400     strSymbolName = colSymbols.Item(lngCounter).GetProperty("Name")
        strSymbolSize = colSymbols.Item(lngCounter).GetField(SYMFLD_SIZE)
        strSymbolType = colSymbols.Item(lngCounter).GetField(SYMFLD_TYPE)

500     Debug.Print "Symbol Name: " & strSymbolName & ", " & "Original Size: " & strSymbolSize & ", " & "New Size: " & strXYSize & ", " & "Symbol Type: " & strSymbolType
       
        ' set new size for this symbol
        ' XYSize is passed in from MAIN
600     Call colSymbols.Item(lngCounter).SetField(SYMFLD_SIZE, strXYSize)

700 Next lngCounter
   
1000 exit_routine:
    ' take out the trash
    ' If Not curDiagram Is Nothing Then Set saObjsCol = Nothing
    ' If Not saApp Is Nothing Then Set saApp = Nothing
    Exit Sub

1100 myError:
    strErrorMsg = Err.Number & vbCrLf & Err.Description & vbCrLf & "Line: " & Erl & "Module:" & Err.Source & "Procedure Name: " & strProcName
    ' MsgBox strErrorMsg
    Debug.Print strErrorMsg
    GoTo exit_routine
   
End Sub



-------------------------
Thanks,

MattS
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.