PDA

View Full Version : Can I replace all layers in a layout object with the same layers from another?



starbase1
11-04-2013, 07:10 AM
Subject line pretty much says it all - I have a complex object with many layers set up in a scene, and I'd like to replace all layers from one version with all layers from a different version.

I can do it one layer at a time, but it would be a lot less error prone and time consuming to do the whole lot in one hit. Is this possible?

LW 11.5

Nick

JoePoe
11-04-2013, 07:16 AM
Can you, with layout closed, simply rename the new object with the old objects name and place it in the the right path?
(do whatever naming backup dance you need to do first of course).

Once that's done, with both open, save the object with the name you really want and it will update automatically. Yes?

Waves of light
11-04-2013, 07:20 AM
You can open up the .lws file in a text editor and do a find and replace on the object ID. But be careful, backup everything first before attempting this.

For instance, in my current scene file there is a line that I believe calls the object file and then places it in the scene:

'LoadObjectLayer 43 10000016 Objects/_MyProjects/Arch_Viz/Football_Stadiums_Brazil2014_obj/Maracana_Stadium_v048.lwo'

so I would just do a find and replace using:

Football_Stadiums_Brazil2014_obj/Maracana_Stadium_v048.lwo

to

Football_Stadiums_Brazil2014_obj/Maracana_Stadium_v049.lwo

Save the file and see if it opens up in layout correctly, then incrementally save your scene file, just to be on the safe side.

I messed up one of my scene files, because I did the above routine and there were instances of a single referenced objects and it didn't seem to like that. When I re-opened the scene file, it took ages for it to load and there were no instances of the object in the scene.

EDIT: And by instance, I mean Add | Clone | Clone Instance.

Cheers,

Ricky.

starbase1
11-04-2013, 08:36 AM
Thanks for the suggestions - I had thought of renaming away the object, but then other scenes that use it would not find it. And the manual editing of the scene file is a bit of a kludge...

Given that there are replace with object commands, I was hoping to have missed an option with this. The way it works at the moment feels like a hangover from when object files had only one layer...

jeric_synergy
11-04-2013, 10:39 AM
If I understand what you're saying: YES, it does seem like a hangover.

When one replaces a "object" which is a layer in a multi-mesh, shouldn't we get a dialog asking if all the other objects/layers from that new source file be replaced also????

This seems like the kind of SIMPLE "feature" that could (and maybe HAS) be easily addressed with a script. "Better Object Replace.lws" would be a good name.

nickdigital
11-04-2013, 10:49 AM
If you replace the first layer associated with an object it will swap out all the layers associated with it.

However, if you've imported a layer manually, that layer has no relationship with the first layer as that "load object" operation is separate from your other "load object" operation.

I was working on a script that made doing this more intelligent. I believe Dodgy was as well. The problem is that there's no way to get the index id of a layer. Checking which layer is what is done by comparing the name of the layer so the script is dependent on someone giving all their layers unique names. If all the layers are called "unnamed" then the script will fail. I'd say submit a request to get index id via lscript/python. Then you, or we could finish our scripts.

Doing a find/replace in a text editor on the lws file is your quickest solution right now.

jeric_synergy
11-04-2013, 11:00 AM
so there's no programmatic way to determine the source file name, and search the scene for similar?

Is the id# you refer to on the Layout or the Modeler side?

I'm hoping they get this facility into Python: seems like that would be a really handy bit of info to have accessible.

JoePoe
11-04-2013, 11:22 AM
....but then other scenes that use it would not find it.

"My" methods specifically addresses this.
Once the new file is in place and renamed give the original it's original name again. It will be where it needs to be and named correctly for everywhere else it's used.

It sounds convoluted but it's really only four naming steps.

It's a little like an easy setup of the classic Tower of Hanoi game. :)

nickdigital
11-04-2013, 11:30 AM
so there's no programmatic way to determine the source file name, and search the scene for similar?


No, there is a way. My script works for my needs but I'm also very careful to give my layers unique names. So it works. However for me to release it as a gift to the LW Community, I'd want it to be as fool proof as possible. The current way we can determine Modeler layers is not fool proof



Is the id# you refer to on the Layout or the Modeler side?


It'd be on the model file side...so it wouldn't be specific to L or M.

jeric_synergy
11-04-2013, 12:35 PM
Nick, perhaps a helpful adjunct would be a Modeler script that at least gave simple unique names to all unnamed layers.

