Itoo Software Forum

Forest Pack => Forest Pro (*) => Topic started by: Paul Roberts on May 08, 2015, 03:31:58 PM

Title: Scripts for Forest Pack
Post by: Paul Roberts on May 08, 2015, 03:31:58 PM
In this sticky topic we encourage you to share any intersting scripts or tools that you've created to make working with Forest Pack even easier.

If you'd like to share your work with the community, just feel free to upload or link to your script with a brief description below.

To download files from our forums you need to be logged in with an account associated with a Pro license.

Many thanks!

Paul

Disclaimer: Any scripts uploaded to this thread by the iToo Software team are not supported officially by iToo, please use at your own risk.
Title: Re: Scripts for Forest Pack
Post by: Michal Karmazín on May 08, 2015, 04:04:37 PM
Surface Assignment

(http://i.imgur.com/hUiZrLH.jpg?1)

A simple one for quick base surface reassignment, that can be handy in case of having multiple Forest objects.

Its UI is quite simple. To select the "new" surface please Pick Surface button. You can select Forest object(s) manually or if wanted you can select all Forest object in your scene by Select All Forest objects button. By hitting Assign all selected Forest object will now use the picked surface.

Cheers,
Title: Re: Scripts for Forest Pack
Post by: TL1895 on May 08, 2015, 07:39:42 PM
Excellent!
thank you
Title: Re: Scripts for Forest Pack
Post by: SozoDigital on August 10, 2015, 07:14:24 AM
Very nice! Thank you very much for sharing!

Cheers!
Title: Re: Scripts for Forest Pack
Post by: in3des on September 08, 2015, 12:52:12 PM
= Forest Replace Object =
adding this one also
Carlos made it some time ago
(if I remember this scripts helps to change an object in all forests with new one)
Title: Re: Scripts for Forest Pack
Post by: Michal Karmazín on October 07, 2015, 10:22:27 AM
ObjectsToForest

(http://i.imgur.com/Vu89Tww.jpg?1)

This script will automatically add selected items & place them to source object's position. Use the Select Objects to pick all objects that should be inserted into the new "AutoForest" object. Than by clicking the AutoForest button, it'll create a new Forest object with all those objects with transformations corresponding to its "source objects".

Hope, it'll speed-up your work-flow, when this kind of task needs to be performed massively.

Best regards,
Title: Re: Scripts for Forest Pack
Post by: HM3153 on February 03, 2016, 11:50:20 PM
Great!!!
Title: Re: Scripts for Forest Pack
Post by: Paul Roberts on May 04, 2016, 10:50:54 AM
InstancesToForest

(http://i.imgur.com/m3no1Ax.png)

This script looks in the scene to find instances of the objects in Forest Pack's item list. When it finds them they're added to FP, matching the position, rotation and scale.

To use this script:
- Create a new FP object
- Add an object/s to Forest Pack's items list, these are the things with instances in the scene that you'd like to convert to FP geometry.
- Change to Tree Editor mode
- With the FP object still selected, press Instance To Forest.

Here's a video of it working



Note that this is an early version. At the moment the Forest Pack object must be at the world origin (the script changes this automatically though). I'd also like to add the ability to append the instances (at the moment it overwrites the current scatter),an option to automatically find instanced objects and add one of them to the items list (great for automatically converting large scenes), and an option to delete the original instances once added to FP.

I hope it's useful for some people.

Many thanks!

Paul.
Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on June 21, 2016, 09:45:00 AM
Wish/request

A script that selects all ForestPack nodes, so that I can put them in a separate layer.
Title: Re: Scripts for Forest Pack
Post by: Paul Roberts on June 21, 2016, 11:40:23 AM
Hi,

You could use this line of code to select all the object in the scene:

select (for s in geometry where classOf s == Forest_Pro collect s)

Alternatively you could easily  select all the Forest Objects using Forest Lister. To do this:

1 - Hold down Control and click on the boxes in the first column of Forest Lister for all the Forest Objects you wish to select.

(http://i.imgur.com/ELrpqsL.png)

2 - Click the Select Objects (http://i.imgur.com/RhdWlYg.png) button.

I hope that helps, please let me know if you have any further questions.

Many Thanks,

Paul
Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on June 24, 2016, 12:54:43 AM

You could use this line of code to select all the object in the scene:

select (for s in geometry where classOf s == Forest_Pro collect s)

Alternatively you could easily  select all the Forest Objects using Forest Lister.

Both your answer helped me perfectly well.


Wish/request 2

A way to set "Auto Assign to Active View" on all forest items in the scene. I encountered huge difficulties when I was setting up a test-scene with several samples. It ended up being too many items to be renderable. I had to go through the forest objects one by one and set Auto Assign...
Title: Re: Scripts for Forest Pack
Post by: Screenscene vfx on August 02, 2016, 05:56:04 PM
Hurray!

I was supplied a scene from another post company who'd written an instancer for maya and arnold to do digital set extensions. We'd been given a huge collection of alembic caches, texture files and a single maya file that had point helpers named after the model that should have been scattered on it. I was able to split the objects into layers based on their names and then bastardize your script to create a forest object with a tree matching the position, rotation and scale of each of the point helpers.

Now rather than 33,000+ vray proxies in my scene, I've a forest object for each of the 90 types of objects scattered in the scene and something way more manageable to deal with.

Much appreciated Paul!

Quote

-- Make a forest object to load stuff into

theForestObj = forest_Pro mode:1

-- Quick function in case I want to loop it later

function MakeForestFromSelection theForest theSel =
(
   
   for i = 1 to (theSel.count) do
   (
      
      -- All nicked from Paul roberts instances to forest script - http://forum.itoosoft.com/index.php?topic=2929.0
      
      local itemMatrix = theSel.transform
      local rot = quattoeuler (theSel.transform.rotationpart) order:5
      local newRot = [degtorad(rot.y),degtorad(rot.z),degtorad(rot.x)]
      local itemLocalBoundingBox = nodeGetBoundingBox theSel itemMatrix
      local size = (itemLocalBoundingBox[2] - itemLocalBoundingBox[1]) * itemMatrix.scalePart
      
      -- Add in a forest tree using the transform data of each selection object
      
      theForest.trees.create theSel.pos 1 1 theForest.specidlist[1]
      theForest.trees.setRotation (theForest.trees.count()-1) newrot
      theForest.trees.setSize (theForest.trees.count()-1) size
      theForest.trees.update_ui()
      theForest.trees.update()            
   )
)

-- Fly my pretties

MakeForestFromSelection theForestObj (selection as array)
Title: Re: Scripts for Forest Pack
Post by: Paul Roberts on August 03, 2016, 11:15:41 AM
Instance lights on Forest Pack items

(http://i.imgur.com/QuROX1d.png)

This script instances any object to match the position and rotation of items scattered with Forest Pack. It can be useful for distributing lights, splines, particle systems or any other non-geometric object that it not able to be scattered directly with Forest Pack

To use this script:
- NOTE: To return correct transform information, Forest Pack object must be scattering custom geometry, not using one of the built in billboard templates.
- Press the "Pick Object to instance" button and choose the object you'd like to instance, for example a light
- Make sure a Forest Object is selected.
- Click "Instances to Forest"

The new instances are created with a combination of the source object and the Forest object's names. To delete these.

- Make sure the source object is chosen using the "Pick Object to instance" button
- Select the FP object
- Click delete instanced objects.

Note: Because the delete function is using the names of the FP object and the source object you should not change their names if you would like to use the delete function.

Here's a video of it working



I hope it's useful for someone.

Many thanks!

Paul.
Title: Re: Scripts for Forest Pack
Post by: raistlin on September 07, 2016, 09:51:26 AM
Hi Itoo

Can you add a little script to "randomize seed" a selection of multiple Forest Pack object in a click, it should be really interesting for scene that we re-use...

Cheers!
Title: Re: Scripts for Forest Pack
Post by: raistlin on September 07, 2016, 10:11:19 AM
Hi Itoo

Can you add a little script to "randomize seed" a selection of multiple Forest Pack object in a click, it should be really interesting for scene that we re-use...

Cheers!

I've done a little thing like that :

$.seed = random 1 999999

But it's really limited, because the result is apply in the same time on each forest object...
Damned...
It work, for sure... But i'm pretty sure it could be better...
Title: Re: Scripts for Forest Pack
Post by: Paul Roberts on September 07, 2016, 10:19:52 AM
Hi!

If you just need a simple line you can use the following -

for i in selection do i.seed = random 1 999999


It will apply a different random seed to each selected Forest Pack object.

I hope that helps.

Cheers!

Paul
Title: Re: Scripts for Forest Pack
Post by: raistlin on September 07, 2016, 03:20:54 PM
Soooo, here my solution!
as you have help me a lot in many times, here is my little contribution...

rollout FFRandomSeed "FF-Random Seed" width:200 height:128
(
   button btn1 "Random Seed" pos:[24,72] width:152 height:32
   label titre "  - Forest Pack - Random Seed -" pos:[16,8] width:168 height:32
   groupBox grp1 "Select at least one FF-Object" pos:[8,40] width:184 height:80
   on btn1 pressed  do
      for i in selection do( i.seed = random 1 999999)
)
createdialog FFRandomSeed

Have a nice day!
Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on October 15, 2016, 01:14:18 AM
Script wish:

Assign current camera to selected forest(s)
Title: Re: Scripts for Forest Pack
Post by: iToo on October 15, 2016, 08:40:54 AM
Script wish:

Assign current camera to selected forest(s)

If that helps, the "Copy" button in Camera rollout, copies current camera and properties to all FP objects.

Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on October 29, 2016, 06:14:44 PM
InstancesToForest

(http://i.imgur.com/m3no1Ax.png)
I hope it's useful for some people.

Many thanks!

Paul.

In your video, you're in the Geometry Rollout and press the None-button, and pick a mesh. Even though, the mesh is not visible in the FP object and under Tree Editor it says 0 Items.
In my case, when I press None and then pick a mesh, I immediately see a point cloud of that mesh.
- What am I doing different from you?

Later, you explain "change to Tree Editor mode"
- What does it mean? In the video, you simply enter the rollout, but you're not pressing any button or changing modes.

In my case, I wanted to turn one single object to an FP object. InstanceToForest didn't work for me. The only thing it did was to reset scale and rotation of the picked object. Under Tree Editor, there were 0 Items.
However, when I had multiple instances, it worked, except it skipped the "original mesh" which appears to be the first mesh created, not the one I pick as source.
In your video, you picked one item, and when you pressed Instances to Forest, it turned them all, including the object you picked, to point clouds.
Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on October 29, 2016, 06:20:07 PM
Script wish:

Assign current camera to selected forest(s)

If that helps, the "Copy" button in Camera rollout, copies current camera and properties to all FP objects.

Unfortunately, this was not what I was looking for.
I meant a better way to assign a camera instead of the current solution where you press the None-button and then pick a camera.
My trick so far is to press auto-assign to active view, then pan the scene and cancel with right click, and the camera gets assigned. Then I untick "auto assign".
This could be scripted and what the script does is assigning the current camera to the selected forest object.
Title: Re: Scripts for Forest Pack
Post by: Kerezsi on January 12, 2017, 11:34:23 AM
Script wish:

Assign current camera to selected forest(s)

If that helps, the "Copy" button in Camera rollout, copies current camera and properties to all FP objects.

Unfortunately, this was not what I was looking for.
I meant a better way to assign a camera instead of the current solution where you press the None-button and then pick a camera.
My trick so far is to press auto-assign to active view, then pan the scene and cancel with right click, and the camera gets assigned. Then I untick "auto assign".
This could be scripted and what the script does is assigning the current camera to the selected forest object.

run in maxscript listener, assigns the current viewport's camera to selected forest objects:

try for s in selection where classOf s == Forest_Pro do s.camera = getActiveCamera() catch()
Title: Re: Scripts for Forest Pack
Post by: Straightface Studios on March 28, 2017, 12:02:12 AM
Here is a script which will take a Krakatoa PRT Loader or a Particle Flow source and places a tree for each particle at the particle's position.   Unfortunately there is a bug in ForestPack which limits the particle system limit to around 20k particles before it's impossibly slow so only use it for smaller particle systems.

#Note only reads position, not orientation or scale of particles.
Title: Re: Scripts for Forest Pack
Post by: raistlin on July 13, 2017, 01:37:16 AM
Hi itoo!

The defy of the day :
is there a way to clean forest  pack pro duplicate geometry in the list??

In a case we merge some scenes with Forest object, we have some duplicate source geometry, without the same name in the forest template layer, but the same Xref name and place...

Is there a script to automate the process of replacement and keep the surface?
It's a way to optimise our scene and clean the assets for renders.

I try to merge fpp object, but first, we lost the surface, and second : we lost our instance which are randomly replaced by the other...

Cheers :) ^^
Title: Re: Scripts for Forest Pack
Post by: Adam86 on March 13, 2018, 03:30:24 PM
Would love one that could add a forest colour map into selected mesh materials, i've got about 15 plant models each with 15 multisub object leaf ID's, going to have to manually add one to each slot!
Title: Re: Scripts for Forest Pack
Post by: Michal Karmazín on March 13, 2018, 04:27:43 PM
Hi,

The Material > Optimize Materials feature allows you Apply Forest Color to a Selection or the Material Library (attaching screen-shot). Hope that helps.

Best regards,
Title: Re: Scripts for Forest Pack
Post by: Adam86 on March 13, 2018, 04:37:43 PM
Hi,

The Material > Optimize Materials feature allows you Apply Forest Color to a Selection or the Material Library (attaching screen-shot). Hope that helps.

Best regards,

Amazing!!! that was quick work :)
Title: Re: Scripts for Forest Pack
Post by: FlynnAD on May 13, 2018, 04:39:37 AM
InstancesToForest

This script looks in the scene to find instances of the objects in Forest Pack's item list. When it finds them they're added to FP, matching the position, rotation and scale.

Paul.

Hi Paul,
Your script is fantastic. I've used it to convert old mental ray proxies into a format that I can now re-use in Vray, as well as grabbing hundreds of 3dsmax instances into one forest object.

However, I've noticed that the script WILL ALWAYS MISS ONE OBJECT. Just one, not two, not none. If you make an array of instances in 3dsmax, then make a forest object from these instances using your script, it's easy to pick out the single object that doesn't make the cut. Can you find the glitch in your script that causes one random item to be excluded?

Thanks,
Matt
Title: Re: Scripts for Forest Pack
Post by: Rokas on May 14, 2018, 03:51:29 PM
Hi Paul,
Your script is fantastic. I've used it to convert old mental ray proxies into a format that I can now re-use in Vray, as well as grabbing hundreds of 3dsmax instances into one forest object.

However, I've noticed that the script WILL ALWAYS MISS ONE OBJECT. Just one, not two, not none. If you make an array of instances in 3dsmax, then make a forest object from these instances using your script, it's easy to pick out the single object that doesn't make the cut. Can you find the glitch in your script that causes one random item to be excluded?

Thanks,
Matt

In 36th line remove "-1" so it look like this:
      for x = 1 to (instanceList.count) do
Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on June 20, 2018, 12:54:23 PM
A script that sets Display > Viewport to
* Mesh
* Proxy
* Points-cloud
Title: Re: Scripts for Forest Pack
Post by: Rokas on June 20, 2018, 01:35:27 PM
A script that sets Display > Viewport to
* Mesh
* Proxy
* Points-cloud

Please use included  ForestPack lister (https://docs.itoosoft.com/forestpack/forest-lister) for this.
(https://i.imgur.com/ju9Z27u.jpg)

edit:
Also this script seems to work (thank You for edit Haider)
Quote
for obj in selection do if (classof obj == Forest_pro) then obj.vmesh = 0
Title: Re: Scripts for Forest Pack
Post by: leonardo.afanador on June 20, 2018, 02:19:40 PM
A script that sets Display > Viewport to
* Mesh
* Proxy
* Points-cloud

it exists
http://www.scriptspot.com/3ds-max/scripts/v-ray-proxy-tools
Title: Re: Scripts for Forest Pack
Post by: Haider of Sweden on June 22, 2018, 03:49:16 PM
Please use included  ForestPack lister (https://docs.itoosoft.com/forestpack/forest-lister) for this.
(https://i.imgur.com/ju9Z27u.jpg)

I know there are other ways than scripting to do what I ask for, but the script will act much faster than first opening a UI and then making choices. So I went with this solution and thank you very much for your help (I switched out the Railclone_Pro to Forest_Pro to make it work

Code: [Select]
for obj in selection do if (classof obj == Forest_pro) then obj.vmesh = 0

it exists
http://www.scriptspot.com/3ds-max/scripts/v-ray-proxy-tools

But this one doesn't work for Forest Pack, does it? Have you tried? (I haven't tried it)
Title: Re: Scripts for Forest Pack
Post by: Frag Studio on August 31, 2018, 04:28:59 PM
Thank you very much Paul, that script saved me lot of time yesterday.

Everyone sharing script like you are heroes. At one moment in one place, you're one artist's best friend.
Title: Re: Scripts for Forest Pack
Post by: VIZIOEN on November 08, 2018, 10:27:20 AM
InstancesToForest

(http://i.imgur.com/m3no1Ax.png)

This script looks in the scene to find instances of the objects in Forest Pack's item list. When it finds them they're added to FP, matching the position, rotation and scale.

To use this script:
- Create a new FP object
- Add an object/s to Forest Pack's items list, these are the things with instances in the scene that you'd like to convert to FP geometry.
- Change to Tree Editor mode
- With the FP object still selected, press Instance To Forest.

Here's a video of it working

<iframe width="560" height="315" src="https://www.youtube.com/embed/CuQbinj-U5Y" frameborder="0" allowfullscreen></iframe>


Note that this is an early version. At the moment the Forest Pack object must be at the world origin (the script changes this automatically though). I'd also like to add the ability to append the instances (at the moment it overwrites the current scatter),an option to automatically find instanced objects and add one of them to the items list (great for automatically converting large scenes), and an option to delete the original instances once added to FP.

I hope it's useful for some people.

Many thanks!

Paul.

Does this still work with the latest Forest Pack? I've placed Instances of Xref Objects with object paint. When using this script it adds the right amout of instances to the forest pack but they are all at the same position (first instance placed).
Title: Re: Scripts for Forest Pack
Post by: Dragan on February 20, 2019, 09:57:20 PM
I found Surface and Object Assigment but can`t see Area Assignment?
 
Title: Re: Scripts for Forest Pack
Post by: Rokas on October 24, 2019, 10:33:55 AM
Select Dependent objects.

Usage:
Select Your ForestPack Pro / RailClone Pro objects(can be mixed among other items) and running this script will add dependent objects to Your selection:
(https://i.imgur.com/69MPBrM.gif)