creating elements

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

creating elements

Postby KH » Thu May 31, 2007 2:34 pm

Hi,

I am trying to create a Package and then add other Class elements to the
package, but I am running into a ClassCastException. Does anyone know why
this might be? My code is attached below. Also, does anybody have any
examples for creating Elements that you can share with me?

Thanks for your help.

--

//create session
SessionManager.getInstance().createSession("Create and add Element");
ElementsFActory f =
Application.getInstance().getProject().getElementsFactory();

Package myPackage = f.createPackageInstance();
myPakcage.setName("Test Package");

Class myClass = f.createClassInstance();
myClass.setName("Test Class");
myClass.setOwner(myPackage);

SessionManager.getInstance().closeSession();


KH
 
Posts Rating:

Re: creating elements

Postby KH » Thu May 31, 2007 4:43 pm

Sorry, just to add to my last post. I fixed the problem with the
ClassCastException, but I still don't see the package and class elements in
the project. I am using MagicDraw version 11.6

Thanks.


> Hi,
>
> I am trying to create a Package and then add other Class elements to the
> package, but I am running into a ClassCastException. Does anyone know why
> this might be? My code is attached below. Also, does anybody have any
> examples for creating Elements that you can share with me?
>
> Thanks for your help.
>
> --
>
> //create session
> SessionManager.getInstance().createSession("Create and add Element");
> ElementsFActory f =
> Application.getInstance().getProject().getElementsFactory();
>
> Package myPackage = f.createPackageInstance();
> myPakcage.setName("Test Package");
>
> Class myClass = f.createClassInstance();
> myClass.setName("Test Class");
> myClass.setOwner(myPackage);
>
> SessionManager.getInstance().closeSession();
>


KH
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 2 guests