Layer problem with inserted *.obj files

With ‘Default’ as current layer, I’m inserting a scan file as linked block with the Layer Style set to Reference.

After clicking ok, the reference is shown in the layer panel but only for a very short moment.

Here’s a still from a screenvideo.

I saved the file and opened it again and the wire layer takes the color of the scan layer. The cad objects also lost their color and took the color set in the scan layer.

Something is messed up.

First issue is the *.obj scan file not being shown as linked reference in the layer panel.
Second problem is the layer color.

I’ve inserted many other scans like this before and I’m currently confused with what I see.

Here are three files to insert in a Rhino 8 file for anyone to try.

AssemblyCAD.STEP (44.4 KB)
kocher Copy of Sharp fusion 3.obj (3.2 MB)
kocher Copy of Boolean subtraction 3.obj (637.6 KB)

System Info

Rhino 8 SR4 2024-1-16 (Rhino 8, 8.4.24016.19001, Git hash:master @ 6629551a67b43795d6c888fd40dbd82205f8bfb1)
License type: Kommerziell, build 2024-01-16
License details: Cloud Zoo

Windows 11 (10.0.22631 SR0.0) or greater (Physical RAM: 128GB)
.NET 7.0.15

Computer platform: DESKTOP

Standard graphics configuration.
Primary display and OpenGL: NVIDIA RTX A5000 (NVidia) Memory: 22GB, Driver date: 12-1-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 537.99
> Accelerated graphics device with 4 adapter port(s)
- Secondary monitor attached to adapter port 0
- Windows Main Display attached to adapter port 1

Secondary graphics devices.
NVIDIA Quadro K2200 (NVidia) Memory: 4GB, Driver date: 12-1-2023 (M-D-Y).
> Accelerated graphics device with 4 adapter port(s)
- There are no monitors attached to this device!

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: 8x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 12-1-2023
Driver Version: 31.0.15.3799
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 23028 MB

Rhino plugins that do not ship with Rhino
C:\Users\martinsiegrist\AppData\Roaming\McNeel\Rhinoceros\8.0\Plug-ins\KeyShot9RhinoPlugin (ecfe8d1f-876a-460f-aa5e-3dd816936811)\1.0.0.0\KeyShot9RhinoPlugin\Rhino 5.0\KeyShot9RhinoPlugin.rhp “KeyShot9RhinoPlugin” 1.0.0.0
C:\Users\martinsiegrist\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\NVIDIADenoiser\0.4.3\NVIDIADenoiser.Windows.rhp “NVIDIADenoiser.Windows” 0.4.3.0

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 8\Plug-ins\Commands.rhp “Commands” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\WebBrowser.rhp “WebBrowser”
C:\Program Files\Rhino 8\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 8\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\import_OBJ.rhp “Import_OBJ” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 8\Plug-ins\import_STEP.rhp “STEP Import”
C:\Program Files\Rhino 8\Plug-ins\MeshCommands.rhp “MeshCommands” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\RhinoCycles.rhp “RhinoCycles” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\SectionTools.rhp “SectionTools”
C:\Program Files\Rhino 8\Plug-ins\Grasshopper\GrasshopperPlugin.rhp “Grasshopper” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\RhinoCode\RhinoCodePlugin.rhp “RhinoCodePlugin” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 8.4.24016.19001
C:\Program Files\Rhino 8\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 8\Plug-ins\Displacement.rhp “Displacement”

Hi Martin - I see something is amiss here, thanks, I’ll investigate.
From what I can see this did not work for obj in V7 either
RH-79903 Insert: OBJ files do not show linked referenced layers
OBJ import has some settings that may affect this but I did not find a combination that ever showed the reference layer.

@martinsiegrist - the problem seems to be that the obj file does not, in this case, contain anything that Rhino can construe as a layer on import. I’m not sure what to do here.

-Pascal

2 Likes

Hi @martinsiegrist,

Open the .obj file and save it to a .3dm file. Then use the .3dm file as the file to insert.

– Dale

Thanks but I want to insert the file directly. I thought this worked fine in the past. I’ll try again.

Inserting the *.obj allows me to quickly replace the file if I’m not happy and I can load the new instance just like that if it has the same name.

Ok so we’re talking about two things.

  1. *.obj does not seem to save any layer information. The g-tag is used to save group names. The import option ‘Layers’ can be used to put the *.obj file in a layer. This only works if there is a g-tag. And none of the files exported out of Artec Studio seem to have a g-tag. If Rhino could improve the Import Options to allow setting the o-tag as Nothing, Layer, Group or Object names… that would solve my problem. I’ll also ask Artec to improve their *.obj export with a g-tag…

  2. After saving and opening the file with the inserted *.obj missing a g-tag, the content of the linked block reference is being moved to the next layer. This could also be solved with the option to use the o-tag as layer name.

image

I came to the conclusion that the g-tag is parsed into a layer structure.

The attached box_g-tag.obj (1.3 KB) file imports to layer ‘05’

image

image

I added the g-tag in the following *.obj exported from Artec Studio:

I have created a python script to add or modify a g-tag in an *.obj file.

So far I’ve been using it in IDLE Python and it works for the files I exported from Artec Studio

import tkinter as tk
from tkinter import filedialog

root = tk.Tk()
root.withdraw()  # Hide the main window

path = filedialog.askopenfilename(initialdir="A:\\")  # Open the file dialog


print(path)



def new_layer():

    layer = input('Please enter a child layer name: ')

    new_layer = 'g artec-studio ' + layer


    with open(path, 'r') as f:
        lines = f.readlines()

    with open(path, 'w') as f:
        for line in lines:
            if line[0] == 'g':
                f.write(new_layer + '\n')
            else:
                f.write(line)

    with open(path, 'r') as f:
        lines = f.readlines()

    # insert new_line at the 8th index (before the 9th line)
    lines.insert(8, new_layer + '\n')

    with open(path, 'w') as f:
        for line in lines:
            f.write(line)



def replace_line(file_name, line_num, text):
    with open(file_name, 'r') as file:
        lines = file.readlines()

    lines[line_num] = text + '\n'  # replace the specific line

    with open(file_name, 'w') as file:
        for line in lines:
            file.write(line)


found = False



with open(path, 'r') as file:
        index = 0
        for i, line in enumerate(file):
            if line.startswith('g'):
                index = i
                print(f"Line {i} starts with 'g'")
                
                print(line)

                layer = input('Please enter the new layer name: ')

                new_layer = 'g artec-studio ' + layer

                
                found = True

                replace_line(path, i, new_layer)

                message = 'g-tag replaced with: ' + new_layer

                print(message)

                
if not found:
    
    print("No line starts with 'g'")

    new_layer()


print('done')

If I made it so you could import obj “o” tags as layers would that get you what you need?

Thanks for your reply, Tim.

This would make my live a little easier, yes.

Long term I expect Artec to improve their *.obj export

Hi Martin,

One more question. Since it would be best to add another set of radios for "o"s it really ought to go into 9. Are you able to use 9 or would this be best for you in 8? If the latter, I’ll add an advanced setting in 8 (0-3, similar to the radios for "g"s where 0 is the top and 3 is the bottom) and the add the UI in 9. Let me know, if you can use 9 I won’t bother doing anything in 8.

Tim

9 is the new WIP?

I’ve seen a couple of people mentioning it, but there is no download link I can find.

We’ve paused Rhino 9 development as we clean up Rhino 8; it’s not available publicly yet.

I got the go ahead to put this in V8. I’ll get to it soonish.

1 Like