Title: RE: RE: (ROSE) Accessing Cutomised Model Properties with REI.

> Would I be right in thinking that the on-line help assumes a
> basic understanding of VB

Yes.  Rose script language is a VB compatible language with
extensions for the Rose objects.  So in order to be fluent with
Rose script, one would want to have a basic understanding of
VB language.

Below are a few examples of working with custom properties that
hopefully will help:

=============================================================
Q> I'm using a custom property set. I've used Rose to enter some of these
(bSubscriber class). But, the GetProperties method on Class never returns
any properties even though they are visible in the Model using the GUI. How
do I get at the custom property sets using Rose script.

A> One problem might be that the DefaultTool for the open model is not set
properly. The default tool must be set to be the name of the tool that
owns the property set. (Every property has a name and a tool (or owner)).

Somewhere early in the script execute:

RoseApp.CurrentModel.DefaultTool = "cg"

*The default DefaultTool depends on the version of Rose. In C++, for
example, its "cg".

Example script: 

'*-----

Sub Main
viewport.open
viewport.clear
Dim aModel as Model

set aModel = RoseApp.CurrentModel
Dim Classes as ClassCollection
Dim aClass as Class
Dim Idx as Integer
Dim PropList as PropertyCollection

set Classes = aModel.GetAllClasses

ToolName$ = "cg"
RoseApp.CurrentModel.DefaultTool = ToolName$

For Idx = 1 to Classes.Count
set aClass = Classes.GetAt(Idx)
set PropList = aClass.GetProperties 'See note below
print PropList.Count
Next
End Sub

'*-------
=============================================================
other examples:
=============================================================
Sub Main
viewport.open
viewport.clear
Dim aModel as Model

set aModel = RoseApp.CurrentModel
Dim Classes as ClassCollection
Dim aClass as Class
Dim Idx as Integer
Dim PropList as PropertyCollection
Dim theProperty as Property

set Classes = aModel.GetAllClasses

ToolName$ = "ddl"
RoseApp.CurrentModel.DefaultTool = ToolName$

For Idx = 1 to Classes.Count
 set aClass = Classes.GetAt(Idx)
 print "class "; aclass.name

 set PropList = aClass.GetProperties 'See note below
 print PropList.Count

 For PropID = 1 To PropList.Count
       Set theProperty = PropList.GetAt (PropID)
                  'if theProperty.PropertyType <> "AttrSetAttr" then
                  Print theProperty.Name
', theProperty.Value
'                  theProperty.PropertyType
                 'end if
 Next PropID

Next
       
End Sub

=============================================================
'!BACKUP THE MODEL FILE BEFORE ATTEMPTING TO USE THIS SCRIPT
'OR ANY OTHER SCRIPT THAT MODIFIES THE MODEL!

'Sample code to set a custom property set "MyPersistentClassSet"
'on classes (and associated attributes and associations) that
'are marked as persistent

const MyPersistentClassSet as string = "MyPersistentClassSet"
const MyPersistentAttSet as string = "MyPersistentAttSet"
const MyPersistentAssocSet as string = "MyPersistentAssocSet"

sub doMe(c as class)
dim atts as attributeCollection
dim added as boolean

RoseApp.currentModel.DefaultTool = "cg"

added = c.addProperty("cg_style",MyPersistentClassSet)

set atts = c.attributes

for i% = 1 to atts.count
  added = atts.getat(i).addproperty("cg_style",MyPersistentAttSet)
next i

'
'  Now for the associations...
'
dim assocs as associationCollection
set assocs = c.getAssociations
dim theAssoc as association
dim theRole as Role

for i% = 1 to assocs.count

  set theAssoc =        assocs.getat(i)
  
   set  theRole = theAssoc.getCorrespondingRole(c)

if theRole.getUniqueId = theAssoc.Role1.GetUniqueId then
  added = theAssoc.Role2.addproperty("cg_style",MyPersistentAssocSet)
else
  added = theAssoc.Role1.addproperty("cg_style",MyPersistentAssocSet)
end if

next i

end sub

Sub Main
    dim allCl as ClassCollection
    set allCl = RoseApp.CurrentModel.GetAllClasses
   
    for i% = 1 to allCl.count
       if allCl.getat(i).persistence then
           DoMe allCl.getat(i)
       end if
    next i
End Sub
=============================================================


Patrick Kennedy
 Rational Support


-----Original Message-----
From: Les Munday [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 23, 2002 3:13 PM
To: [EMAIL PROTECTED]
Subject: Re: RE: (ROSE) Accessing Cutomised Model Properties with REI.



> Custom properties are accessed via generic method calls
unlike hardcoded
> properties.  There's a bunch of methods you can use to get
custom
> properties:
>
> GetToolProperties()
> GetPropertyValue()
>
> These and other methods are documented in the on-line help
that is installed
> with Rose.
>
Ah, but I believe that the problem is that these are not
sufficiently documented in the on-line help.

Would I be right in thinking that the on-line help assumes a
basic understanding of VB, which I don't have?

So when I try to use these commands I get error messages
like, 'the object does not have an assigned default value'

Any additional help would be most welcome. Examples even more
so.

Les.

________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
************************************************************************
* 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