我有一个具有RGB值的CSV文件,我可以通过CSV文件通过Dynamo Python脚本在Revit中创建材质,但是创建的材质没有分配AppearanceAsset(即使它具有外观资产选项卡)。我获得了该物料的AppearanceAssetID,它返回“ -1”,根据API的说法,这意味着没有分配的资产。
如何创建已分配外观ID的材料
我想访问外观资产并为其设置颜色,因为通常只设置图形颜色,而不设置外观颜色。
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
def ToRevitColor(dynamoColor):return Color(dynamoColor.Red, dynamoColor.Green, dynamoColor.Blue)
def ToDynamoObject(revitObject, isRevitOwned=False):return revitObject.ToDSType(isRevitOwned)
doc = DocumentManager.Instance.CurrentDBDocument
newMaterials = []
appassetid = []
TransactionManager.Instance.EnsureInTransaction(doc)
mat_name = IN[0]
color = IN[1]
for i,y in zip (mat_name, color):
new_mat_id = Material.Create(doc, i)
new_mat = doc.GetElement(new_mat_id)
new_mat.Color = ToRevitColor(y)
newMaterials.append(ToDynamoObject(new_mat))
appassetid.append(new_mat.AppearanceAssetId)
TransactionManager.Instance.TransactionTaskDone()
OUT = newMaterials,appassetid
http://www.revitapidocs.com/2018.1/d02d0677-341a-8d1a-d3eb-35ff82f01695.htm
API参考