from pathlib import Path
import clr
import rhinoinside

sysdir = Path("C:/Program Files/Rhino 7 WIP/System")
plugdir = Path(sysdir, "..", "Plug-ins").resolve()
rhinoinside.load(f"{sysdir}")

import System
import Rhino
import os 

_3dm_file_path = "C:\\Dev\\Python\\as.3dm"
_export_obj_file_path = "C:\\Dev\\Python\\export.obj"

def ExportAsObj():
    
    write_options = Rhino.FileIO.FileWriteOptions()
    write_options.WriteSelectedObjectsOnly = False
    
    obj_options = Rhino.FileIO.FileObjWriteOptions(write_options)
    obj_options.UseSimpleDialog = True
    dummy_out = System.Boolean(0)
    doc,already_exists = Rhino.RhinoDoc.Open(_3dm_file_path,dummy_out)
    print(doc)
    if doc != None:
        rc = Rhino.FileIO.FileObj.Write(_export_obj_file_path, doc, obj_options)
        if rc == Rhino.PlugIns.WriteFileResult.Success:
            print ("Success, file saved:", _export_obj_file_path)
        else:
            print ("Error saving file:", _export_obj_file_path)

ExportAsObj()