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: How to Rename a symbol or definition in VBA?
Topic Summary:
Created On: 5-Oct-2007 09: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.
Answer This question was answered by Toby Chaloner, on Friday, October 5, 2007 10:57 AM

Answer:
The name is manipulated via the 'Field' interface.  The following achieved the renaming in the previous example.  The DEFNFLD_ definitions were exposed in the VBA editor without needing importing.

 'rename the definition
 Debug.Print def.GetField(DEFNFLD_SANAME)
 def.SetField DEFNFLD_SANAME, "arthur"
 Debug.Print def.name, def.GetProperty("Name")
 Debug.Print def.GetField(DEFNFLD_SANAME)
 def.Save
 Set def = Nothing
 
 'rename the symbol
 Debug.Print sym.GetField(SYMFLD_NAME)
 sym.SetField SYMFLD_NAME, "arthur"
 Debug.Print sym.name, sym.GetProperty("Name")
 Debug.Print sym.GetField(SYMFLD_NAME)
 Set sym = Nothing
 diag.Save
 diag.Hide
 diag.Show
 Set diag = Nothing
 5-Oct-2007 09:58
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

Can someone suggest how to rename a symbol and its definition in a VBA macro?
I have tried the following illustration without success...

'I selected a symbol on a diagram as a target before running the following.
Private Sub tDemoChangeName()
    Dim def As Definition

    Dim diag As Diagram
    Set diag = Application.Encyclopedia.GetCurrentDiagram
    Dim sym As Symbol
    Set diagSymbols = Application.Encyclopedia.GetCurrentDiagram.GetAllSymbols
    Call diagSymbols.ReadAll
    For i = 1 To diagSymbols.Count
        Set sym = diagSymbols.Item(i)
        If sym.Selected Then
            Debug.Print sym.name
                       
            'Set def = getSymbolsDefinition(sym) ' does a lookup sym.GetRelatedObjects(RELTYPE_DEFINEDBY)...
            Debug.Print def.name, def.GetProperty("Name")
            def.SetProperty "Name", "arthur"
            Debug.Print def.name, def.GetProperty("Name"), "d after"
            'def.name = "arthur"
            def.Save
            Set def = Nothing
            Debug.Print sym.name, sym.GetProperty("Name")
            sym.SetProperty "Name", "arthur"
            Debug.Print sym.name, sym.GetProperty("Name"), "s after"
            'diag.Save
            Set sym = Nothing
        End If
    Next i
End Sub

Report this to a Moderator Report this to a Moderator
 5-Oct-2007 10:57
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

Answer Answer
The name is manipulated via the 'Field' interface.  The following achieved the renaming in the previous example.  The DEFNFLD_ definitions were exposed in the VBA editor without needing importing.

 'rename the definition
 Debug.Print def.GetField(DEFNFLD_SANAME)
 def.SetField DEFNFLD_SANAME, "arthur"
 Debug.Print def.name, def.GetProperty("Name")
 Debug.Print def.GetField(DEFNFLD_SANAME)
 def.Save
 Set def = Nothing
 
 'rename the symbol
 Debug.Print sym.GetField(SYMFLD_NAME)
 sym.SetField SYMFLD_NAME, "arthur"
 Debug.Print sym.name, sym.GetProperty("Name")
 Debug.Print sym.GetField(SYMFLD_NAME)
 Set sym = Nothing
 diag.Save
 diag.Hide
 diag.Show
 Set diag = Nothing
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.