Per on line help for GetActiveDiagram,

 Set theDiagram = theModel.GetActiveDiagram ()

 where type is, theDiagram As Diagram, not ClassDiagram 

 Take note that a script using the GetActiveDiagram
 method or GetSelected means that you must launch this script 
 from a menu item in Rose.  You cannot run this script from a 
 script window because if you try to do so the script window 
 will be the active window.  

 To launch this script from a menu selection you will need to 
 modify the rose.mnu file (located in Rose's home directory 
 --- location of rose.exe) and add an option to run your script.  

 For example, to execute a script called "myscript.ebx" and add 
 a menu item "RUN MY SCRIPT", the following 4 lines of code
 was added to rose.mnu under the Tools heading: 
 
 option "RUN MY SCRIPT"
           {
              RoseScript $SCRIPT_PATH\myscript.ebx
           }

 ------------------------------------------------------------------

 Menu Tools
 
 {
 
   Separator
   option "Class Wizard..."
           {
              enable %model:writeable
              RoseScript $SCRIPT_PATH\cwizard.ebx
           }
   option "RUN MY SCRIPT"
           {
              RoseScript $SCRIPT_PATH\myscript.ebx
           }
 }
 
 ------------------------------------------------------------------

 $SCRIPT_PATH pathmap by default is the location of rose.exe.
 See online help regarding Pathmaps for more information.
 You could also hard code the path if desired.

Here's a short example script showing use of, 

'add note with text to current (active) diagram GetActiveDiagram()

 Sub Main

        Dim diag As Diagram 
        Dim note As NoteView

        Set diag = RoseApp.CurrentModel.GetActiveDiagram()

        If diag Is Nothing Then
                MsgBox "No active diagram"
                Exit Sub
        End If
        
        qName$ = "TEST"
        Set note = Diag.AddNoteView(qName$, 2)
        note.YPosition = 200
      note.XPosition = 1000
   
        MsgBox "Done" 

 End Sub

Patrick Kennedy
 Rational Support

> -----Original Message-----
> From: Manish Agrawal [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 04, 2001 8:58 PM
> To: [EMAIL PROTECTED]
> Subject: (ROSE) does rose script not allow polymorphic assignments?
> 
> 
> 
> Hi,
> I was trying to do the following:
> dim the Model as Model
> dim objClassDiagram as ClassDiagram
> set theModel = RoseApp.CurrentModel
> set objClassDiagram = theModel.GetActiveDiagram() //error!!!
> 
> I get a compile time error on line 4 that the assigned 
> variable and the
> expression are of different types. Is this because "GetActiveDiagram"
> returns a "diagram" and not a "ClassDiagram"? However I know that the
> diagram being returned is a ClassDiagram. Can I do something 
> to assign the
> returned object reference to a ClassDiagram variable and not 
> to a Diagram
> variable?
> Thanks and Regards
> Manish 
> **************************************************************
> **********
> * Rose Forum is a public venue for ideas and discussions.
> * For technical support, visit http://www.rational.com/support
> *
> * Admin.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
*
* Admin.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