Skip to content

Commit

Permalink
Project directory cleanups for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Mar 6, 2018
1 parent eadf235 commit abeda57
Show file tree
Hide file tree
Showing 47 changed files with 3,134 additions and 3,134 deletions.
12 changes: 4 additions & 8 deletions RevitPythonShell.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.12
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitPythonShell", "RevitPythonShell\RevitPythonShell.csproj", "{7E37F14E-D840-42F8-8CA6-90FFC5497972}"
ProjectSection(ProjectDependencies) = postProject
Expand All @@ -11,13 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitPythonShell", "RevitPy
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonConsoleControl", "PythonConsoleControl\PythonConsoleControl.csproj", "{F1152D68-346B-4F48-8DB7-BE67B5CB1F49}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{84677A26-E049-48B3-AFB0-3B3F99955849}"
ProjectSection(SolutionItems) = preProject
Setup_RevitPythonShell_2014.iss = Setup_RevitPythonShell_2014.iss
Setup_RevitPythonShell_Vasari_Beta1.iss = Setup_RevitPythonShell_Vasari_Beta1.iss
Setup_RevitPythonShell_Vasari_Beta2.iss = Setup_RevitPythonShell_Vasari_Beta2.iss
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RpsRuntime", "RpsRuntime\RpsRuntime.csproj", "{C8446636-C663-409F-82D0-72C0D55BBA1C}"
EndProject
Global
Expand Down Expand Up @@ -63,6 +56,9 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8E6A5A3B-CCC1-402D-9D4B-989DE2CEB738}
EndGlobalSection
GlobalSection(SubversionScc) = preSolution
Svn-Managed = True
Manager = AnkhSVN - Subversion Support for Visual Studio
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<RevitPythonShell>
<SearchPaths>
<!-- a list of paths to add to the engines search path -->
</SearchPaths>
<Variables>
<!-- a list of string variables to add to the scope -->
</Variables>
<Commands>
<!-- a list of preconfigured commands -->
</Commands>
<InitScript src="init.py"/>
<StartupScript src="startup.py"/>
<?xml version="1.0" encoding="utf-8" ?>
<RevitPythonShell>
<SearchPaths>
<!-- a list of paths to add to the engines search path -->
</SearchPaths>
<Variables>
<!-- a list of string variables to add to the scope -->
</Variables>
<Commands>
<!-- a list of preconfigured commands -->
</Commands>
<InitScript src="init.py"/>
<StartupScript src="startup.py"/>
</RevitPythonShell>
188 changes: 94 additions & 94 deletions RevitPythonShell/init.py → RevitPythonShell/DefaultConfig/init.py
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
# these commands get executed in the current scope
# of each new shell (but not for canned commands)
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.DB.Analysis import *

uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document

from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.UI import UIApplication


def alert(msg):
TaskDialog.Show('RevitPythonShell', msg)


def quit():
__window__.Close()
exit = quit


def get_selected_elements(doc):
"""API change in Revit 2016 makes old method throw an error"""
try:
# Revit 2016
return [doc.GetElement(id)
for id in __revit__.ActiveUIDocument.Selection.GetElementIds()]
except:
# old method
return list(__revit__.ActiveUIDocument.Selection.Elements)
selection = get_selected_elements(doc)
# convenience variable for first element in selection
if len(selection):
s0 = selection[0]

#------------------------------------------------------------------------------
import clr
from Autodesk.Revit.DB import ElementSet, ElementId

class RevitLookup(object):
def __init__(self, uiApplication):
'''
for RevitSnoop to function properly, it needs to be instantiated
with a reference to the Revit Application object.
'''
# find the RevitLookup plugin
try:
rlapp = [app for app in uiApplication.LoadedApplications
if app.GetType().Namespace == 'RevitLookup'
and app.GetType().Name == 'App'][0]
except IndexError:
self.RevitLookup = None
return
# tell IronPython about the assembly of the RevitLookup plugin
clr.AddReference(rlapp.GetType().Assembly)
import RevitLookup
self.RevitLookup = RevitLookup
# See note in CollectorExt.cs in the RevitLookup source:
self.RevitLookup.Snoop.CollectorExts.CollectorExt.m_app = uiApplication
self.revit = uiApplication

def lookup(self, element):
if not self.RevitLookup:
print 'RevitLookup not installed. Visit https://github.com/jeremytammik/RevitLookup to install.'
return
if isinstance(element, int):
element = self.revit.ActiveUIDocument.Document.GetElement(ElementId(element))
if isinstance(element, ElementId):
element = self.revit.ActiveUIDocument.Document.GetElement(element)
if isinstance(element, list):
elementSet = ElementSet()
for e in element:
elementSet.Insert(e)
element = elementSet
form = self.RevitLookup.Snoop.Forms.Objects(element)
form.ShowDialog()
_revitlookup = RevitLookup(__revit__)
def lookup(element):
_revitlookup.lookup(element)

#------------------------------------------------------------------------------

# a fix for the __window__.Close() bug introduced with the non-modal console
class WindowWrapper(object):
def __init__(self, win):
self.win = win

def Close(self):
self.win.Dispatcher.Invoke(lambda *_: self.win.Close())

