简体   繁体   中英

Postable Commands from Revit API using Dynamo for Revit(2015)

Here's the documentation for the relevant API material

在此处输入图片说明

What I'm trying to do is be able to call postable commands from Dynamo (in this case, I cannot even debug because the import clause fails for Autodesk.Revit.UI ). I got the number 10:05:57.614 from the journal file, but it does not mean much to me if I can't import the correct namespace. If I do not import, then the Evaluator tells me that the function calls I want to make are undefined. Please help.

Does this have something to do with the State of the Revit session as it executes a Dynamo script?

And the associated error message:

错误味精

for copy+paste..

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *


import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import System
dataEnteringNode = IN



elemType = UnwrapElement(IN[0])

cmdID = System.Enum.Parse(RevitCommandId, "10:05:57.614")


TransactionManager.Instance.EnsureInTransaction(doc)

uiapp.PostCommand("10:05:57.614")

OUT = uSelect
doc.Regenerate()
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.

This should resolve the issue of being unable to import RevitAPIUI.dll:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

clr.ClearProfilerData()
uiPath = r'C:\Program Files\Autodesk\Revit 2016\RevitAPIUI.dll'
clr.AddReferenceToFileAndPath(uiPath)

from Autodesk.Revit.UI import *

def pickSomething():
    from Autodesk.Revit.UI.Selection import ObjectType
    picked = uiapp.ActiveUIDocument.Selection.PickObject(ObjectType.Element)
    return picked

#Assign your output to the OUT variable.
OUT = pickSomething()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM