Bug In Export Obj: SubLayers Ignored For Obj Groups

The export as obj file has a bug in it for sub-layers. Say I have these layers and export settings:

image

image

In v5, the geometry on the temp layers would export in groups named Temp_Temp1, Temp_Temp2, Temp_Temp3, and Temp_Temp4. In v6, all of the geometry from temp 1 through 4 are exported as Temp. The sub-layers are being ignored.

Hi Eric - yeah… so now we export nested groups, corresponding to the layers. I think your objects are in two groups, Temp and Temp1 for example - I vaguely remember this is by design, but I could be making that up, and I do not remember the reason- I’ll ask the developer.
https://mcneel.myjetbrains.com/youtrack/issue/RH-46452

@EricM - apparently the change was quite deliberate and it allows incoming obj files with groups, or round-tripped ones, to distribute the objects onto correctly nested layers. So, the question is, how bad is this for your workflow? It may be possible to write a post-process tool to tweak the obj files, and in a future (say 7) version, make an option to combine groups.

-Pascal

It’s not great. I have to copy/paste to V5 and export from there.

It appears that the other programs I only respect the first group name:

g Temp Temp1
v .....

g Temp Temp2
v .....

Temp1 and Temp2 end up in the Temp group. I don’t have any good options for getting around this other than export from v5.

Hi Eric - something to try, I’ll attach as a python script as well.

TweakObjGroupNames.py (809 Bytes)


import rhinoscriptsyntax as rs
import fileinput
import os
import scriptcontext as sc


def TweakObj():
    
    defFolder = rs.WorkingFolder()
    
    if sc.sticky.has_key("OBJTWEAK_FOLDER"):
        defFolder = sc.sticky["OBJTWEAK_FOLDER"]
    
    sFile = rs.OpenFileName("File to tweak", "obj file|*.obj||", defFolder, extension = "*.obj")
    if not sFile:return
    
    sFolder = os.path.dirname(sFile)
    sc.sticky["OBJTWEAK_FOLDER"] = sFolder
    
    
    oFile = fileinput.FileInput(sFile,inplace=1)
    for line in oFile:
        if line.startswith("g "):
            sline = line[2:len(line)-1]
            line = "g " + sline.replace(chr(32), "__")
            print line + "\n"

        else: print line
    oFile.close()
    
if __name__=="__main__":TweakObj()

-Pascal

1 Like

This was a very disruptful change to my workflow too, FYI

Hi @galen.burrell. Did you manage a work-around for this? I’m running into the same issue now.

Hi @nathanieljon, for now i am just using the TweakObjGroupNames.py python script provided above until they (hopefully) provide a better option.