Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - «Midnight»

Pages: 1 ... 375 376 [377]
5641
Automation Interface, Add-Ins and Tools / Re: ExportPackageXMI
« on: February 19, 2006, 03:58:27 pm »
What I always seem to do, when I'm trying something for the first time, is create a package (or whatever) and then try to use it. After a bit of hair-pulling I always find that I've forgotten to (either or both) call the .Update() method or more likely, to call the .Refresh method of the parent collection.

In the latter case (forgetting to call .Refresh) the result would be similar to your problem.

Reloading the project should put things right, but who knows.

Please let me know if that's what's happening. I am soon embarking on some heavy data transfer stuff through automation, and I'd sure like to know if this is going to be a speed bump.

David

5642
I too seem to get varying results here. I don't know if the behavior is different between the various collections, or if my memory of what's happening is faulty (either is possible).

A safe way is to trap for the exception, but still test for a null result. Given that you are working through an OLE interface (and possibly a Net Interop layer) this should not seriously impact your perceived performance.

5643
Oops, mea culpa...

I seem to be monotasking here, at best.

I just realized (while I was programming) that I had mis-stated this. You are correct. You must enter one of the strings listed in the help file as a valid element type.

Of course "Package" is a valid type for the Package.AddNew method. Since I then went on to explain Element.AddNew method my brain just directed me to type "Element" rather than tell you to use the element 'type.'

I only noticed this when I went back into my code and entered "Element" for the element type - and got the same error as you.

Bottom line: you should be OK entering the element type. Try using "State" or "UseCase" or "Activity" for a change. You can find a list of these in the help. Just look for Element, and find the Type attribute. This works for several other sets of string constants.

While we're at it, the ObjectType property will return one of the ot<whatever> enumeration values, and is pretty reliable for finding out what you have when you traverse a collection. It is read-only.

David

5644
Since my last reply I have been working with EA automation, including creating packages. I must confess that I have not been creating both views and packages as we are discussion.

However...

You are creating your packages as type "otPackage" via the second parameter of the AddNew call. Try "Package" instead. Likewise, use "Element" instead of "otElement" for the element call.

David

EDIT:

Just tried out the above solution, using a blank model (no views or anything). Worked like a charm. It also worked perfectly when I added the element directly to the View, so use the above solution and disregard my original assertion.

I was using VB.Net with the Strict option on, so needed to use DirectCast or CType to cast the results of the AddNew methods to EA.Package or EA.Element. You will need to perform the same cast.

Remember that if you want to enumerate the collection or find the package or element via GetByName, you will first have to call the Refresh method on the parent collection.

Let me know how it works.

David

5645
I think I've run into this myself recently.

It looks like you are trying to add an element into a package, which is in turn a direct child of the Model element.

[At least recently; it might have been different a while back] EA seems to consider any package that is an immediate child of the Model element to be a View. Views seem not to like having elements as immediate children.

Try creating another package directly under iPack. Then add your element to the second package.

Please let me know if this works; if not I'll see if I still have the code where I ran into something similar, and whether I preserved the solution. My code was in VB.Net 2003, but you should be able to translate without trouble.

David

5646
Thanks KP,

I was getting resigned to that fate...

Of course boundaries are arbitrary (or whatever) partitionings of a system, so there is really much less of an 'ownership' relation between them and their enclosed elements than in other UML constructs.

I gather I can just line up the elements I want to enclose, calculate the greatest extent of height or width, and then simply plunk down a boundary and size it accordingly.

The other way would sort of be in reverse, as you suggest.

5647
Anyone have insights on how to handle - thorough the automation interface - the relationship between a boundary (the enclosure, not the UP Boundary Element) and those elements it encloses.

I'm looking to do things like:
  • add a boundary to a diagram, then add elements to the boundary
  • query a boundary to enumerate the elements it encloses
  • create a hierarchy of nested boundaries


It's easy to identify or add a boundary, but from there I'm lost.

David

5648
One of the other threads mentioned that EA uses a default model (good ole EABase.eap by default) for the version 6.1 method of creating a new model. You can apparently change the contents to customize the 'starter' components.

If you want to look it up, the thread was suggesting using EABase_Jet4.0 as a possible default.

In any case it might be possible to somehow grab or manipulate this information by automation.

Of course, I have not tried it yet. Still busy fighting some unrelated fires.

5649
Hi Colin,

I had the same problem myself during evaluation. Bottom line is that you have to supply a file. [If you are using a repository back end you will have to supply an existing schema, populated from a model via the Transfer function.]

This next holds true through build 781 inclusive; see below for a note on later builds.

You can programmatically copy from an empty reference model, which you will want to create separately. This can be stored in some kind of default location for automation purposes only. Not the most elegant conceptual solution, but it works and looks fine to the user.

Please note that as of version 6.1 build 785 - just released a few days ago - there is a different process for creating a new model via the user interface. Now you just point to the desired location (which does not have to exist) and EA does the homework. It also allows you to select which portions of a 'stock' model you want to include, if any.

I have not looked at the documentation or tried programming with the new process, but intend to soon - a client has an immediate need. We should let each other know if we learn anything.

David

Pages: 1 ... 375 376 [377]