Comparing files

Is there a (relatively) simple way to compare two .3dm files and identify geometry which is duplicated between the files and/or geometry which is unique to each file?

Hi David - I don’t think so, off hand but, is the test for duplicate strict like SelDup?

-Pascal

Yes, strict like SelDup.

I imported File B into File, ran SelDupAll, and then Hide for all the selected objects. That left the unique objects but did not explicitly say which file they were from. However by opening the individual files I was able to determine what had/had not changed in the later version.

Hi David - seems like a scripty thing might help - I’ll think about it - something like tagging all the imported geometry with user text to be able to filter the objects.

-Pascal

1 Like

Hi David, a trick I sometimes use is to ‘worksession’ one of the files into the other and select the worksession file. If the files share the same origin etc. differences stand out nicely.

I tried using Worksession to compare the files. Due to the nature of the files the differences were not obvious without going through the files layer by layer. Unfortunately SelDup and SelDupAll do not check the objects in the reference files.

Another thing you could try is to drag the selected worksession off to the side of the area you’re inspecting - it will bounce back when finished of course.

Thats a very interesting idea, have you had a chance to test it in the end?

I have not done any testing but it is easy enough to tag objects in a file - this could also be done to an imported file as it comes in, but maybe one tag is enough.

Simple example

import rhinoscriptsyntax as rs


def tag_objects():
    
    file = rs.DocumentName()

    if not file:return

    tagString = file.split(".")[0]
    
    ids = rs.AllObjects()
    
    if not ids: return
    
    for id in ids:
        rs.SetUserText(id, 'FileTag', tagString)
        
tag_objects()

Here is a thing to select these once the dups have been hidden’

import rhinoscriptsyntax as rs

def sel_tag_objects():
    
    file = rs.DocumentName()

    if not file:return

    tagString = file.split(".")[0]
    
    ids = rs.NormalObjects()
    
    if not ids: return
    rs.UnselectAllObjects()
    rs.EnableRedraw(False)
    for id in ids:
        
        if rs.SetUserText(id, 'FileTag', tagString):
            rs.SelectObject(id)
    rs.EnableRedraw(True)
        
sel_tag_objects()

and, I suppose there ought to be one to clear all the tags…

import rhinoscriptsyntax as rs

def clear_tag_objects():
    

    ids = rs.AllObjects()
    
    if not ids: return

    for id in ids:
        rs.SetUserText(id, 'FileTag', "")

clear_tag_objects()

-Pascal

4 Likes

Fantastic, thank you very much! Very helpful!

Amazing tools, also gave me a good reason to look into Rhino’s command line interface:

for %i in (*.3dm) do Rhino.exe /nosplash /runscript="-RunPythonScript (...\TagObjects.py) save exit" "%i"

Is there any way to run this “headlessly” from command line though?