# Path: importerUtils.py
# def canImport():
# 	global _can_import
# 	return _can_import
# 
# def logInfo(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkLogging", False)): _log("logInfo",    Console.PrintMessage, msg, args)
# 
# def logWarning(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkWarning", False)): _log("logWarning", Console.PrintWarning, msg, args)
# 
# def logError(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkError", True)):    _log("logError",   Console.PrintError,   msg, args)
# 
# def logAlways(msg, *args):
# 	_log("logAlways", Console.PrintMessage, msg, args)
# 
# def getAuthor():
# 	return _author
# 
# def getComment():
# 	global _comment
# 	return _comment
# 
# def getLastModifiedBy():
# 	global _lastModifiedBy
# 	return _lastModifiedBy
# 
# def setThumbnail(thumbnail):
# 	global _thumbnail
# 	_thumbnail = thumbnail
# 	return
# 
# Path: importerFreeCAD.py
# def createGroup(name):
# 	return newObject('App::DocumentObjectGroup', name)


import os, sys, FreeCAD, FreeCADGui, importerSAT, importerDXF, Import_IPT, importerF3D
import Acis, importerClasses
from importerUtils   import canImport, logInfo, logWarning, logError, logAlways, getAuthor, getComment, getLastModifiedBy, setThumbnail
from olefile         import isOleFile
from importerFreeCAD import createGroup
from pivy            import coin

				reader.create3dModel(group, doc)
			releaseMemory()
			FreeCADGui.SendMsgToActiveView("ViewFit")
	else:
		_open(filename, skip, only, root)
	logInfo(u"DONE!")
	return

def _open(filename, skip = [], only = [], root = None):
	reader = read(filename)
	if (reader is not None):
		name = os.path.splitext(os.path.basename(filename))[0]
		doc = FreeCAD.newDocument(decode(name))
		doc.Label = name
		doc.CreatedBy = getAuthor()
		doc.LastModifiedBy = getLastModifiedBy()
		doc.Comment = getComment()
		reader.create3dModel(root , doc)
		adjustView(doc)
	releaseMemory()
	return

def open(filename, skip = [], only = [], root = None):
	'''
	opens an Autodesk Inventor file in a new document
	In addition to insert (import), the iProperties are as well added to the document.
	'''
	if (isFileValid(filename)):
		logAlways(u"Reading: %s", os.path.abspath(filename))
		_open(filename, skip, only, root)

# Path: importerUtils.py
# def canImport():
# 	global _can_import
# 	return _can_import
# 
# def logInfo(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkLogging", False)): _log("logInfo",    Console.PrintMessage, msg, args)
# 
# def logWarning(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkWarning", False)): _log("logWarning", Console.PrintWarning, msg, args)
# 
# def logError(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkError", True)):    _log("logError",   Console.PrintError,   msg, args)
# 
# def logAlways(msg, *args):
# 	_log("logAlways", Console.PrintMessage, msg, args)
# 
# def getAuthor():
# 	return _author
# 
# def getComment():
# 	global _comment
# 	return _comment
# 
# def getLastModifiedBy():
# 	global _lastModifiedBy
# 	return _lastModifiedBy
# 
# def setThumbnail(thumbnail):
# 	global _thumbnail
# 	_thumbnail = thumbnail
# 	return
# 
# Path: importerFreeCAD.py
# def createGroup(name):
# 	return newObject('App::DocumentObjectGroup', name)


# Path: importerIL.py
import os, sys, FreeCAD, FreeCADGui, importerSAT, importerDXF, Import_IPT, importerF3D
import Acis, importerClasses
from importerUtils   import canImport, logInfo, logWarning, logError, logAlways, getAuthor, getComment, getLastModifiedBy, setThumbnail
from olefile         import isOleFile
from importerFreeCAD import createGroup
from pivy            import coin

				reader.create3dModel(group, doc)
			releaseMemory()
			FreeCADGui.SendMsgToActiveView("ViewFit")
	else:
		_open(filename, skip, only, root)
	logInfo(u"DONE!")
	return

def _open(filename, skip = [], only = [], root = None):
	reader = read(filename)
	if (reader is not None):
		name = os.path.splitext(os.path.basename(filename))[0]
		doc = FreeCAD.newDocument(decode(name))
		doc.Label = name
		doc.CreatedBy = getAuthor()
		doc.LastModifiedBy = getLastModifiedBy()
		doc.Comment = getComment()
		reader.create3dModel(root , doc)
		adjustView(doc)
	releaseMemory()
	return

def open(filename, skip = [], only = [], root = None):
	'''
	opens an Autodesk Inventor file in a new document
	In addition to insert (import), the iProperties are as well added to the document.
	'''
	if (isFileValid(filename)):
		logAlways(u"Reading: %s", os.path.abspath(filename))
		_open(filename, skip, only, root)

		logInfo(u"DONE!")
