Ejemplo n.º 1
0
    def __init__(self):
        try:
            self.uiapp = __revit__
            self._host = Revit.HOSTS.RPS
        except NameError:
            try:
                # Try Getting handler from Dynamo RevitServices
                self.uiapp = self.find_dynamo_uiapp()
                self._host = Revit.HOSTS.DYNAMO
            except Exception as errmsg:
                logger.warning('Revit Application handle could not be found')

        try:
            # Add DB UI Import to globals so it can be imported by rpw
            clr.AddReference('RevitAPI')
            clr.AddReference('RevitAPIUI')
            from Autodesk.Revit import DB, UI
            globals().update({'DB': DB, 'UI': UI})
        except Exception:
            # Replace Globals with Mock Objects for Sphinx and ipy direct exec.
            logger.warning('RevitAPI References could not be added')
            from rpw.utils.sphinx_compat import MockObject
            globals().update({'DB': MockObject(fullname='Autodesk.Revit.DB'),
                              'UI': MockObject(fullname='Autodesk.Revit.DB')})
            self.uiapp = MockObject(fullname='Autodesk.Revit.UI.UIApplication')
            self._host = None
Ejemplo n.º 2
0
    def __init__(self):
        try:
            self.uiapp = __revit__
            self._host = Revit.HOSTS.RPS
        except NameError:
            try:
                # Try Getting handler from Dynamo RevitServices
                self.uiapp = self.find_dynamo_uiapp()
                self._host = Revit.HOSTS.DYNAMO
            except Exception as errmsg:
                logger.warning('Revit Application handle could not be found')

        try:
            # Add DB UI Import to globals so it can be imported by rpw
            clr.AddReference('RevitAPI')
            clr.AddReference('RevitAPIUI')
            from Autodesk.Revit import DB, UI
            globals().update({'DB': DB, 'UI': UI})
        except Exception:
            # Replace Globals with Mock Objects for Sphinx and ipy direct exec.
            logger.warning('RevitAPI References could not be added')
            from rpw.utils.sphinx_compat import MockObject
            globals().update({'DB': MockObject(fullname='Autodesk.Revit.DB'),
                              'UI': MockObject(fullname='Autodesk.Revit.DB')})
            self.uiapp = MockObject(fullname='Autodesk.Revit.UI.UIApplication')
            self._host = None
Ejemplo n.º 3
0
 def Factory(element):
     # Depracated - For Compatibility Only
     msg = 'Element.Factory() has been depracated. Use Element()'
     logger.warning(msg)
     return Element(element)
Ejemplo n.º 4
0
>>> from rpw.utils.dotnet import List, Enum, Process

"""

import sys

from rpw.utils.logger import logger
from rpw.utils.sphinx_compat import MockImporter

# Attempt to Import clr
try:
    import clr
except ImportError:
    # Running Sphinx. Import MockImporter
    logger.warning('Error Importing CLR. Loading Mock Importer')
    sys.meta_path.append(MockImporter())

################
# .NET IMPORTS #
################

import clr
clr.AddReference('System')  # Enum, Diagnostics
clr.AddReference('System.Collections')  # List

# Core Imports
from System import Enum
from System.Collections.Generic import List
from System.Diagnostics import Process
Ejemplo n.º 5
0
 def Factory(element):
     # Depracated - For Compatibility Only
     msg = 'Element.Factory() has been depracated. Use Element()'
     logger.warning(msg)
     return Element(element)
Ejemplo n.º 6
0
import sys

from rpw.utils.logger import logger
from rpw.utils.sphinx_compat import MockImporter

# Attempt to Import clr
try:
    import clr
except ImportError:
    # Running Sphinx. Import MockImporter
    logger.warning('Error Importing CLR. Loading Mock Importer')
    sys.meta_path.append(MockImporter())

################
# .NET IMPORTS #
################

import clr
clr.AddReference('System')                 # Enum, Diagnostics
clr.AddReference('System.Collections')     # List

# Core Imports
from System import Enum
from System.Collections.Generic import List
from System.Diagnostics import Process
Ejemplo n.º 7
0
try:
    #  This is a workaround to fix Sphinx's autodoc
    import clr
    clr.AddReference('RevitAPI')
    clr.AddReference('RevitAPIUI')
    clr.AddReference('System')

    from Autodesk.Revit import DB
    from Autodesk.Revit import UI
    from System.Collections.Generic import List
    from System import Enum

except Exception as errmsg:
    logger.error(errmsg)
    platform = None
    logger.warning('Could not Revit Document. Will Import Sphinx Compat Vars')
    from rpw.utils.sphinx_compat import *

# Imported Revit's Assemblies
else:
    try:
        uidoc = __revit__.ActiveUIDocument
        doc = __revit__.ActiveUIDocument.Document
        version = __revit__.Application.VersionNumber.ToString()
        platform = {'revit': version}
        logger.info("Running In Revit")

    except NameError:
        logger.debug('Could not find pyRevit Document. Trying Dynamo.')
        try:
            clr.AddReference("RevitServices")