PDA

View Full Version : Rename multiple selected surfaces in the Surface Editor...



lardbros
01-07-2014, 10:22 AM
Please please please can I have the ability to multi-select surfaces in the surface editor, and right-click and rename them ALL... not just the one I happen to right-click on!

This drives me crazy! Having to rename 100 surfaces that have all been called the same due to the FBX importer being a bit crappy, not recognising that a material 'Metal' on one object isn't the same as 'Metal' on another, and calls it 'Metal01' instead... is completely unnecessary.

This should be really simple! Please, please, please either fix the FBX importer (loading into Modo first, and then exporting as an .lwo works fine, so Luxology know what they're doing!!!) or let me rename multiple selected surfaces!! PLEASE!!??

Thanks,
Tim

lertola2
02-04-2014, 10:02 AM
I am struggling with this issue now also. I think I remember that someone wrote a script to solve this problem. But I can't find the posts now. The stupid forum broken search function is apparently never going to be fixed.

inkpen3d
02-04-2014, 10:56 AM
At the top of the surface editor there's a drop-down menu "Edit by" where you can select either "Object" or "Scene". If you select "Scene" then all surfaces with the same name are grouped together into one entry in the "Surface Name" list. Select the given surface you want to rename and then use the "Rename" button in the top right of the panel to rename the surface. Save your model(s) and remember to return the "Edit by" back to "Object". This works the same in both Modeler and Layout.

Hope that helps.

Edit: Ah, sorry, misread your post. Ignore what I said as it won't help your particular problem.

Regards,
Peter

ernpchan
02-04-2014, 10:57 AM
Do these help?

https://www.lightwave3d.com/assets/plugins/entry/surface-rename-editor/
http://forums.newtek.com/showthread.php?103552-Plugin-Script-Batch-Rename-Surface-and-Object-Layer

jeric_synergy
02-04-2014, 11:13 AM
Just a red flag: is the "By Name" switch 'destructive', i.e. global and non-reversable? Just sayin' it might be well to step carefully with it.

inkpen3d
02-04-2014, 11:34 AM
Just a red flag: is the "By Name" switch 'destructive', i.e. global and non-reversable? Just sayin' it might be well to step carefully with it.

Agreed. Though it does pop up a warning when selected. However, as I said in my edit, I don't think that method will help with this particular problem. :(

lertola2
02-04-2014, 12:25 PM
Do these help?

https://www.lightwave3d.com/assets/plugins/entry/surface-rename-editor/
http://forums.newtek.com/showthread.php?103552-Plugin-Script-Batch-Rename-Surface-and-Object-Layer

I was very hopeful that one of those would solve this problem but neither does as far as i can tell. They both will let you rename surfaces by adding a prefix or suffix but they will not combine multiple surfaces into one. Lightwave's fbx exporter gives each object a different surface name by appending a number to it. So if you have 100 clones of a box, for example, and you want to combine them into one object by exporting an fbx file from Layout and opening it in Modeler then you end up with 100 different surfaces like box_1, box_2, box_3 etc. Maybe I am mis-remembering but I thought there was a thread recently where some one brought this up and someone else wrote a script to solve the problem.

ernpchan
02-04-2014, 01:32 PM
So in your example, you want to assign the surface 'box_1' to all the boxes?

iain_r
02-04-2014, 01:59 PM
You can try these python scripts. They do the same but the file with mon in the name has monitor functions to display an update, makes it run slower.

You can also try this lscript if you wish, contains monitor as well.


@version 2.2
@warnings
@script modeler
@name "Change Surface"

main{

reqbegin("Change Surface");
reqsize(300,100);
c1 = ctlstring("Surface to Replace", "");
c2 = ctlstring("New Surface", "");
return if !reqpost();
osurf = getvalue(c1);
nsurf = getvalue(c2);
reqend();
tokens = parse(",", osurf);
nt = size(tokens);
setsurface(nsurf); // new surface
surfObj = Surface(nsurf);
surfObj.setValue(SURFCOLR, <118, 118, 118>); // just a colour for a basic window
currSurf = nextsurface();
s = 1;
while(currSurf != nil){
s = s + 1;
currSurf = nextsurface(currSurf);

}
moninit(s, "Processing Surfaces");
currSurf = nextsurface();
while(currSurf != nil){
selmode(USER);
selpolygon(SET, SURFACE, currSurf);
for(i=1; i <= nt; i++){
t2 = "^" + tokens[i];
expr = regexp(t2);
if(expr == nil)
return;
if(currSurf == expr){
changesurface(nsurf);
}
monstep();
}
currSurf = nextsurface(currSurf);
selpolygon(CLEAR);
}
monend();
}

Regards

Iain

lertola2
02-04-2014, 07:36 PM
You can try these python scripts. They do the same but the file with mon in the name has monitor functions to display an update, makes it run slower.

You can also try this lscript if you wish, contains monitor as well.

...

Regards

Iain

Thanks Iain but none of those scripts seem to work. The Change Surface script is changing all polygons to the new surface, not just polygons that contain the search text in their surface name. The Enumerate Surface gives each selected polygon a unique surface name. And the script you pasted in the code box gives me a python error when I try to run it.

lardbros
02-05-2014, 06:23 AM
I'm kind of glad that someone else has come across this pretty major issue with FBX. I've been on at Newtek for quite some time to sort this, and never got anywhere.

I have the exact same problems as you lertola. I want to select multiple surfaces (which have different names, like metal001, metal002... ...) and rename them to the same (metal, for instance).

I tried the plugin that is meant to help manage surfaces, but it has the same issue as the built in LW Surface Editor. You can multi-select surfaces, but as soon as click re-name it'll just do the surface underneath the mouse-click. VERY frustrating!



Think it's a bit of a case of people reading the initial problem, and thinking they understand it entirely. It's only when you attempt to load a complex FBX from 3dsMax that you realise how horrendous the material/surfaces are dealt with in LW :(

lardbros
02-05-2014, 06:26 AM
Actually, while we're at it... can we have multi-select and ability to make alterations on everything in the LW UI please?

lardbros
02-05-2014, 06:29 AM
...... The stupid forum broken search function is apparently never going to be fixed.

Scrub what I wrote... the search seems to work better if you click the advanced tab and search instead of using the top box!

lardbros
02-05-2014, 06:34 AM
Here's another thread with 'seemingly' the same issue....

Haven't tried the script though


http://forums.newtek.com/showthread.php?137693-Layout-rename-surfaces&highlight=rename+multiple+surfaces

lertola2
02-05-2014, 09:13 AM
Here's another thread with 'seemingly' the same issue....

Haven't tried the script though


http://forums.newtek.com/showthread.php?137693-Layout-rename-surfaces&highlight=rename+multiple+surfaces

No that is a Layout script renames surfaces by appending the file name to the front of the surface name. It does not combine surfaces.

What we need is a Modeler script the will search through the surface names and combine all surfaces that contain the same search string into one surface. So, for example, you have an object that has these surfaces: box_01, box_02, and sphere_01. You should be able to put in the word 'box' as the search string and then the script should find the two surfaces that contain 'box' and combine them into one surface. And the script should leave the surface named 'sphere_01' alone. Maybe to combine surfaces the script will have to select all polygons that have surfaces with the search string in them and then assign the new surfaces to them. This might be what the Change Surface script posted by Iain in the zip file above is trying to do. But it did not work for me when I tried it.

It would be nice if the surface editor itself would be re designed to allow combining of surfaces but I doubt if that will ever happen. Maybe Newtek could add the option in fbx export to save the surfaces in each object with their proper name and not append a number to it. That would be great but it would not help the case when importing fbx from other programs that have multiple names for the same surface.

iain_r
02-05-2014, 12:46 PM
Ok, the code posted is for lscript not python, also check out this link

http://forums.newtek.com/showthread.php?137404-freeze-hundred-surface-in-one-surface&highlight=changesurface

I think this is what you are trying to describe as your request and it's what the script does.

Regards

Iain

lardbros
02-11-2014, 05:05 AM
No that is a Layout script renames surfaces by appending the file name to the front of the surface name. It does not combine surfaces.

What we need is a Modeler script the will search through the surface names and combine all surfaces that contain the same search string into one surface. So, for example, you have an object that has these surfaces: box_01, box_02, and sphere_01. You should be able to put in the word 'box' as the search string and then the script should find the two surfaces that contain 'box' and combine them into one surface. And the script should leave the surface named 'sphere_01' alone. Maybe to combine surfaces the script will have to select all polygons that have surfaces with the search string in them and then assign the new surfaces to them. This might be what the Change Surface script posted by Iain in the zip file above is trying to do. But it did not work for me when I tried it.

It would be nice if the surface editor itself would be re designed to allow combining of surfaces but I doubt if that will ever happen. Maybe Newtek could add the option in fbx export to save the surfaces in each object with their proper name and not append a number to it. That would be great but it would not help the case when importing fbx from other programs that have multiple names for the same surface.

Sorry, I do know what we're after, I've been after this for a LOOOONG time!... I never looked in detail at what the thread I posted...

This is so frustrating and simply leads me to believe that there aren't many LightWave users that are delving into the FBX and importing it into LW from other packages. Shame!! :(

jeric_synergy
02-11-2014, 09:11 AM
Well, it's a shame that I don't have any need for such activity, surely. I'd be delving like a crazed delver if I had such a gig.

lertola2
02-11-2014, 02:09 PM
Sorry, I do know what we're after, I've been after this for a LOOOONG time!... I never looked in detail at what the thread I posted...

This is so frustrating and simply leads me to believe that there aren't many LightWave users that are delving into the FBX and importing it into LW from other packages. Shame!! :(

Or they are just suffering in silence and working around the problem as best they can which is what I usually do. Someone should submit a bug report feature request so that Newtek becomes aware of the problem.

I did try Iain's lscript (which is in the code window of his first post above) and it did work although it was painfully slow on one of my files. I could not get the python scripts that are attached to that message to work. Also in this thread http://forums.newtek.com/showthread.php?137404-freeze-hundred-surface-in-one-surface&highlight=changesurface which Iain gave the link for above is a link to this script: https://www.lightwave3d.com/assets/plugins/entry/cp_selectsurfnames/. This script will select polygons based on a search string. I think that is just as good as a script that combines surfaces because once it is run you can change the surface on all the polygons at once.

-Joe

lardbros
02-11-2014, 02:30 PM
I've posted a bug report...
https://fogbugz.newtek.com/default.asp?51668_hthqpk2jvn25sbdk

I did this quite some time ago, but haven't heard anything since. :(

jeric_synergy
02-11-2014, 06:10 PM
Do we EVER hear anything back? The best I get is "Yep, we can replicate, it's in the queue.".

lardbros
02-12-2014, 06:16 AM
Well... they sent it to a developer... trouble is it's more of a feature request than a bug... so it'll always get sent to the back of the queue.

I did have a few emails from them regarding this, and one of them did say that they were working on an over-arching modification to the import/export system I think, so maybe it's in the works?

jeric_synergy
02-12-2014, 11:02 AM
Occasionally I DO get requests for more examples, but since I usually include at least one if possible, ....

jgutwin
04-27-2014, 12:51 PM
I was also struggling with material names being enumerated with every separate piece of mesh when importing an fbx file. Names like metal__1, metal__2 through metal__238 etc. I wrote a couple of python scripts to clean up some of the worst situations that were easiest to code. These are not 'all-purpose' but may be helpful in some of your FBX import situations.

The 2 scripts are named
SurfaceNameConsolodateQuickFirst.py
SurfaceNameConsolodateAggressiveAsk.py

The first one looks for the shortest matching material name that already exists. So 'metal__238' matches the shorter 'metal__1' and is renamed that. The aggressive ask version looks for the double or single underbar '_' on the right and ask if you want to shorten it with a yes no box. Enter and escape keys work for that but you have to go through a lot of asks for some files. Both of them try to avoid renaming a surface named 'material_155' to a surface named 'material'.

Mr_Q
06-12-2014, 11:28 AM
I ran this latest script you've posted on my mesh. I ran the version that asks and while it appears to work (YAY!) it does spit up a Python console error at the end.

CPython 2.7.5 (default, May 30 2013, 10:07:04) [MSC v.1500 64 bit (AMD64)]
Polygon #1 changed surface to "ThisIsANewSurface".
Traceback (most recent call last):
File "C:\Program Files\NewTek\LightWave11.6.3\support\plugins\third-party\SurfCollapser\SurfaceNameConsolodateAggressi veAsk.py", line 89, in <module>
raise exception
KeyError: 'vray'


When I run the version that doesn't ask, it produces no error but it also doesn't consolidate all the surfaces, only some. So that is not ideal.

Lastly, if I attempt to run either script a second time while in the same modeler session, even with another mesh, it will crash dump.

ninok5
01-29-2015, 02:29 PM
I was also struggling with material names being enumerated with every separate piece of mesh when importing an fbx file. Names like metal__1, metal__2 through metal__238 etc. I wrote a couple of python scripts to clean up some of the worst situations that were easiest to code. These are not 'all-purpose' but may be helpful in some of your FBX import situations.

The 2 scripts are named
SurfaceNameConsolodateQuickFirst.py
SurfaceNameConsolodateAggressiveAsk.py

The first one looks for the shortest matching material name that already exists. So 'metal__238' matches the shorter 'metal__1' and is renamed that. The aggressive ask version looks for the double or single underbar '_' on the right and ask if you want to shorten it with a yes no box. Enter and escape keys work for that but you have to go through a lot of asks for some files. Both of them try to avoid renaming a surface named 'material_155' to a surface named 'material'.



Thank you so much for the scripts! It worked. My import generated over 2000 surfaces all "black paint_1, black_paint_2, etc etc" and I though I was doomed to select each one at a time and then merge them all together. So really really appreciate it!

Newtek, this problem would be alleviated if there was a way to transfer the selection of surfaces in the surface editor onto the model in modeler. Something as simple as right click on a surface after multi selecting them and hitting "select polygons" or something along those lines. Then I could hit Q and assign a surface to them all. Currently the alternative to the scripts is to pull up the "w" menu, select 1 surface at a time, hit + and repeat until all are selected.

jeric_synergy
01-29-2015, 05:41 PM
This is the kind of functionality that a low-level dev should be able to whip up IN A HURRY via Python/LScript, and should: I still feel like these little utilities should be addressed via scripting in a timely fashion, natively/officially.

+++++++++++

Hah, the inclusion of "Surface Editor" in the Firefox title bar was triggering my installation of AHK (it thought I was using the Surface Editor), causing "s" to be trapped-- I guess that just shows how tricky programming is, undermining my post. Dagnabit.... :jam: :eek:

MSherak
01-29-2015, 06:15 PM
The problem really is the FBX format. It will assign a surface per model when exported. Other packages read in the file and don't assume anything so you get everything that FBX has in it.. In this case a material per object if exported from MAX. I am sure there could be more options added to the FBX importer for Lightwave which could reduce the everything in the file to something more manageable. Place a feature request for condense multiple objects with same material name.

For now you need a script of plugin to do specifics in Modeler.

-M

jeric_synergy
01-29-2015, 08:46 PM
I disagree: there's a fundamental weakness in dealing with mass Surfaces, and rather than exclusively dealing with FBX import, it would be better to have native tools to deal with ANY such situation.

It's a common problem: lots of software neglects the idea of dealing with multiple instances of {whatever}. EG, Adobe MUSE does not allow you to multiple select things to re-organize the Library folder (!?!?!). HUGE oversight in my eyes, and one that should be dealt with at a very low level in ALL the list-oriented interfaces. Same thing here.

That is: list operations should be robust and flexible.

RomanS
06-03-2015, 05:46 AM
I was also struggling with material names being enumerated with every separate piece of mesh when importing an fbx file. Names like metal__1, metal__2 through metal__238 etc. I wrote a couple of python scripts to clean up some of the worst situations that were easiest to code. These are not 'all-purpose' but may be helpful in some of your FBX import situations.

The 2 scripts are named
SurfaceNameConsolodateQuickFirst.py
SurfaceNameConsolodateAggressiveAsk.py

The first one looks for the shortest matching material name that already exists. So 'metal__238' matches the shorter 'metal__1' and is renamed that. The aggressive ask version looks for the double or single underbar '_' on the right and ask if you want to shorten it with a yes no box. Enter and escape keys work for that but you have to go through a lot of asks for some files. Both of them try to avoid renaming a surface named 'material_155' to a surface named 'material'.




jgutwin - today you saved my day!!! Thanks for this very helpful plugin!
Roman

Iaian7
08-10-2017, 05:05 PM
I was also struggling with material names being enumerated with every separate piece of mesh when importing an fbx file. Names like metal__1, metal__2 through metal__238 etc. I wrote a couple of python scripts to clean up some of the worst situations that were easiest to code. These are not 'all-purpose' but may be helpful in some of your FBX import situations.

The 2 scripts are named
SurfaceNameConsolodateQuickFirst.py
SurfaceNameConsolodateAggressiveAsk.py

The first one looks for the shortest matching material name that already exists. So 'metal__238' matches the shorter 'metal__1' and is renamed that. The aggressive ask version looks for the double or single underbar '_' on the right and ask if you want to shorten it with a yes no box. Enter and escape keys work for that but you have to go through a lot of asks for some files. Both of them try to avoid renaming a surface named 'material_155' to a surface named 'material'.

John Gutwin, thank you so much for this. You just saved my hide on an imported object with hundreds of surfaces!

gar26lw
08-11-2017, 06:35 PM
I've had this come up too and it's a pita, thank for the scripts. Will try.

kopperdrake
06-01-2018, 01:16 PM
Another thank you to jgutwin for the scripts - just had the same problem of hundreds of variations on a name after fbx import :thumbsup:

erikals
06-02-2018, 03:15 AM
related >


https://www.youtube.com/watch?v=lr4rF3cttl8

kopperdrake
06-03-2018, 01:06 PM
Brilliant! Thanks Erikcals :thumbsup:

erikals
06-03-2018, 02:00 PM
happy to help :)
especially thanks to Matt Gorner for creating it    https://i.imgur.com/tJGL61i.png

Ma3rk
06-03-2018, 04:58 PM
You might also check out the various multi-select, assign, consolidate, & renaming options in OD Tools too.

erikals
06-04-2018, 01:17 AM
OD Tools = Cool      https://i.imgur.com/w7295Cw.gif

kopperdrake
06-04-2018, 08:54 AM
The only reason I haven't yet bought Oliver's toolset is that I still haven't begun to use 2018 in anger. It sits here gathering dust whilst I wait for a project I dare use the new renderer on. I can see potential uses - where a PBR high-poly scene would kill Octane, but getting the time to play to get up to speed is a rarity.

Matt
06-04-2018, 09:09 AM
related >


https://www.youtube.com/watch?v=lr4rF3cttl8

Was going to suggest this, but you beat me to it!

kopperdrake
06-05-2018, 04:31 AM
Was going to suggest this, but you beat me to it!

Thanks Matt - been using it in anger of the last couple of days - really helped take the drudgery out of surface renaming :thumbsup:

jeric_synergy
06-05-2018, 10:57 PM
Was going to suggest this, but you beat me to it!

#aflw: Matt, since you're now on the LW team, is this shipped w/the standard distro?? Just wondering.

Matt
06-06-2018, 10:30 AM
#aflw: Matt, since you're now on the LW team, is this shipped w/the standard distro?? Just wondering.

Yes, it is:

Detail Tab > Polygons Group > Reassign Surface

lertola2
06-06-2018, 03:34 PM
Yes, it is:

Detail Tab > Polygons Group > Reassign Surface

It is great that this tool has been added to Modeler! But it doesn't do any good if you don't know about it. Are there other new tools in Modeler that aren't listed in on the New to 2018 page? (https://docs.lightwave3d.com/display/LW2018/New+to+2018)

Ma3rk
06-06-2018, 04:06 PM
It is great that this tool has been added to Modeler! But it doesn't do any good if you don't know about it. Are there other new tools in Modeler that aren't listed in on the New to 2018 page? (https://docs.lightwave3d.com/display/LW2018/New+to+2018)

Kinda have to stand behind you & mutter yea on that point.

And when did the Merege Triangles tool get added? Listed in 21015 docs but not as new, yet see no mention of it in the 11.6x docs.