Jump to content
Sign In to follow this  
redlotus

SimTropolis Tools

98 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 
While working on one of my buildings, I finally came to the point where I needed to assign night lighting to the windows.  Since there were over 2700 windows, I decided that it was time to take the plunge into MaxScripts.  Attached is the script that I came up with to randomly select the windows that I wanted to night light.
 
Unfortunately, this isn't just a fire-and-forget type script.  In order to work properly, you have to follow a few rules:
1.  The objects that you want the randomizer to select from must include the word 'Window' in their name.  If they don't, then you'll have to make an adjustment to the script (see below).
2.  Objects that you don't want the randomizer to select from cannot have the word 'Window' in their name.  Adding insult to injury, hiding objects does not remove this restriction.
3.  You must also make two more changes to the script.
 
Here are the lines that will need to be changed (including the name change, if needed)
totalwindows=2792 -- This needs to be changed to the total number of objects that the randomizer will choose from.  If you don't know how many that is, select all of the objects you want to include, press F11 (to open the script listener), and type 'selection.count' (without the quotes) into the top pane.  You should see the total number of objects in the lower pane.
windowswanted=800 -- This needs to be changed to the total number of objects that you want to be chosen.
tempselection=$*Window*[rand] -- If your objects do not include 'Window' in the name, you will have to change the blue text to a common word that is shared by all of the objects.  DO NOT FORGET RULE #2.
 
Anyway, I hope this helps all of you that have been asking for this sort of thing.  If you are having any problems, let me know.
 
-red
 
Installation instructions:  Unzip into your \BAT\Scripts directory.
To Edit the Script:  Choose MAXScript-->Open Script...
To Run the Script:  Choose MAXScript-->Run Script...

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

yeah i wrote a request for something like this in the modd area!

i will try yours out tonight, but if you have time, try and make something that will take a user's selection set, and randomly make nite windows.

as i said in my other thread, it would be cool if :

1. the script would randomize to more that 1 different intensity level
2. would create groups (named by intensity) of the the different intensities!

