Composition Container

All topics on the Atoms in any Enterprise Dynamics Library.
Post Reply
Thor
Posts: 12
Joined: Thursday 16 January, 2014 - 15:16

Composition Container

Post by Thor »

Hello,

I will have to duplicate a number of machines (which are composed of multiple atoms) and intend to use the composition container atom for easy duplication. I managed to create the composition container which now contains the relevant atoms. Then I saved it and imported the same into the library. So far so good.

When inserting my composition container into the Model Layout, it will screw up the interconnections between the atoms within the container (i.e. some connections are completely lost and others are reconnnected to the wrong channels/atoms). Is there anything I need to be aware of?

BR
Thorsten
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Composition Container

Post by marlies »

Hi Thorsten,

I cannot reproduce the problem you describe. I also added atoms to a composition container. Saved it as .atm and started dragging the atom into the model. The connections were there as before.

Could you attach an example?

Regards, Marlies
Thor
Posts: 12
Joined: Thursday 16 January, 2014 - 15:16

Re: Composition Container

Post by Thor »

Hi Marlis,

Thanks for your reply! I retried the procedure and this time it worked properly. I don't exactly know what I did differently last time but the important thing is that it now works...

Best regards
Thorsten
Thor
Posts: 12
Joined: Thursday 16 January, 2014 - 15:16

Re: Composition Container

Post by Thor »

Hi Marlies,

I want to place some code in the OnCreation Event handler of a composition container that I have created and imported to the library. The purpose is to set atom names and labels of (and within) the composition conatiner whenever I drag a composition container into the model. However, upon import of the composition container to the library this code is lost and replaced by standard code. I then have to open the atom editor for the composition container in the library and manually replace the standard text with my code.
Is there any way around this procedure?

Also, I do not fully understand the mother/daughter relationship of composition containers that were created (and updated). When I create a new version (aka save new files) of a composition container after editing, the old version becomes the mother of the new one. I ran into problems where the program could not find the mother and inherrited base class values. Could you maybe explain how to avoid any touble when creating new versions of a composition container?

One last question, is there any way of adding a composition container to the library when opening the model? I could get the following code to work but don't know where to place it (Turbine v8.atm is the name of the composition container):
do(
library,
execfile(ModDir([Turbine v8.atm]))
)

Many thanks in advance and best regards
Thorsten
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Composition Container

Post by marlies »

Hello Thorsten,

To start with your last question: this code can be placed in the startup script. You will find that via File > Startup script.

Then the onCreation code of the composition container. It usually is the right way to do what you want to do, but.. in this case the save button in the composition container's gui will override the code you placed in there yourself.

The mother/daughter relationship between the composition containers is as follows:
- The first one is the original composition container atom from the library. This is what we call the baseclass atom, it does not inherit from any other atom.
- As soon as you drag a composition container into the model it will be a daughter of the original composition container, even if you save it with a different name as a separate .atm file. So your newly created atom inherits code from the original composition container atom. The difference is that the save button (as mentioned above) adds some extra functionality to your own created container.
- When you start dragging the new atm file into the model the containers that will be created will be a daughters of your own created .atm file. So: it inherits the code from your atm file (the code added by the button), but also from the original atom.
- To summarize: baseclass (origial atom, doesn't inherit) - your saved .atm (daughter of original, inherits from original) - your model containers (daughter of your saved .atm, inheriting from the saved .atm and via that atom from the orginal one).

To get around the overwrite of the code in the oncreation you could do the following:
- Save the composition, then add it to the library, then adjust the code in the oncreation via the atom editor and save the atm via File > Save Atom as. Make sure that you add your code for naming the atoms after the code that is already there. Do not use the save button in the composition container anymore as it will overwrite your code again.
- You could also add the code to the onreset of the atm file, although it has the disadvantage that the code for naming will be executed everytime you reset the model. If you choose this option use the inherit command:

Code: Select all

Do( 
 inherit { this command makes sure you don't loose functionality that should be inherited }, 
 name(rank(1,c)) := [aname]
)
Regards, Marlies
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Composition Container

Post by marlies »

Hi Thorsten,

To load your own atoms into the library, a good option is also to create your own .app file. I assume you usually choose logistics suite when you open up ED? When you go to c:program files/ed/apps you will find the file logistics suite.app there. When you copy this, open it in e.g. notepad and add code for loading your own atoms to the file, the next time you will have your own app as an option and the additional atoms will be loaded automatically.
This way it's easier to share your app with other people.

Regards, MArlies
Post Reply