def __getattr__(self, name):
return getattr(self.win, name)
__window__ = WindowWrapper(__window__)
# these commands get executed in the current scope
# of each new shell (but not for canned commands)
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.DB.Analysis import *

uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document

from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.UI import UIApplication


def alert(msg):
TaskDialog.Show('RevitPythonShell', msg)


def quit():
__window__.Close()
exit = quit


def get_selected_elements(doc):
"""API change in Revit 2016 makes old method throw an error"""
try:
# Revit 2016
return [doc.GetElement(id)
for id in __revit__.ActiveUIDocument.Selection.GetElementIds()]
except:
# old method
return list(__revit__.ActiveUIDocument.Selection.Elements)
selection = get_selected_elements(doc)
# convenience variable for first element in selection
if len(selection):
s0 = selection[0]

#------------------------------------------------------------------------------
import clr
from Autodesk.Revit.DB import ElementSet, ElementId

class RevitLookup(object):
def __init__(self, uiApplication):
'''
for RevitSnoop to function properly, it needs to be instantiated
with a reference to the Revit Application object.
'''
# find the RevitLookup plugin
try:
rlapp = [app for app in uiApplication.LoadedApplications
if app.GetType().Namespace == 'RevitLookup'
and app.GetType().Name == 'App'][0]
except IndexError:
self.RevitLookup = None
return
# tell IronPython about the assembly of the RevitLookup plugin
clr.AddReference(rlapp.GetType().Assembly)
import RevitLookup
self.RevitLookup = RevitLookup
# See note in CollectorExt.cs in the RevitLookup source:
self.RevitLookup.Snoop.CollectorExts.CollectorExt.m_app = uiApplication
self.revit = uiApplication

def lookup(self, element):
if not self.RevitLookup:
print 'RevitLookup not installed. Visit https://github.com/jeremytammik/RevitLookup to install.'
return
if isinstance(element, int):
element = self.revit.ActiveUIDocument.Document.GetElement(ElementId(element))
if isinstance(element, ElementId):
element = self.revit.ActiveUIDocument.Document.GetElement(element)
if isinstance(element, list):
elementSet = ElementSet()
for e in element:
elementSet.Insert(e)
element = elementSet
form = self.RevitLookup.Snoop.Forms.Objects(element)
form.ShowDialog()
_revitlookup = RevitLookup(__revit__)
def lookup(element):
_revitlookup.lookup(element)

#------------------------------------------------------------------------------

# a fix for the __window__.Close() bug introduced with the non-modal console
class WindowWrapper(object):
def __init__(self, win):
self.win = win

def Close(self):
self.win.Dispatcher.Invoke(lambda *_: self.win.Close())

def __getattr__(self, name):
return getattr(self.win, name)
__window__ = WindowWrapper(__window__)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# script that is run when Revit starts in the IExternalApplication.Startup event.
try:
# add your code here
# ...
__window__.Close() # closes the window
except:
import traceback # note: add a python27 library to your search path first!
# script that is run when Revit starts in the IExternalApplication.Startup event.
try:
# add your code here
# ...
__window__.Close() # closes the window
except:
import traceback # note: add a python27 library to your search path first!
traceback.print_exc() # helps you debug when things go wrong
Binary file removed RevitPythonShell/Images/Thumbs.db
Binary file not shown.
Binary file removed RevitPythonShell/Resources/PythonConsole16x16.png
Binary file not shown.
Binary file removed RevitPythonShell/Resources/PythonConsole32x32.png
Binary file not shown.
Binary file removed RevitPythonShell/Resources/PythonScript16x16.png
Binary file not shown.
Binary file removed RevitPythonShell/Resources/PythonScript32x32.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed RevitPythonShell/Resources/Thumbs.db
Binary file not shown.
Binary file removed RevitPythonShell/Resources/ipy.ico
Binary file not shown.
Binary file removed RevitPythonShell/Resources/py.ico
Binary file not shown.
Binary file removed RevitPythonShell/Resources/pycon.ico
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using System.Windows.Forms;

namespace RevitPythonShell
{
/// <summary>
/// Open the configuration dialog.
/// </summary>
[Regeneration(RegenerationOption.Manual)]
[Transaction(TransactionMode.Manual)]
class ConfigureCommand: IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var dialog = new ConfigureCommandsForm();
dialog.ShowDialog();

MessageBox.Show("Restart Revit to see changes to the commands in the Ribbon", "Configure RevitPythonShell", MessageBoxButtons.OK, MessageBoxIcon.Information);

return Result.Succeeded;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using System.Windows.Forms;

namespace RevitPythonShell
{
/// <summary>
/// Open the configuration dialog.
/// </summary>
[Regeneration(RegenerationOption.Manual)]
[Transaction(TransactionMode.Manual)]
class ConfigureCommand: IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var dialog = new ConfigureCommandsForm();
dialog.ShowDialog();

MessageBox.Show("Restart Revit to see changes to the commands in the Ribbon", "Configure RevitPythonShell", MessageBoxButtons.OK, MessageBoxIcon.Information);

return Result.Succeeded;
}
}
}
Loading

0 comments on commit abeda57

Please sign in to comment.