SIDE NOTE: I almost always have more Hidden layers than Visible/Active -- in fact I've requested a preference switch where all Layers START as Hidden*, and are only made active by user intention-- and usually I'll add an "NV" to a Layer Name to indicate/document that I don't want to see the layer. (*This would prevent the common-for me- mistake of when I make, say, a CUTTER layer, and it gets sent to Layout when I don't want it to.)

If I were to write the script above, I'd add a function where "Occupied but non-visible Layers" got names that started/ended in "-NV-".

nickdigital
11-04-2013, 12:41 PM
Nick, perhaps a helpful adjunct would be a Modeler script that at least gave simple unique names to all unnamed layers.

Define "simple". :D

If the LWG can add the layer index that'd be the best solution, instead of some wonky hack workaround. Submitting a feature request would be my suggestion, instead of someone spending the time to make a lscript that has limited usefulness.

Waves of light
11-04-2013, 12:46 PM
Thanks for this Nick, it'll be interesting to see what you come up with.

jeric_synergy
11-04-2013, 12:49 PM
Define "simple". :D
Yes. :) I'd probably go with"Auto-(systemclocktime)", or "NV-Auto-(systemclocktime)" in the case of a non-visible layer. Or, the Layer Number. (The latter has the advantage of brevity, and I'm still not happy how hard LW makes it to see and USE long layer names.)

Obviously, the more parameters LWG can expose to Python and LScript (which they should probably just abandon, as Bob's time is 'WAYYYYYyyyyy better spent on Python IMO) the better. I'm not sure why we have to keep beating THAT drum. The more hooks scripters have to use, the more they can bend the software to their own uses.

nickdigital
11-04-2013, 01:03 PM
....

If I were to write the script above, I'd add a function where "Occupied but non-visible Layers" got names that started/ended in "-NV-".

I believe what you described is very do-able. Your script would iterate through all the layers, and just turn off any layer that contained the string "-NV-".

jeric_synergy
11-04-2013, 01:38 PM
I believe what you described is very do-able. Your script would iterate through all the layers, and just turn off any layer that contained the string "-NV-".
Well, that would be another function, part of the "assign unique names" function, really sort of the inverse. But it could be part of suite of "hidden layers" functions. Since I almost always only have one or two IMPORTANT layers, e.g. "Main" and "Eyes", turning them ON is usually trivial compared to turning OFF nineteen 'work layers'.

I've rather garbled this up, so to recap:

1) to use YOUR system, Nick, an "auto-namer" would be desirable to avoid the labor of naming layers when it's not all that important for documentation purposes, ie. only uniqueness matters
2) for my workflow, adding "-NV-" to already Hidden layers would be desirable, and
3) "Auto-hiding" layers with "-NV-" in their Layer name would also be desirable.

spherical
11-04-2013, 01:48 PM
I put all work layers in another similarly named object. Keeps the actual model clean and small.

jeric_synergy
11-04-2013, 06:20 PM
I put all work layers in another similarly named object. Keeps the actual model clean and small.
You are 'WAY more organized than I.

Also, usually the work layers are pretty light: Boolean cutters, measuring sticks, alignment rulers.

spherical
11-04-2013, 07:39 PM
Hehhehheh. Some of my work parts are light but it's all cruft when it comes to loading the model in a scene. I'd just as soon have a file that I can duplicate layers and modify as much as I like and save them all, without having to be concerned about how big it gets or make sure the non-rendering layers are turned off before saving. Too many times I've loaded a model that had work parts in it and wondered where this big box came from. And, if I have versions of an object, I can use the same work parts file with them. Don't have to wonder which model that one specific X cutter is in and/or have all of those work part layers duplicated in all of the versions.

Waves of light
11-05-2013, 02:49 AM
I have a layer called 'Junk', which is always turned off/invisible in the layers tab in Modeler, so that it doesn't get sent to Layout. In there are all my splines, curves, stuff for booleans.

starbase1
11-05-2013, 03:19 AM
Well the models in this case are fairly complex, and need a lot of layers - it's actually the Soviet N-1 moon rocket, and each stage is in a different layer, various steering rockets have layers so they can move independently, the fairings each have a layer, as does the escape system, the payload modules and so forth.

There are also four variants of the entire rocket, so I'm often in a position where I have set up a complex holder scene for one variant, and then want to produce the same renders for another.

If I start renaming the N1-6L as the N1-7L etc, then the opportunities for confusion are limitless!

