[Closed] Possible to automate the creation of 1000s of objects?
Hi Dan,
What I’m thinking is that my client may already have a database of all the variations and it would just be a case of re-structuring it to make it usable in the Max script.
With regards to the timeline / deleting the variations, I guess this is something that with a few tests I’d see where the limitations lie. Your idea of batching a group together sound like a good option, and might be useful to group / batch them to aid in organisation too.
Cheers,
Dean
what is next?
#2 we need CSV parser
#3 the way to apply it
ok. here is a scripted modifier that does do this two things:
plugin Modifier FrameControl
name:"Frame Guide"
classID:#(0x00196700,0x1774a7c1)
(
fn getNode = refs.dependentnodes (refs.dependents this)[1] firstonly:on
parameters data rollout:params
(
filename type:#string default:"" ui:ed_filename
)
fn readCSV file: =
(
local data = #()
if doesfileexist file and (ss = openfile file) != undefined do
(
while not eof ss do
(
s = readline (trimleft s " ")
if s[1] != "#" do
(
params = filterstring s ",;"
d = for p in params where (v = p as float) != undefined collect v
append data d
)
)
close ss
)
data
)
fn updateData = if (data = readCSV file:filename) != undefined do animate on, redraw off
(
local props = #(#width, #height, #depth, #topWidth, #sideWidth, #bottomWidth)
node = getNode()
deletekeys node
for k=0 to data.count-1 do at time (k*5)
(
d = data[k+1]
for i=1 to d.count while i < 7 do setproperty node props[i] d[i]
)
)
rollout params "Parameters"
(
edittext ed_filename readonly:on fieldwidth:151 align:#left offset:[-12,0]
button load_bt "Load..." width:75 align:#left offset:[-8,2] across:2
button update_bt "Update" width:75 align:#right offset:[8,2]
on load_bt pressed do undo "Frame Control" on
(
file = getOpenFilename caption:"Load Frame Guide File" filename:filename types:"Frame Guide (.csv)|*.csv"
if file != undefined do
(
filename = file
updateData()
)
)
on update_bt pressed do undo "Frame Control" on
(
updateData()
)
)
on attachedToNode node do
(
--format "attach... % %
" node (classof node.baseobject)
if not iskindof node.baseobject FramePlus do deletemodifier node this
)
on update do
(
--format "update... %
" target
)
)
to be continued…
everything is solved… there is no problem to add position and rotation to the CSV file… no ploblem is to add background plane for the image…
what is the real problem? the real problem is the frame style. how to use different profiles for the frame shape and… AND have the frame shape animatable?
sweep modifier? its shape is not animatable.
lofter? the same thing.
any other ideas?
i promised to continue as i have a time…
Okay. Here is how to make frame profile animatable, which give as ability change profile on-fly
delete objects
(
r = rectangle name:"frame" wirecolor:orange
s = Sweep CustomShape:1 SmoothSection:off SmoothPath:off
p = converttosplineshape (arc name:"profile" radius:1 pie:off from:0 to:180 wirecolor:yellow)
-- for k=1 to numknots p do setKnotType p 1 k #corner
setKnotType p 1 1 #corner
setKnotType p 1 4 #corner
s.shapes[1] = p
addmodifier r s
animatevertex p #all
updateshape p
c = p.baseobject[#master]
animate on for k = 1 to 20 do at time (t = (k-1)*5)
(
r.width = random 10 50
r.length = random 10 50
radius = (random 0.02 0.1)*(amin r.width r.length)
pos = c[2].value
pos.x = radius
c[2].value = pos
pos = c[11].value
pos.x = -radius
c[11].value = pos
pos = c[5].value
pos.x = (random 0.5 1)*radius
pos.y = (random 0.5 1)*radius
c[5].value = pos
pos = c[8].value
pos.x = (random -0.0 -1)*radius
pos.y = (random 0.2 1)*radius
c[8].value = pos
--format "% = % > % % % %
" t radius c[2].value.x c[5].value.x c[8].value.x c[11].value.x
)
)
we can have a list of presets and using one from the list set knot points and in/out tangents. that’s easy…
Enjoy!
Hi Denis,
Thanks for your scripts! Although its way over my head, I can see how you have gone about building them and your method.
Instead of being able to control the dimensions of the frame, it would be easier to control a profile for a sweep modifier, and the size of the rectangle to define the overall size. The frames / profiles would all be handmade before, so it would be a case of switching from one profile to another, so as long as the naming lined up with the script control, it should be pretty straight forward to switch between the variations, and for switching between the photos, I presume you can script to change the bitmap files directly?
The main problem lies with how to automate this process 1000s of times, as Dan pointed out, ideally I don’t want to be submitting 1000s of files to a renderfarm, but at the same time I don’t want to have an uncontrollable Max file.
Is there by chance a way to do some post-rendering scripting where once the file has rendered it somehow moves to the next variation, maybe even perhaps through xrefs, or even changing the directory for which the max file is located?
With the load times, would it make any difference not going though something like Backburner, but perhaps straight from Max? I know it’s a little backwards, but would cut down the load times of Max.
Sorry I’m thinking out loud here, if I don’t make much sense let me know!!
I would look at generating an Image-File-List IFL for texture variations then using a CSV file to animate values in max and thus you could send one job to Backburner and it would render all permutations. The next problem comes though from dealing with having one long sequence of images Render_0001.jpg etc… and how you can use these files after they’re done.
right. that was the first what i thought about. but i asked myself after. why is it just a texture change? do we happy to have the same material for all our screens and frames? we have different profiles for frame but we have the same material for all of them. does it make sense?
so… we will change material on-fly as well of course it’s kinda silly to have 1,500 materials just because they all have one different picture… so we will need system to re-use any shader by changing its textures(diffuse, specular, bump/normal).
yes. normal map. what if i want to have my portrait painted in oil? why do i have to have only a glossy photo?
Hi Dave,
That’s the less complicated part in my opinion as I can set-up an After Effects files to load in all these files as sequences and spit them back out exactly as I need them.
Thanks for the tip on using IFL by the way!!
Cheers,
Dean
Backburner still has to load up 95% of itself, so it’s only slightly less demanding in terms of loading and whatnot. What you could do, however…
There’s a thing that ships with Backburner called cmdjob.exe. It allows you to submit windows command line scripts to backburner. This includes the ability to open max using the command line, and when opening max from the command line you have the option to have it automatically run a script. So what you could do is have your script which…
- Reads the .csv file
- Works out how many “tasks” it needs to perform (say, it needs to create and render 1,500 frames)
- Split this into smaller tasks – say, a group of 150 at a time, so you have ten separate jobs.
- Your script then writes out a bunch of maxscript code to 10 external files (which are actually text files, but you can name .ms [maxscript] files.
- You submit 10 jobs to backburner via cmdjob.exe, each job to open max and run one of the 10 scripts.
What is inside those 10 scripts are the meat of what you want it to do – the lofts and lathes or the sweeps etc. It could be set to create one, render it, delete all. Create the second, render it, delete all. Etc. The last line in this script is to quit max.
This way, your main script doesn’t actually contain any of the code that creates the variations. What it contains is the ability to write those lines of code into other scripts. This has the benefit of not only working well with backburner, but you also a) don’t need to send too many jobs b) leverage your render farm to render the tasks and c) leverage your render farm to actually process the creation of these bits of geometry. If you have more than 10 render nodes, you can split the task up into 100 separate files, or 1000. It’s up to you.
(I use a similar system here to make changes to files before submitting them to render. Strictly speaking, there’s no reason why this needs to be done via cmdjob.exe and a separate script, except that cmdjob.exe tasks in backburner support dependencies where as submitting raw max renders to backburner from maxscript does not… for some mad reason.)
i’m absolutely sure that there are many cool and smart solutions with multiple files or multiple nodes in the same file. but this is not my point… finally i want to have only one file, with only one node, and CSV file that controls everything. CSV file could be made by a clerk of a hair-cut saloon or a funeral home. who doesn’t know what 3ds max is. but the system must work anyway
Denis, I think you hit the nail on the head, if someone with no knowledge of Max, programming or such, can generate the info needed to automate the process, then that’s what I need to aim for. There would be some inital set-up needed such as manually creating the frames, but the rest should be automatic.
Thanks for all your input guys, I think that gives me enough info for now. Like I said I’m not looking to actually build the script at the moment, but just wanted to check the feasibility of doing something like this with programming, and if the project progresses in this direction I’d then look to have someone to build it.
Cheers guys,
Dean