WELL GOOD LUCK!

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    Wow.  Only one comment from all of you.  I guess that I'll have to assume that this was a little more work than you folks wanted to put in.  Never fear.  I have updated the script to make it a little more user friendly.  You will no longer have to worry about changing the script to suit your needs.  Here is how the new script will work:
    1.  Select the group of objects that you want randomly chosen for night lighting (or for any other reason you may want a random selection)
    2.  Open the MAXScript Listener by pressing the F11 key.
    3.  Select Run Script... from the File menu in the Listener and open the RandomWindow script.
    4.  The script will ask you what percentage of the objects that you want to remain selected.  Make sure that you use an integer between 0 and 100, otherwise the script will generate an error.
    5.  After a few seconds (or minutes if you're on a slower computer with a lot of objects selected<ahttps://community.simtropolis.com/assets/emoticons/3.gif>), your selections will be ready to add night lighting to.
     
    Unfortunately, there is only one caveat left with this new script--you can't really use groups within your selection set.  When the randomizer is deselecting objects, if it comes across an object within a group, it will deselect the entire group.  This will badly skew the results.  I wish that there was a way around this, but I haven't found it yet.  Also, if you are working with a large selection set, you might want to decrease your percentage a little bit, because the randomizer will sometimes choose the same object more than once, and you will end up with a few more windows than you might expect.
     
    Let me know if anyone has any comments or suggestions.
     
    cerulean,
    Sorry, but I really don't know how to get the script to apply night lighting itself, nevermind having it vary the intensity.  What I would recommend is that you run the script a few times, each time applying the night lighting (with whatever intensity you want), grouping the set, and then 'freezing' that group.  This should give you the effect that you're looking for and it wouldn't take much longer than having a script do it for you.
     
    -red

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    YAY! Ill dl this when I get home THANKS!!!!!!!!!!!!!!!!


    SC4, Forevermore!

    Currently preoccupied with architecture school...lurking with caution.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    BRILIANT!! SIMPLY BRILIANT!! this is what i freaking needed when i was doing the night windows for the transamerica pyramid.. do you know how many windows it had.. ahem.. OVER 3500!!!! ..it took pretty long to make the nite windows.. this will surely make it alot easier for all of us.. thank you<ahttps://community.simtropolis.com/assets/emoticons/2.gif>

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Cool, Ill have to test this out! It seems like it will work though, and really selecting is the hard part, so creating a group and renaming it is pretty easy24.gif24.gif

    Ive attached a file to this message too, if you are in interested. I found this script at http://tdp.nu/scriptsearch.html this site has a ton of scripts most of which are written for 3dsmax, not gmax. as such the below attachment DOESN'T WORK, but it might be good for reference. I tried to mess around with it, but i don't know anything about programming.

    thanks again!9.gif21.gif24.gif

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    ok attach didnt work, it should be in this message!

    again this DOESN'T SEEM to work in GMAX, and is for reference only.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    ok i did some tinkering with redlotus' script and added a rollout box so you dont have to go into the listener, other than that its all his!

    ATTACHED!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I too have tinkered with the script and have come up with a way to let this script actually light up the windows by putting Night_ in front of all the deselected objects.

    I'm going to tinker on this some more... Maybe we can even edit the intensity and stuff...This would be a really handy tool for every BATter, and I'm sure that we can create a super user-friendly one if we combine our knowledge

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    oppie, i really prefer that we dont put night in front, i know why you do it and it makes sense i think, you do it so you can select them right?, but if we are going to try and use multiple intensities, we really need to start grouping the windows...just my thoughts...maybe if you suffixed the names with the intensities? I dont know, but to me they should all be named Windows...i usually just name them all G-0000 for glass, eg G-1221 would be the 1221th pane of glass created.

    ive been trying to work on a multiple group function in there, but i cant figure out how to do it because you start off with a selection, then subtract from that selection. So you are left with one group. but if you want 3 groups, how do you reselect all of the objects that unselected and then unselect all the objects you just assigned to group one. does that make sense?

    step 1 you start off with 100 windows, and say you want 4 groups

    step 2 then the script randomly selects 25 windows

    step 3 then assigns them to a group (i dont know how to do this either, maybe it remanes them all night1?

    step 4 then you need to deselect those objects

    step 5 then reselect the 75 other objects you didnt rename or group

    step 6 then repeat from step 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    The best thing would be if each window also got a random light intensity assigned. I think it should be possible; I've looked at the standard BAT maxscripts and judging from those it can be done with some tweaking. I'm going to spend a great deal of my weekend on that and I'll see what I can come up with....

    It would rock if we could release a true BAT add-on!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    good point...then we could just add Night_ as a prefix like you said.

    Can you attach the script you messed around with? So i can see how you handled renaming.

    All that would be left then is to find out how to assign intensities. I am at work and dont actually have the BAT here, so im not sure how that vairable is handled, and acutally it would be a pure stroke of luck if i found it myself anyway...unless there are scripts associated with the BAT and a part of the script that said HEY LOOK AT ME I CONTROL NIGHT LIGHT INTENSITY <ahttps://community.simtropolis.com/assets/emoticons/9.gif> wouldn't that be nice...but its gotta be in there somewhere...

    beyond that tho, there could be a spinner for max and min intensities...

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    also in order to show up properly in game for everyone it is supposed to be nite_!  night_ will show it lit in gmax and the previews/renders but not ingame (well not for everybody i should say)... so nite_ is universal and night_ is specific (some people see it ingame others dont)
     
    and I think I will have to use this script for my latest work, the Apple HQ building which will have i dont know how many windows (ummm lets see if i can count on the top of my head real quick....  i think around 900 windows)

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    [bEGINQUOTE]

    3/26/2004 2:08:01 PM[/quoteDATE]
    [/quoteAUTHOR]
    good point...then we could just add Night_ as a prefix like you said.

    Can you attach the script you messed around with? So i can see how you handled renaming.

    All that would be left then is to find out how to assign intensities. I am at work and dont actually have the BAT here, so im not sure how that vairable is handled, and acutally it would be a pure stroke of luck if i found it myself anyway...unless there are scripts associated with the BAT and a part of the script that said HEY LOOK AT ME I CONTROL NIGHT LIGHT INTENSITY 9.gif wouldn't that be nice...but its gotta be in there somewhere...

    beyond that tho, there could be a spinner for max and min intensities...
    [/quoteMESSAGE][/bEGINQUOTE]

    I can't attach the script itself; I messed it up a bit because I tried to speed up the selecting process a bit... Yet the renaming is pretty easy anyway:

    tempselection.name = Night_Window

    I inserted the above line just before deselect tempselection. I'm well aware that this still needs a lot of tweaking but I also think this is well worth spending a few hours of work on. So I'll keep you updated on my progress. As a student programmer I'm pretty interested in these maxscripts. I'm thinking of other things that would be useful, like some kind of 'center geometry' script that fixes that bug where the model seems to be offset in the Lot Editor.

    EDIT: There seems to be a better way to rename objects:

    tempselection.name = (Night_ + tempselection.name as string)

    The above one keeps the original object name and adds the Night prefix in front of it.

    Screwball; I'll use nite_ in future versions of this script. 1.gif

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    works like a charm oppie! now we just need to know how to set the intensities...anyone?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    YAY! SOme of my buildings have like 5,000 windows! This will cut down on some time!

    YAY YAY YAY!<ahttps://community.simtropolis.com/assets/emoticons/9.gif><ahttps://community.simtropolis.com/assets/emoticons/9.gif><ahttps://community.simtropolis.com/assets/emoticons/9.gif>


    SC4, Forevermore!

    Currently preoccupied with architecture school...lurking with caution.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I also managed to make the random selecter both more accurate and (I hope) faster in the long run. My version checks literally every selected object and then evaluates based on the percentage given by the user if the object should be selected or deselected. This way the random select process is very accurate, and since it doesn't select the same object twice, I hope it's also faster but I don't have any way to prove that right now...

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    cool, when you get the script reworked post it so we can see what you have done. I am pretty interested in the maxscripts too and would like to see how you are doing stuff.

    I will be testing what we have by 5pm PST on the Azubre Corporate Offices Building tonight. It has 2500+ windows so I should be able to give it a good test run. It would be nice if we could figure out how to do intensities by then, but theres not much i can do here at work because the BAT doesnt work without SC4 and i dont have it installed here at work so im limited to playing with the random selection features and the rollout stuff which i found remarable easy despite my lack of knowledge on the subject.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    I couldn't get version 1 to work but version 2 works like a dream. Thank you very much RedLotus!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    This should do quite nicely...
     
    -Chris

    Correlation doesn't imply causation, but it does waggle its eyebrows suggestively and gesture furtively while mouthing 'look over there'. - xkcd.com

    Visit my SC4 City Journal, Leicester County | Index | Street Map
    Buffalo and Upstate New York BATs

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Ok, i have streamed lined the selection process by making sure it only selects the objects once. Please test this on something before using it on a large scale model. What i have done is after the randomly selected object is renamed, it is deselected, and the last object in the selection set is assigned to the currently randomized position. thus shrinking the selection set size by one. This seems to make things very accurate. I tested it on 140 objects at 50% and it came back with 70 objects every time.

    Random_select-03 ATTACHED

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Somthing else I have discovered upon further testing is that the percentage value you input is actually the percentage of objects that will remain in the selection. In other words. if you set it to 20%, 80% of the objects will be nite windows, and vice versa...

    EDIT: I am also working on having the script also assign another string, after the nite_ string which will say C1 or C2, right now its 1-10. I am doing this because i like to copy my glass texture x number of times, and modify the tint slightly so that the windows appear slightly irregular, like the Tsng building, that Red CO$$ High density building. there are others that do it too, but that ones the one i notice the most. Right now I am setting it up so that the default is 1, and I think i can make it so that if you say you only want 1 color, that it wont actually add the C1 to the name, so those that don't want to use it wont be troubled with it.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    One last update for today.

    This one includes the Random Color plugin. The two run separately though so as not mess each other up. All the random colorizer does is add a prefix to the object names like sphere11 becomes C1sphere11. I dont know how many people will use this, but as i explained before, it will do this randomly and it is the up to the modeler to assign different textures to all the items with the proper prefixes.

    Also in this version i inversed the percentages so they make more sense. Now if you choose 20%, 20% of the selected objects will be selected and the nite_ tag added to the beginning of the object's name.

    Alright, I gotta try and do some modelling now <ahttps://community.simtropolis.com/assets/emoticons/9.gif> but this code stuff is kinda fun!

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    First of all, I'd like to say that you guys are doing a great job on this.  You're making a lot of progress in a short amount of time.  I just wish that I had a little more time to contribute to the effort.<ahttps://community.simtropolis.com/assets/emoticons/25.gif>
     
    Somthing else I have discovered upon further testing is that the percentage value you input is actually the percentage of objects that will remain in the selection.
     
    Actually, that was kind of the point of the script when I first designed it.  The idea was to select a group of objects, run the randomizer, and then assign night lighting using the Parameters rollout of the BAT utility.  That way you could set the intensity, freeze that group and then run through the whole process again with the remaining objects (setting a different intensity each time).  If you look at the script, the variable name, windowswanted, was actually a misnomer because it was actually the number of windows not wanted.  Sorry for the confusion on that.
     
    -red

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Ok, I can add that back in, I think I will add it instead of changing it, so you have the choice. The colorize windows thing worked out great for me. I am going to run over to my Azubre Corporate Office thread and upload a pic i made this morning at home showing the random windows color. There is a link to the thread in my sig.

    I still have not been able to find the controller for the intensity setting in the max scripts that come with the BAT. I'm going to post a message over at maxis and see if anyone there can help us out with that.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    No need to add the inverting into the script.  I have found the controls for intensity.  Attached is cerulean's script with the new intensity randomizer.  Now all we have to do is give the script a thorough run through to make sure that there aren't any bugs.  If you're using this script, please let us know how it works.  If no one finds any bugs or problems in the next week, I'll post this to the mods section of the site.
     
    Thanks for all your help,
     
    -red

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    Cool! That looks like it will work well! I will test it tonight!
     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    I thought of something that might speed this script up a little.
    Can we stop gmax from updating the views after each object is selected? then regen all the views when the script is done? Im sure this is possible, and bet it would speed it up a little. Its not too slow now, but it could be faster...

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    One thing that would be useful is spinners for the max and min value from the intensity randomize statement, so you don't have to edit it manually. Other than that this is a very useful script <ahttps://community.simtropolis.com/assets/emoticons/9.gif>
    *<ahttps://community.simtropolis.com/assets/emoticons/24.gif width=17>*<ahttps://community.simtropolis.com/assets/emoticons/24.gif width=17>*<ahttps://community.simtropolis.com/assets/emoticons/24.gif width=17>*<ahttps://community.simtropolis.com/assets/emoticons/24.gif width=17>*<ahttps://community.simtropolis.com/assets/emoticons/24.gif width=17>*

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account

    Sign In to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections