Itoo Software Forum

Forest Pack => Forest Pro (*) => Topic started by: cc8boy on April 06, 2017, 10:15:06 AM

Title: Can you write me a very simple Script for grouped obj?
Post by: cc8boy on April 06, 2017, 10:15:06 AM
Hello everyone,
   I really need a MAXscript to add a grouped object as custom objects in Forest pro object. Can you write a very simple script that I can add specific group as custom object ?
I tried to use this commands
$.cobjlist[1] = $Grouphead
$.namelist[1] = $Grouphead.name
$.matlist[1] = sceneMaterials["abc"]

But it failed to add the whole group as custom objects.
Title: Re: Can you write me a very simple Script for grouped obj?
Post by: Michal KarmazĂ­n on April 06, 2017, 02:06:22 PM
Hi,

That's possible via Maxscript in a following way:
All objects handled in such group can be selected and stored as the "items" variable for example by:

items = for i in Objects where (isGroupMember i == true) collect i;

To add it to existing Forest object, it's necessary to define .count vales for several Forest properties. You can find list of these in following ObjectToForest (https://forum.itoosoft.com/index.php?topic=2929.msg12480#msg12480) script.
Setting new counts you can proceed by:

existingItemsCount = $.cobjlist.count;
$.cobjlist.count = $.cobjlist.count + items.count;
...
$.problist.count = $.problist.count + items.count;


This needs to done for all of these values ($.matlist, $.namelist, $.coloridlist ... $.problist).
Finally, you can add & define these objects by:

for i = 1 to items.count do
    (
    $.cobjlist[existingItemsCount + i] = items;
    ...
    $.problist[existingItemsCount + i] = 100;
    );

Again, this have to be done for all listed properties ($.matlist, $.namelist, $.coloridlist ... $.problist).
Hope that helps.

Best regards,