Skip to content

Commit 86bb941

Browse files
authored
Merge pull request #137 from architecture-building-systems/develop
Puhblish New Version For IronPython3.4
2 parents eecc688 + ad777c2 commit 86bb941

22 files changed

+120
-62
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
- 2022-12-16 **2.0.0**
3+
- Add support IronPython 3.4 [#136](https://github.com/architecture-building-systems/revitpythonshell/pull/136)
4+
- Please follow [Upgrade from IronPython2 to IronPython 3](https://github.com/IronLanguages/ironpython3/blob/master/Documentation/upgrading-from-ipy2.md) to upgrade your code.
25
- 2022-09-22 **1.0.2**
36
- Fix set CollectorExt.m_app error. [#128](https://github.com/architecture-building-systems/revitpythonshell/pull/128)
47
- 2022-06-27 **1.0.1**

Installer/Installer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const string projectName = "RevitPythonShell";
1313
const string outputName = "RevitPythonShell";
1414
const string outputDir = "output";
15-
const string version = "1.0.2";
15+
const string version = "2.0.0";
1616

1717
var fileName = new StringBuilder().Append(outputName).Append("-").Append(version);
1818
var project = new Project

Installer/Installer.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
</PropertyGroup>
1313
<ItemGroup>
1414
<PackageReference Include="WixSharp.bin">
15-
<Version>1.19.*</Version>
15+
<Version>1.20.2</Version>
1616
</PackageReference>
1717
<PackageReference Include="WixSharp.wix.bin">
18-
<Version>3.11.*</Version>
18+
<Version>3.11.2</Version>
1919
</PackageReference>
2020
</ItemGroup>
2121
</Project>

PythonConsoleControl/PythonConsoleCompletionDataProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected void PopulateFromPythonType(List<PythonCompletionData> items, string n
157157
//string dirCommand = "dir(" + objectName + ")";
158158
string dirCommand = "sorted([m for m in dir(" + name + ") if not m.startswith('__')], key = str.lower) + sorted([m for m in dir(" + name + ") if m.startswith('__')])";
159159
object value = commandLine.ScriptScope.Engine.CreateScriptSourceFromString(dirCommand, SourceCodeKind.Expression).Execute(commandLine.ScriptScope);
160-
foreach (object member in (value as IronPython.Runtime.List))
160+
foreach (object member in (value as IronPython.Runtime.PythonList))
161161
{
162162
bool isInstance = false;
163163

PythonConsoleControl/PythonConsoleControl.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
</PropertyGroup>
1515
<ItemGroup>
1616
<PackageReference Include="AvalonEdit" Version="6.0.1" />
17+
<PackageReference Include="IronPython" Version="3.4.0" />
1718
</ItemGroup>
1819
<ItemGroup>
1920
<Reference Include="IronPython">

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ database exploration tool to become a Revit API Ninja :)
3131
- `lookup()` function for snooping `Element`, `ElementSet` and `ElementId` objects
3232
in [RevitLookup](https://github.com/jeremytammik/RevitLookup)
3333

34+
## IronPython 3
35+
36+
IronPython 3.4 uses Python 3.4 syntax and standard libraries and so your Python code will need to be updated accordingly. There are numerous tools and guides available on the web to help porting from Python 2 to 3.
37+
38+
IronPython 3 targets Python 3, including the re-organized standard library, Unicode strings, and all of the other new features.with user upgrade from **IronPython 2** to **IronPython 3**, please follow [Upgrade from IronPython 2 to IronPython 3](https://github.com/IronLanguages/ironpython3/blob/master/Documentation/upgrading-from-ipy2.md).
39+
40+
Various differences between IronPython and CPython can follow at [Differences IronPython and CPython](https://github.com/IronLanguages/ironpython3/blob/master/Documentation/differences-from-c-python.md).
41+
3442
## Installation
3543

3644
Please follow last release at section [Release](https://github.com/architecture-building-systems/revitpythonshell/releases/latest) support version Support From Revit 2018-2023.
@@ -69,7 +77,7 @@ Learn some python:
6977

7078
Learn about the Revit API:
7179

72-
* [Autodesk Developer Network](T)
80+
* [Autodesk Developer Network](https://www.autodesk.com/developer-network/open)
7381
* [Jeremy Tammiks blog "The Building Coder"](http://thebuildingcoder.typepad.com/)
7482

7583
Tutorials recommended by the community:
-734 KB
Binary file not shown.
-622 KB
Binary file not shown.

RequiredLibraries/IronPython.Wpf.dll

-7 KB
Binary file not shown.

RequiredLibraries/IronPython.dll

-1.7 MB
Binary file not shown.
-46.2 KB
Binary file not shown.
-987 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
-135 KB
Binary file not shown.
Binary file not shown.

RequiredLibraries/WPG.dll

-155 KB
Binary file not shown.

RevitPythonShell/DefaultConfig/init.py

+64-24
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ def alert(msg):
1717

1818
def quit():
1919
__window__.Close()
20+
21+
2022
exit = quit
2123

2224

23-
def get_selected_elements(doc):
25+
def GetSelectedElements(doc):
2426
"""API change in Revit 2016 makes old method throw an error"""
2527
try:
2628
# Revit 2016
@@ -31,7 +33,7 @@ def get_selected_elements(doc):
3133
return list(__revit__.ActiveUIDocument.Selection.Elements)
3234

3335

34-
selection = get_selected_elements(doc)
36+
selection = GetSelectedElements(doc)
3537
# convenience variable for first element in selection
3638
if len(selection):
3739
s0 = selection[0]
@@ -51,43 +53,81 @@ def __init__(self, uiApplication):
5153
try:
5254
rlapp = [app for app in uiApplication.LoadedApplications
5355
if app.GetType().Namespace == 'RevitLookup'
54-
and app.GetType().Name == 'App'][0]
56+
and app.GetType().Name == 'Application'][0]
5557
except IndexError:
5658
self.RevitLookup = None
5759
return
5860
# tell IronPython about the assembly of the RevitLookup plugin
5961
clr.AddReference(rlapp.GetType().Assembly)
6062
import RevitLookup
6163
self.RevitLookup = RevitLookup
62-
# See note in CollectorExt.cs in the RevitLookup source:
63-
try:
64-
self.RevitLookup.Snoop.CollectorExts.CollectorExt.m_app = uiApplication
65-
except TypeError: # assigning m_app is now not required and even not possible
66-
pass
67-
self.revit = uiApplication
6864

69-
def lookup(self, element):
65+
def IsInstalled(self):
7066
if not self.RevitLookup:
7167
print('RevitLookup not installed. Visit https://github.com/jeremytammik/RevitLookup to install.')
72-
return
73-
if isinstance(element, int):
74-
element = self.revit.ActiveUIDocument.Document.GetElement(ElementId(element))
75-
if isinstance(element, ElementId):
76-
element = self.revit.ActiveUIDocument.Document.GetElement(element)
77-
if isinstance(element, list):
78-
elementSet = ElementSet()
79-
for e in element:
80-
elementSet.Insert(e)
81-
element = elementSet
82-
form = self.RevitLookup.Snoop.Forms.Objects(element)
83-
form.ShowDialog()
68+
return False
69+
return True
70+
71+
def SnoopCurrentSelection(self):
72+
if self.IsInstalled():
73+
form = self.RevitLookup.Views.ObjectsView()
74+
form.SnoopAndShow(self.RevitLookup.Core.Selector.SnoopCurrentSelection)
75+
76+
def SnoopElement(self,element):
77+
if self.IsInstalled():
78+
if element is None:
79+
print("element null object, Please input element to snoop")
80+
return
81+
if isinstance(element, int):
82+
element = doc.GetElement(ElementId(element))
83+
if isinstance(element, ElementId):
84+
element = doc.GetElement(element)
85+
if isinstance(element, list):
86+
elementSet = ElementSet()
87+
for e in element:
88+
elementSet.Insert(e)
89+
form = self.RevitLookup.Views.ObjectsView(elementSet)
90+
self.RevitLookup.Core.ModelessWindowFactory.Show(form)
91+
pass
92+
form = self.RevitLookup.Views.ObjectsView(element)
93+
self.RevitLookup.Core.ModelessWindowFactory.Show(form)
94+
95+
def SnoopActiveView():
96+
if self.IsInstalled():
97+
self.SnoopElement(doc.ActiveView)
98+
99+
def SnoopDb(self):
100+
if self.IsInstalled():
101+
form = self.RevitLookup.Views.ObjectsView()
102+
form.SnoopAndShow(self.RevitLookup.Core.Selector.SnoopDb)
84103

85104

86105
_revitlookup = RevitLookup(__revit__)
87106

88107

89-
def lookup(element):
90-
_revitlookup.lookup(element)
108+
def SnoopCurrentSelection():
109+
_revitlookup.SnoopCurrentSelection()
110+
111+
112+
'''
113+
## Example :
114+
## _revitlookup.SnoopElement(doc.ActiveView)
115+
## _revitlookup.SnoopElement(959510)
116+
## _revitlookup.SnoopElement(doc.ActiveView.Id)
117+
'''
118+
119+
120+
def SnoopElement(element):
121+
_revitlookup.SnoopElement(element)
122+
123+
124+
def SnoopActiveView():
125+
_revitlookup.SnoopActiveView()
126+
127+
128+
def SnoopDb():
129+
_revitlookup.SnoopDb()
130+
91131

92132
# ------------------------------------------------------------------------------
93133

RevitPythonShell/Examples/helloworld.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
helloworld.py - example RevitPythonShell script
33
for testing the DeployRpsAddin program.
44
'''
5-
print 'hello, world :)'
5+
print("Hello World!")
4.52 MB
Binary file not shown.

RpsRuntime/RpsRuntime.csproj

+35-30
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@
5252
<PublishTrimmed>true</PublishTrimmed>
5353
</PropertyGroup>
5454
<ItemGroup>
55-
<Reference Include="PresentationCore"/>
56-
<Reference Include="PresentationFramework"/>
57-
<Reference Include="WindowsBase"/>
55+
<Reference Include="PresentationCore" />
56+
<Reference Include="PresentationFramework" />
57+
<Reference Include="WindowsBase" />
5858
</ItemGroup>
5959
<ItemGroup>
60-
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="$(RevitVersion).*"/>
61-
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI" Version="$(RevitVersion).*"/>
62-
<PackageReference Include="AvalonEdit" Version="6.0.1"/>
60+
<PackageReference Include="DynamicLanguageRuntime" Version="1.3.3" />
61+
<PackageReference Include="IronPython" Version="3.4.0" />
62+
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="$(RevitVersion).*" />
63+
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI" Version="$(RevitVersion).*" />
64+
<PackageReference Include="AvalonEdit" Version="6.0.1" />
6365
</ItemGroup>
6466
<ItemGroup>
6567
<Reference Include="IronPython">
@@ -82,34 +84,34 @@
8284
</Reference>
8385
</ItemGroup>
8486
<ItemGroup>
85-
<Reference Include="PresentationCore"/>
86-
<Reference Include="System"/>
87-
<Reference Include="System.Core"/>
88-
<Reference Include="System.Drawing"/>
89-
<Reference Include="System.Windows.Forms"/>
90-
<Reference Include="System.Xaml"/>
91-
<Reference Include="System.Xml.Linq"/>
92-
<Reference Include="System.Data.DataSetExtensions"/>
93-
<Reference Include="System.Data"/>
94-
<Reference Include="System.Xml"/>
95-
<Reference Include="WindowsBase"/>
87+
<Reference Include="PresentationCore" />
88+
<Reference Include="System" />
89+
<Reference Include="System.Core" />
90+
<Reference Include="System.Drawing" />
91+
<Reference Include="System.Windows.Forms" />
92+
<Reference Include="System.Xaml" />
93+
<Reference Include="System.Xml.Linq" />
94+
<Reference Include="System.Data.DataSetExtensions" />
95+
<Reference Include="System.Data" />
96+
<Reference Include="System.Xml" />
97+
<Reference Include="WindowsBase" />
9698
</ItemGroup>
9799
<ItemGroup>
98-
<Compile Include="ExternalCommandAssemblyBuilder.cs"/>
99-
<Compile Include="IRpsConfig.cs"/>
100-
<Compile Include="RpsConfig.cs"/>
101-
<Compile Include="RpsExternalApplicationBase.cs"/>
102-
<Compile Include="RpsExternalCommandBase.cs"/>
103-
<Compile Include="RpsExternalCommandScriptBase.cs"/>
104-
<Compile Include="ScriptExecutor.cs"/>
100+
<Compile Include="ExternalCommandAssemblyBuilder.cs" />
101+
<Compile Include="IRpsConfig.cs" />
102+
<Compile Include="RpsConfig.cs" />
103+
<Compile Include="RpsExternalApplicationBase.cs" />
104+
<Compile Include="RpsExternalCommandBase.cs" />
105+
<Compile Include="RpsExternalCommandScriptBase.cs" />
106+
<Compile Include="ScriptExecutor.cs" />
105107
<Compile Include="ScriptOutput.cs">
106108
<SubType>Form</SubType>
107109
</Compile>
108110
<Compile Include="ScriptOutput.Designer.cs">
109111
<DependentUpon>ScriptOutput.cs</DependentUpon>
110112
</Compile>
111-
<Compile Include="ScriptOutputStream.cs"/>
112-
<Compile Include="SettingsDictionary.cs"/>
113+
<Compile Include="ScriptOutputStream.cs" />
114+
<Compile Include="SettingsDictionary.cs" />
113115
</ItemGroup>
114116
<ItemGroup>
115117
<EmbeddedResource Include="ScriptOutput.resx">
@@ -118,15 +120,18 @@
118120
</EmbeddedResource>
119121
</ItemGroup>
120122
<ItemGroup>
121-
<EmbeddedResource Include="Resources\PythonScript16x16.png"/>
123+
<EmbeddedResource Include="Resources\PythonScript16x16.png" />
122124
</ItemGroup>
123125
<ItemGroup>
124-
<EmbeddedResource Include="Resources\PythonScript32x32.png"/>
126+
<EmbeddedResource Include="Resources\PythonScript32x32.png" />
125127
</ItemGroup>
126128
<ItemGroup>
127-
<EmbeddedResource Include="Resources\python_27_lib.zip"/>
129+
<EmbeddedResource Include="Resources\python_27_lib.zip" />
128130
</ItemGroup>
129131
<ItemGroup>
130-
<Folder Include="Properties\"/>
132+
<Folder Include="Properties\" />
133+
</ItemGroup>
134+
<ItemGroup>
135+
<EmbeddedResource Include="Resources\IronPython.3.4.0.zip" />
131136
</ItemGroup>
132137
</Project>

RpsRuntime/ScriptExecutor.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ private void AddEmbeddedLib(ScriptEngine engine)
131131
{
132132
// use embedded python lib
133133
var asm = this.GetType().Assembly;
134-
var resQuery = from name in asm.GetManifestResourceNames()
135-
where name.ToLowerInvariant().EndsWith("python_27_lib.zip")
134+
string[] resourceNames = asm.GetManifestResourceNames();
135+
var resQuery = from name in resourceNames
136+
where name.ToLowerInvariant().EndsWith("ironpython.3.4.0.zip")
136137
select name;
137138
var resName = resQuery.Single();
138139
var importer = new IronPython.Modules.ResourceMetaPathImporter(asm, resName);

0 commit comments

Comments
 (0)