2016-04-01 30 views
0

我想獲得2016 compit安裝的revitpython外殼和我有問題運行代碼。修復python外殼問題運行腳本/安裝

我已經安裝了外殼和路徑設置的IronPython 2.7.3本網站上的說明,

http://blog.productspec.net/2015/02/03/beginners-guide-to-python-in-autodesk-revit/

我也跟着上嘗試運行腳本多個教程。這一個似乎是把一個句子變成全部大寫字母的最簡單方法。

import clr 
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI') 
from Autodesk.Revit.DB import * 

app = __revit__.Application 
doc = __revit__.ActiveUIDocument.Document 

t = Transaction(doc, 'convert text') 
t.Start() 
for el in uidoc.Selection.Elements: 
    el.Text=el.Text.upper() 
t.Commit() 

我知道蟒蛇的一點點,形成我可以告訴,這看起來不錯,但我得到試圖運行時返回此錯誤。

enter image description here

那麼這是有這個下拉作秀詳細信息下:

Revit中遇到System.MissingMemberException: '選擇' 對象 有沒有屬性 '元素' 在 IronPython.Runtime .Binding.PythonGetMemberBinder.FastErrorGet'1.GetError(CallSite site,TSelfType target,CodeContext context)blah blah blah

enter image description here

所有幫助表示讚賞。

回答

0

Check out the Revit 2016 SDK。 Selection.Elements在2015年已棄用。嘗試Selection.GetElementIds()。你將遍歷一組elementId而不是一個元素,並且需要使用Document.GetElement方法來獲取元素對象。

+0

謝謝你,我確實嘗試過這些,我認爲它可能是它寫的方式。我最終發現了這一點,似乎儘管我還沒有嘗試過Selection.GetElementIds()或Document.GetElement方法。 有沒有辦法添加文件?我會嘗試上傳代碼,但它說很多字符 – Cflux