any notepad++ gurus?

I have a very long mtl file to edit from a model of Adelaide I downloaded untextured with all the maps only for the induvidual buildings in separate folders same names as single untextured FBX file which exports as an obj creating a mtl file

it has this pattern

newmtl name of object same as map

Ns 0

d 1

Ni 0.001

illum 2

Ka 0.2 0.2 0.2

Kd 1 1 1

Ks 0 0 0

 

I want to change each instance to

 

newmtl name of object same as map

Ns 0

d 1

Ni 0.001

illum 2

Ka 0.2 0.2 0.2

Kd 1 1 1

Ks 0 0 0

map_Kd name of object same as map.JPG

 

I otherwise need to either manually do it about a thousand times or load the maps on my thousand objects

 

«1

Comments

  • TooncesToonces Posts: 919

    Notepad++ replace can update all files. I used these instructions recently to convert mc6 to pz2:

    http://cyonixgfx.deviantart.com/art/Converting-mc6-Files-to-pz2-194920273

    Tricky part is that it looks like you're appending to the end of the file, not replacing anything. So not sure if there is a special thing you can search for EOF like /r/n/n or something like that. If you're truly appending to end of file, perhaps one of these suggestions:

    https://stackoverflow.com/questions/5612105/add-text-to-the-end-of-each-file-with-notepad-and-regex

  • fixmypcmikefixmypcmike Posts: 19,705

    Can you record the operations

    search for newmtl

    copy from after newmtl to end of line

    go down x lines

    add new llne with map_Kd, paste name of object, .JPG

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    Can you record the operations

    search for newmtl

    copy from after newmtl to end of line

    go down x lines

    add new llne with map_Kd, paste name of object, .JPG

    I am actually doing that in regular notepad

    BTW there are 4731 textures!!!

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    I did find replace the last line Ks 0 0 0 with Ks 0 0 0 map_Kd .Jpg

    and on each am copying the name and then going to the space before map and pressing enter

    it will take days but otherwise loading maps weeks!

     

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    I might give up very soon

  • SimonJMSimonJM Posts: 6,073

    Could to that in awk in seconds, but I don't really have access to a *nix environment.  Let me see if my really old netbook still sparks up ...

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    opened NP++

    I got as far as record

    then find ... and yeah no idea how to run macros

     

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    this is the mtl file btw

    Blender created it from the blend file so not really redistributing anything

    https://data.sa.gov.au/data/dataset/3d-model is where I got the model

     

    zip
    zip
    ACC Base Model.zip
    10K
  • fixmypcmikefixmypcmike Posts: 19,705

    After recording the macro go to the macro menu to run it multiple times.

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    I am so totally lost you have no idea cheeky

    my brain really does not work that well, no idea how to record or what to record laugh

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    damn no they are 3ds files > <

    now I am dragging maps onto selected buildings in iClone 3Dxchange, it's slightly faster than manual editing

    Capture.JPG
    1936 x 1048 - 326K
  • SimonJMSimonJM Posts: 6,073

    Ok, try this - sorry for the dealy, took a while to copy between machines ;)

     

    zip
    zip
    test.zip
    18K
  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    no apology needed never expected a quick fix, you are very kind heart

    now hopefully will work or am back to dragging maps wink

  • SimonJMSimonJM Posts: 6,073

    No worries, any excsue to use awk again ;)

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    LOL  I may still need to try NP++ though as need to add .JPG to each one

  • SimonJMSimonJM Posts: 6,073

    That new line needs a .jpg appended to it?

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    opps yes, I am looking in notepad how as really need to brain a bit sometimes blush

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    oh I added .JPG to every line and it is indeed looking for maps but with a _ in front

    so might need to find replace those next

  • SimonJMSimonJM Posts: 6,073

    So you'd want _BL1_6.jpg as an example?

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    I am actually unsure truth be told

    its being rather odd with th map names

    none actually have a _ in front so I am still figuring this out

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    I think maybe the model names and maps slightly differ

  • SimonJMSimonJM Posts: 6,073

    Here's a new version, with the .jpg attached.  And also, I hope!!!!!, without the hidden whitespace character.  For those with a technicval bent, it was a spurious ^M character that is an artefact of DOS/Windows and *nix systems using different ways of spcifying the end of a line in a text file: one uses CR/LF the other LF/CR and some programs in each system can workout what is happeing and deal with it!

     

    zip
    zip
    test2.zip
    17K
  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    mmm I seem to be also missing a lot maps which complicates it

  • SimonJMSimonJM Posts: 6,073

    That I can't help with - it finds some file snow, but no others?  Any pattern to those it is not finding?

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    I have found opening the obj file in notepad the maps are _jpg so it may a silly Carrara export issue

  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318
    edited June 2017

    I am begining to think there is no correlation between those mtl names and map names but oddly the surfaces match the map names in all my softwares

    both Carrara and Poser add a _ in front and seach for the missing files first and I keep clicking cancel untill it finds ones that are there but it still does not as adding a _ in front again even though not in mtl file

    I honestly give up

    will manually add existing maps maybe a few each day .....

    Post edited by WendyLuvsCatz on
  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318
    edited June 2017

    this gets very weird as those missing textures, at least a few hundred are not in the loaded model's surface areas either

    I can in fact locate every map (except for a handful) by the object names!!

    which do not have _ in front either in the FBX import in Carrara

    Capture.JPG
    1936 x 1048 - 275K
    Post edited by WendyLuvsCatz on
  • TaozTaoz Posts: 10,281

    If all else fails, PowerGrep is an incredible tool, a bit expensive but definitely worth the money. The trial should be fully functional.

    http://www.powergrep.com/

  • morkmork Posts: 278
    edited June 2017

    Two questions:

    1. Is "map_Kd" already in the file, or do you need to add it?
    2. Is "Ks" always 0 0 0?

    Edit: Nevermind. Here are both options, should work in every case.

    This can be done with regular expressions. Please don't ask me to explain. :D
     

    Case A:

    map_Kd already exists, needs to be replaced:

    Search for:
    newmtl\s([^\r\n]+)\r\n(.*?)map_Kd\s(.+?)\r\n

    Replace with:
    newmtl \1\r\n\2map_Kd \1\.jpg
     

    Case B:

    map_Kd does not exist, needs to be added

    Search for:
    newmtl\s([^\r\n]+)\r\n(.*?)Ks\s([0-9\. ]+)

    Replace with:
    newmtl \1\r\n\2Ks \3\r\nmap_Kd \1\.jpg

     

    In both cases make sure to:
    Tick "Regular expression" radio button + ". matches newline" next to it.
    Use a somewhat up2date version of notepad++.
    Make sure you don't have a whitespace at the beginning or ending of the search+replace string after copy+paste.

    One caveat:
    The very last entry might not get replaced, if there is not a newline/linebreak at the end of the file.

    Good luck!

    Post edited by mork on
  • WendyLuvsCatzWendyLuvsCatz Posts: 40,318

    no map Kd was not there and every obj paragraph has the same parameters for the materials 

    its a pain as the obj produced from the unreadable gibbberish FBX file exporting from Carrara and I also tried Blender has a pile of models at the start that neither exist or their coresponding textures.

    loading it in any software those models just do not exist in the scene and it looks for those maps first

    except DAZ studio which pretty much ignores any mtl file on most things including its own exports and loads it untextured, that also messes up the FBX badly so just not going there.

    The issue is the textures are in separate folders with individual 3ds models of each building and nothing will batch load those 3ds files.

    Poser can one by one but many of their positions are out, hence the FBX model in one go,  Carrara loads every one 0, 0, 0 both load them textured but 4K of them!!!

    I get the 4K individual models in Carrara and iClone 3Dxchange with FBX untextured but named the same as the existing maps from that FBX file the problem is creating a mtl file to populate those meshes with those maps converting it to a useable obj.

    I ultimately want it textured in DAZ studio and run texture atlas, then Carrara, Poser not actually iClone as it will never cope with all those maps unless resized very tiny.

    Its really proving unworkable I think as the obj produced has issues to start with, it was obviously created from Sketchup models so mapping rather crap to begin with, the city itself looks quite awesome but individual buildings very fuzzy lowrez textures anyway, might be better flat mapping the lot in Ultimate Unwrap3D and dropping a Google earth image on it like I did my OSM creation of Adelaide.

Sign In or Register to comment.