How to count and identify the Products defined in a Model

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
CyrusMMXI
Posts: 9
Joined: Friday 04 November, 2011 - 11:51

How to count and identify the Products defined in a Model

Post by CyrusMMXI »

Is there any way to count the number of Product Types or their associated Sources defined in a Model? Remember that the code should be self-sufficient and without user intervention it can identify how many products have been defined in the Model (or alternatively how many Sources).
User avatar
MatthijsJongboer
Posts: 200
Joined: Thursday 11 November, 2010 - 14:12

Re: How to count and identify the Products defined in a Mode

Post by MatthijsJongboer »

When you want to get the total number of product types, the first question is how you identify a product type. If it's through a color or image or through a label or maybe some other definition? When you define the number of product types as being equal to the number of sources, you could verify the mother name of all atoms in your model.
4DScript words foratomlayerunder, m and comparetext are crucial here.
When you say that the code should be self-sufficient and work without user intervention, maybe you can indicate how your user should make use of the fucntionality?
CyrusMMXI
Posts: 9
Joined: Friday 04 November, 2011 - 11:51

Re: How to count and identify the Products defined in a Mode

Post by CyrusMMXI »

Thanks MatthijsJongboer! In my case Products differ from each other based on the Sources through which they are introduced to the model. Regarding the user intervention for example I thought that one can be developing a new sort of atom that user should connect the Central Channel of each source to the inputs of that atom, then the number of input channels of that atom can indicate the number of Sources. Is there any way that without requiring the user, the code in this new sort of atom can recognize the number of Sources and possibly control the Sources?
User avatar
MatthijsJongboer
Posts: 200
Joined: Thursday 11 November, 2010 - 14:12

Re: How to count and identify the Products defined in a Mode

Post by MatthijsJongboer »

When you create the atom and have the user connect the atoms, the result would be simply the number of input channels (nric). So creating the connections is also possible (e.g. OnReset). You can use the 4DScript Connect where channel 0 is the central channel. You can increse the number of channels of an atom using the 4DScript SetChannels.
Post Reply