This really should not be that hard.
Nick

Waves of light
11-05-2013, 03:41 AM
Yes, I can see how the normal methods aren't going to work in your case. It's not just a simple task of swapping out one model for another.

jeric_synergy
11-05-2013, 10:15 AM
This really should not be that hard.
Nick
You'll get no argument here. :)

JoePoe
11-05-2013, 03:11 PM
:stumped:
Sorry guys, don't see what's so hard here.
The complexity of the model is irrelevant. Only that they have the same number/order of layers. 2 layers or 6 thousand.... whatever.

The key is the number of lwo's. I thought you were going to say dozens.... but 4? That should not be that confusing.

Yes, each model will have to have the name of one of the others..... for about 30 seconds. All you're doing for that 30 seconds is opening the lws and lwo. Once that's done the name gets changed right back.
For the other three steps use names like "N1-7L Backup" "N1-7L Temp" and "N1-6L Original".
And when you're done you're left with four, and only four, models. None of the Temps/Originals stick around to confuse you.

I just did a test in a couple of minutes.
I think you're psyching yourself out of it because it's a big bad Soviet moon rocket. Think of it as kittens :D.

Want to send me a couple files? I'll switch it out for ya. (uh if the models aren't too poly heavy (like over 500k)..... my computer is on life support :))

jeric_synergy
11-05-2013, 03:51 PM
How could we automate that process? Reduce the time to , oh, 10 seconds?

nickdigital
11-05-2013, 04:00 PM
Doing the recommended text editor find>replace technique doesn't take very long. TBH, the process of clicking objects to select what you want to replace in Layout would take longer.

JoePoe
11-05-2013, 04:02 PM
How could we automate that process? Reduce the time to , oh, 10 seconds?

No, I realize there's a secondary conversation on how to code a solution going on. Obviously I'm all for 10 seconds :) Hey why not 1 :D. Please, code on.

I was just responding to Starbase's last comment. He's got to get it done now, and I think it's doable without too much trouble (as un-automated as the solution(s) at hand may be....lwo naming route or text editor option). :beerchug:

jeric_synergy
11-05-2013, 04:12 PM
Worst-case I'd say that it ought to be possible to have LW-python do the text replacement. It'd probably be dog-slow, but it'd be automatic.

I miss AREXX-- a language that ALL one's applications could use and share data? Not, TMK, nowadays. :(

dwburman
11-05-2013, 04:18 PM
I typically go through the text editor route, but usually I duplicate the scene file ("demoscene_v011.lws") in the OS ("Copy of demoscene_v011.lws") which I then rename and increment manually ("demoscene_v012.lws"), so I don't accidentally mess up the working version of the scene.


The demoscene used to be cool.

JoePoe
11-05-2013, 04:25 PM
Worst-case I'd say that it ought to be possible to have LW-python do the text replacement. It'd probably be dog-slow, but it'd be automatic.

I miss AREXX-- a language that ALL one's applications could use and share data? Not, TMK, nowadays. :(

Well, I don't know about all that....... literally ;D.

But, I did just try out the simple text editor method, and I don't know why (:foreheads) I wasted the couple minutes earlier. It truly was about 10 seconds....tops. :thumbsup:

nickdigital
11-08-2013, 03:26 PM
It looks like layer id has been exposed to lsript.
http://forums.newtek.com/showthread.php?134007-Get-Layer-number-from-Layout

So I can finally finish my scripts. Happy Friday!

starbase1
11-08-2013, 04:00 PM
Thats something to look forward too!

jeric_synergy
11-08-2013, 04:29 PM
It looks like layer id has been exposed to lsript.
http://forums.newtek.com/showthread.php?134007-Get-Layer-number-from-Layout

So I can finally finish my scripts. Happy Friday!
Awesome!!! Just coincidence, or PDTB? (Progress Due To Bellyaching) :king:


PS: just LScript, or Python also?

nickdigital
11-08-2013, 04:31 PM
Awesome!!! Just coincidence, or PDTB? (Progress Due To Bellyaching) :king:


PS: just LScript, or Python also?

I hope it was due to PDTB cuz I've bugged Bob about it.

If it's in the lscript it should be accessible to Python as well. All my stuff is in lscript cuz I'm not that strong in Python yet.

jeric_synergy
11-08-2013, 05:11 PM
I looked at Python but then I got a nosebleed. Looked bloody verbose, but it's the Future.