It would be hard to debug just the snippet of the code with out the code
around it.
If there are problems getting the correct qualified name then, you could
search the classcollection for a particular class name and once found that
class, you can call the GetQualifiedName on that instance to get the fully
qualified name.  You could use that in the AddAssociation class.

For example, the following script assumes there are two classes by name
Parent_Directory and Gauge_Diameter and creates an association between those
two classes and adds the association to the main class diagram.

Hope this example helps in debugging your code.

' script starts here
Sub Main

  Dim cc As ClassCollection
  Set cc = RoseApp.CurrentModel.GetAllClasses()

  ' Get the class for "Element A" of the link (receiving)
  pname = "Parent_Directory"
  rcID = cc.FindFirst (pname)  
  Dim rc As Class
  Set rc = cc.GetAt(rcID)

  ' Get the class for "Element B" of the link (supplier)
  qname = "Gauge_Diameter"
  scID = cc.FindFirst (qname)  
  Dim sc As Class
  Set sc = cc.GetAt(scID)
  MsgBox sc.GetQualifiedName()

 
 ' Add the association
  Dim pref As Association       
  Set pref = rc.AddAssociation ("",sc.GetQualifiedName())
  pref.Stereotype = "Pointer"

  Dim theClassDiag As ClassDiagram
  Set theClassDiag =
RoseApp.CurrentModel.RootCategory.ClassDiagrams.GetAt(1)
  isAdded = theClassDiag.AddAssociation(pref)  
        
End Sub
' script starts here

--Sonny

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 10:15 AM
To: [EMAIL PROTECTED]
Subject: (ROSE) AddAssociation




The problem is I cannot get the association to recognize and set "Element
A" as it appears when viewing the specification of the link.

When created interactively I get (under the General Tab)

  Role A : blank    Element A: Gauge_Diameter
  Role B:  blank    Element B : Parent_Directory

When created from my application I get :

  Role A : blank    Element A:  blank
  Role B:  blank    Element B : Parent_Directory

This is a snippit of my code

  '  Get the class for "Element A" of the link
        rcID = cc.FindFirst (pname)
        Set rc = cc.GetAt(rcID)
 ' Set the qualified name
        qname = qname & "::" & pname

        msgbox (cnest.Name & " " & rc.Name & vbCrLf & qname)
 ' Add the association
        set pref = cnest.AddAssociation ("",qname)
        pref.Stereotype = "Pointer"


The result of the messagebox is :
 Parent_Directory   Gauge_Diameter
Logical View::DS
Data::Engine_Data::TopEnd_Data::Valvetrain_Data::Valve_Data::Intake::Package
::Gauge_Diameter

This breaks down to
View  ::  Category ::  RootClass :: Nested Class1 :: Nested Class2  ::
Nested Class3  :: Nested Class4  :: Nested Class5 :: Target Class

I am using this as the name Gauge_Diameter occurs multiple times in the
model depending on the names of the nested classes, in this case Nested
Class 4 can be Intake or Exhaust and the documentation says if the name
appears twice you must use the fully defined name. I have tried it with
just rc.Name and it still does not work.

I would be grateful if anyone could point out what I'm doing wrong in my
AddAssociation.

Mark Hampshire
                                            
 Knowledge             Location   263 E3000 
 Engineering, TCC                     S2E11 
                                            
 800 Chrysler Drive    Tie Line    754-0818 
                                            
                                            
 Auburn Hills, MI      Phone          (248) 
 48326                             944-0818 
                                            
 CIMS 483-01-13        Fax            (248) 
                                   576-2185 
                                            






****************************************************************************

The information contained in this transmission, which may be
confidential and proprietary, is only for the intended recipients.
Unauthorized use is strictly prohibited. If you receive this
transmission in error, please notify me immediately by telephone
or electronic mail and confirm that you deleted this transmission
and the reply from your electronic mail system.
****************************************************************************



************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Post or Reply to: [EMAIL PROTECTED]
* Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
*    http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
*    To: [EMAIL PROTECTED]
*    Subject: <BLANK>
*    Body: unsubscribe rose_forum
*************************************************************************
************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Post or Reply to: [EMAIL PROTECTED]
* Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
*    http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
*    To: [EMAIL PROTECTED]
*    Subject: <BLANK>
*    Body: unsubscribe rose_forum
*************************************************************************

Reply via email to