xantor opened this issue on Apr 22, 2008 · 7 posts
xantor posted Tue, 22 April 2008 at 10:57 PM
I have a wavefront object that has material names for each seperate part but only one group, is there an easy way to make each part have a group with the material name as the group name?
This could probably be done with a python script.
A script to do it the other way around would be good as well, to use the group names as material names.
svdl posted Tue, 22 April 2008 at 11:01 PM
The Grouping tool in Poser can do this for you.
Now your prop is propery grouped.
The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter
Conniekat8 posted Tue, 22 April 2008 at 11:01 PM
You can do it in UV Mapper. Select by Material, then create a group with an appropriate name and assign selection to it.
In the past, I've been brave enough to change material designation inside an OBJ file to a Group designation with a simple search and replace in a text editor. Not something I'd recommend to a noob, but it's pretty quick.
Also, this is with OBJ files saved out of UV mapper. Other apps may create that is organized a bit differently, and make this method not work.
Hi, my namez: "NO, Bad Kitteh, NO!" Whaz
yurs?
BadKittehCo
Store BadKittehCo Freebies
and product support
xantor posted Tue, 22 April 2008 at 11:09 PM
Conniekat8 does that mean that you can just change a material into an object group? That would work ok.
I don` t want to change each name seperately that way in poser or uvmapper because the object is a figure and has about 30 seperate parts.
svdl posted Tue, 22 April 2008 at 11:34 PM
It's not possible to create groups using Python.
It is possible to assign polygons to existing groups using Python.
If you don't want to do it by hand, the best option is to do the search/replace routine Conniekat8 mentions.
The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter
Conniekat8 posted Wed, 23 April 2008 at 12:15 AM
when you save an OBJ with UV mapper, it places both, Group and Material assignment codes in the facest section of the file (as opposed in the vertex section). This is why it's important to first open your OBJ in UV mapper, then save it. Changes the internal order of things a little bit.
I grabbed one of my objs... this one has only one group, but that doesn't really matter.
The begining of the facet section looks like this:
g !00Body
usemtl Suit
f 1/10/1 2/1/2 3/2/3 4/5/4
f 1/10/1 5/4556/5 6/4590/6 2/1/2
f 7/6/7 4/5/4 3/2/3 8/15/8
f 7/6/7 8/15/8 9/16/9 10/7/10
f 11/3/11 12/4/12 4/5/4 7/6/7
etc etc...
g !00Body stands for (g)=tells ptograms it's a begining of a group section (!00Body) = name of the group - I assign the name*
*Next line:
usemtl Suit stands for (usemtl)=tells ptograms it's a begining of a material section, in this case and UV mappers obj file structure it happens to coincide with group section, which is just what you can take advantage of! (Suit) = name of the material, as I assigned.
Note theese things ARE case sensitive!
Now, you can do search and replace, and either add a line:
Search would be: *usemtl Suit(wildcards for the word)
*Replace with: *usemtl Suit (new line) g Suit
*(more advanced text editor needed for this, where you can add new paragraphs and wildcards)
Or if you don't care about losing material zones, you can do this:
Search would be: *usemtl
*Replace with: g
3. in a simpler editor you can duplicate the lines with a bit of hand copy and pasting, and have two:
*usemtl Suit
usemtl Suit
*Then run a search and replace as described in #2, but don't hit replace all, but alternate replace, don't replace, replace, don't replace. (usually goes quickly with ynynyny strokes on the keyboard Yes, Next, Yes, Next in wordpad or notepad)
You'll end up with:
usemtl Suit
g Suit
*f 7/6/7 8/15/8 9/16/9 10/7/10
f 11/3/11 12/4/12 4/5/4 7/6/7
*etc etc...
usemtl arm
g arm
*f 7/6/7 8/15/8 9/16/9 10/7/10
f 11/3/11 12/4/12 4/5/4 7/6/7
etc etc...
usemtl leg
g leg
**f 7/6/7 8/15/8 9/16/9 10/7/10
f 11/3/11 12/4/12 4/5/4 7/6/7
*etc etc...
ALWAYS save this obj with a different name, in case you goofed up and need to revert. That kind of goes without saying, but I'm saying it anyway :)
Hi, my namez: "NO, Bad Kitteh, NO!" Whaz
yurs?
BadKittehCo
Store BadKittehCo Freebies
and product support
xantor posted Wed, 23 April 2008 at 12:28 AM
Great, thank you.