Book a Demo

Author Topic: Strange behaviour adding elements to a package  (Read 4348 times)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Strange behaviour adding elements to a package
« on: March 06, 2015, 05:09:57 am »
I've added elements to packages HEAPS of times, but this time I am seeing some REALLY strange behaviour.

If I have a package structure like this:

Package1 -> Package2

and then call:

Set element = Package2.Elements.AddNew(elementName, baseClass)

The element appears under Package1 NOT Package2!!!

I am using code in another script that is (as far as I can see) identical except for variable names and yet I am getting this problem :-(

Any clues?

Thanks in advance

Jays  :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Strange behaviour adding elements to a package
« Reply #1 on: March 06, 2015, 10:54:05 am »
What does "Package1 -> Package2" mean?

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Strange behaviour adding elements to a package
« Reply #2 on: March 06, 2015, 05:50:45 pm »
Maybe you need to run a "Project Integrity Check" (Ctrl+F9)
I can image something like this happening when the ID's get a bit mixed up.

In case you want to make sure this is correct add

Code: [Select]
element.PackageID = Package2.PackageID;
element.Update()

to your code

Geert

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Strange behaviour adding elements to a package
« Reply #3 on: March 09, 2015, 05:27:05 am »
Hey Geert

Thanks for the suggestion.
The project integrity check DID clean some stuff up, but unfortunately didn't fix this problem :(

I just can't for the life of me figure out what the hang I am doing wrong!

Jays :-)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Strange behaviour adding elements to a package
« Reply #4 on: March 09, 2015, 05:28:28 am »
Quote
What does "Package1 -> Package2" mean?

q.


Hey q,

Sorry was in an all day workshop on Friday so was typing on my phone only.
It means that I have two packages, where Package 1 is the parent of Package 2.

Cheers

Jays :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Strange behaviour adding elements to a package
« Reply #5 on: March 09, 2015, 07:00:28 am »
I would just confirm that package1 and 2 really contain what the name suggests by inspecting the guid and verifying it in the project browser.

q.