Page 4 of 5 FirstFirst ... 2345 LastLast
Results 46 to 60 of 64

Thread: Incremental Saver (Modeler)

  1. #46
    riki, have you tried the saver posted? i use save() once, and it is to save the object as it is, but save the actual increment using copyfile(). i think that's a good bypass.

    if you have my saver, go to the line (somewhere at line 56):

    Code:
    	save(meshFilename);
    change that to:

    Code:
    	sp = split(meshFilename);
    	newmesh = string(sp[3],[sp4]);
    
    	save(newmesh);

    see if that works.
    "The hardness of God is kinder than the softness of men, and His compulsion is our liberation." - C.S. Lewis


  2. #47
    Oh thanks for that, nice to know I wasn't going crazy

    yep yep I'll give your work around ago, just hitting the pisss at the moment Thank god the weekend is here.

  3. #48
    Hi faulknermano, I tried your original script and I was getting the same sort of problem.

    I just tried the suggested changes and got an error message

    "In main, Line 57, found '[' parse error.


    Code:
    @warnings
    copyfile: in, out
    {
    	in = File(in,"rb");
    	if(!in)
    		return(-1);
    
    	out = File(out,"wb");
    	if(!out)
    	{
    		in.close();
    		return(-1);
    	}
    
    	while(1)
    	{
    		b = in.readByte();
    		last if in.eof();
    		out.writeByte(b);
    	}
    
    	in.close();
    	out.close();
    
    	return(0);
    }
    main // incremental saver
    {
    	selmode(GLOBAL);
    	md[1] = nil;
    	objectDir = getdir(OBJECTSDIR);
    	meshFilename = Mesh(0).filename; // fullpath
    
    	mesh = Mesh() || error("No mesh.");
    	m = 0;
    	while(mesh)
    	{
    		m++;
    		if(mesh.name == "Unnamed")
    			error("<br>Object number ",m," is unnamed.");
    		mesh = mesh.next();
    	}
    
    
    	if(meshFilename == nil)
    	{
    		if(pointcount())
    		{
    			f = getfile("Save Object As...","*.lwo",objectDir);
    			if(f)
    				save(f);
    		}
    		return;
    	}
    
    	sp = split(meshFilename);
    	newmesh = string(sp[3],[sp4]);
    
    	save(newmesh);
    
    	(d,p,f,e) = split(meshFilename);
    
    	s = string("backup_",f);
    	md = matchdirs(objectDir,s);
    	if(md.size() > 1)
    		error("More than one matching directories were found. Aborting.");
    
    	if(!md) // no folders exist
    	{
    		// create a folder
    		str = string(d,p,"backup_",f);
    		mkdir(str);
    		backupDir = str;
    	}
    	else
    		backupDir = string(d,p,"backup_",f);
    
    	// scan the backupdir
    
    	dd = date();
    	d1 = dd[1];
    	mon = dd[2];
    	year = dd[3];
    	tt = time();
    	h = tt[1];
    	m = tt[2];
    	s = tt[3];
    	day = string(d1);
    	mon = string(mon);
    	year = string(year);
    	
    	if(day.size() < 2)
    		day = string("0",day);
    	if(mon.size() < 2)
    		mon = string("0",mon);
    
    
    	hs = string(h);
    	ms = string(m);
    	ss = string(s);
    
    
    
    	if(hs.size() < 2)
    		hs = string("0",hs);
    	if(ms.size() < 2)
    		ms = string("0",ms);
    	if(ss.size() < 2)
    		ss = string("0",ss);
    
    	finalName = string(year,"_",mon,"_",day,"_",hs,".",ms,".",ss); // finalName is the incremented save
    
    	mf = matchfiles(backupDir,"*.lwo");
    	if(mf.size() >= 15) // start replacing
    	{
    		mf.sortA();
    		str = string(backupDir,"\\",mf[1]);
    		a = filedelete(str);
    	}
    
    	newFile = string(backupDir,"\\",finalName,".lwo");
    	a = copyfile(meshFilename,newFile);
    	
    }

  4. #49
    whoops!

    the code below you see:


    Code:
    newmesh = string(sp[3],[sp4]);
    should be:

    Code:
    newmesh = string(sp[3],sp[4]);

    when you say "same problem", are you saying about the paths problem? that the files are still not being saved? (stretching this issue just a little bit more... )
    "The hardness of God is kinder than the softness of men, and His compulsion is our liberation." - C.S. Lewis


  5. #50
    Hi faulknermano, okay we made some progress

    It's saving the file, but a few problems.

    I started out with an object called 'test.lwo' and this file is keep of course in the 'Objects' directory.

    When I run the script it saves the file in the 'Content Directory' and the file is being saved with the same name 'test.lwo'.

    If I run it again it gets saved on my Desktop and then if I run it again it causes my system to freeze up.

    Also I noticed a text file was created called 'backup_'

  6. #51
    okay.. well i think lscript is screwed up big-time now. i think all file management stuff has gone nuts in mac lscript.

    the text file you mentioned is actually supposed to be a folder. the idea of the saver is to create a folder for every object you save and then the script saves it on its own folder; the names will be the data and time of the save.

    in your case, it doesnt seem that the 'manual' way of saving a file (e.g. using copyfile() to copy the original saved file to another place) isnt even working.

    here, i most vote to go back to 2.5.1 (you wont miss that much), unless you dont really need an increment saver.
    "The hardness of God is kinder than the softness of men, and His compulsion is our liberation." - C.S. Lewis


  7. #52
    Thanks for all your help faulknermano. I'll probably just do without for the time being, hopefully they'll get it sorted with the next update. Bloody frustrating though

  8. #53
    Polyvore richpr's Avatar
    Join Date
    Feb 2003
    Location
    Montréal, Canada
    Posts
    493

    Lightbulb

    Try this version of the previous script in this thread, here all the files just end up in the objects directory, but you could change that in the last couple of lines.... It does not create a directory or anything... your object and copes with the date tacked on all end up in objects/ or objects/project/ if you would change it...

    Hope this one works, tried it here (PC) and it works...


    // Incremental Saver uses ObjectName_v_YYYYMMDDHHMMSS.lwo
    @version 2.0
    @name IncSaveD
    @warnings

    main
    {
    selmode(GLOBAL);
    md[1] = nil;
    objectDir = getdir(OBJECTSDIR);
    meshFilename = Mesh(0).filename; // fullpath

    mesh = Mesh() || error("No mesh.");
    m = 0;
    while(mesh)
    {
    m++;
    if(mesh.name == "Unnamed") error("<br>Object number ",m," is unnamed.");
    mesh = mesh.next();
    }

    if(meshFilename == nil)
    {
    if(pointcount())
    {
    f = getfile("Save Object As...","*.lwo",objectDir);
    if(f) save(f);
    }
    return;
    }
    sp = split(meshFilename);
    newMesh = string(sp[3],sp[4]);
    save(newMesh);

    finalName = parse("_v_",sp[3]);
    if (!finalName)
    {
    finalName[1]=sp[3];
    }
    finalName[1] += "_v_";

    dd = date();
    d1 = dd[1];
    month = dd[2];
    year = dd[3];
    tt = time();
    h = tt[1];
    m = tt[2];
    s = tt[3];
    day = string(d1);
    month = string(month);
    year = string(year);

    if(day.size() < 2) day = string("0",day);
    if(month.size() < 2) month = string("0",month);

    hs = string(h);
    ms = string(m);
    ss = string(s);

    if(hs.size() < 2) hs = string("0",hs);
    if(ms.size() < 2) ms = string("0",ms);
    if(ss.size() < 2) ss = string("0",ss);

    finalName[1] = string(finalName[1],year,month,day,hs,ms,ss);
    newFile = string("objects/",finalName[1],".lwo");
    save(newFile);
    newFile = string("objects/",newMesh);
    save(newFile);
    }


  9. #54
    Polyvore richpr's Avatar
    Join Date
    Feb 2003
    Location
    Montréal, Canada
    Posts
    493

    Talking

    The formatting turned out pretty horrible, so here's the ls file attached as a zip
    Attached Files Attached Files

  10. #55
    Polyvore richpr's Avatar
    Join Date
    Feb 2003
    Location
    Montréal, Canada
    Posts
    493
    Here's a variation that is path aware... at least folder + filename and adds a number at the end... real increment... no 0 padding though... so you get Object_v_1.lwo, Object_v_2.lwo, etc.

    Tried it six times, no problem...

    A box was saved in <content>/objects/project/test.lwo

    and after 6 clicks it was at test_v_6.lwo...

    Both versions of the scripts also keep the test.lwo around... which would be better if you were working in Layout at the same time...
    Not sure if the temporary save with the number or the date has an effect on the scene in Layout... needs to be tested

    [Edit] I added padded versions to the zip as well... these are called incsaven2, incsaven3 and incsaven4.ls... they increment and pad with zeroes (for nicely sorted folders!) , like object_v_0001.lwo for incsaven4.... [Edit]
    Attached Files Attached Files
    Last edited by richpr; 07-19-2003 at 06:53 AM.

  11. #56
    Thanks richpr

    I think I have to give up on this one. I tried the scripts but still no luck. I guess the save function for Lscript on the mac is pretty much messed up. I'll hold onto them though, hopefully with the next update they'll get it sorted.

    Thanks again everyone for your help.

  12. #57
    Polyvore richpr's Avatar
    Join Date
    Feb 2003
    Location
    Montréal, Canada
    Posts
    493
    That's a shame... either wait or play around with an older LScript version...

  13. #58
    Yeah hopefully they'll pick this up. I've mentioned it in the Sticky Mac Bug thread.

    I like the idea of saving the date.

    It seems to be working on my system, I run the script and I can see the time stamp, but when I check in the objects folder, there's nothing there. Just the original test.lwo

    It's strange becuase even when I'm quiting out of modeler, after running the script, it asks me if I want to save. I press yes, it quits, but still no file. Very frustrating.

  14. #59
    Polyvore richpr's Avatar
    Join Date
    Feb 2003
    Location
    Montréal, Canada
    Posts
    493
    Not in the content folder either?

  15. #60
    No not saving it at all, anywhere.

    When I tryed the second script it was saving a file called 'Desktop Folder'. The first time it saved it in the Content folder and then the 2nd time I ran the script it saved it on the Desktop.

Page 4 of 5 FirstFirst ... 2345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •