Message 1 of 13

Not applicable
10-14-2018
12:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a CSV File with RGB Values that im using to create materials in Revit through Dynamo Python scripting, However the materials that are created does not have AppearanceAsset assigned to it(even though it has a appearance asset tab}.Since when i get the AppearanceAssetID for the Material it Returns '-1' which as per the API means there is no assigned asset to it.
How do i create materials with Appearance IDs already assigned
I want to access the Appearance asset and set the Color to it, Since normally only the graphics color is set and not the appearance Color.
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
output
http://www.revitapidocs.com/2018.1/d02d0677-341a-8d1a-d3eb-35ff82f01695.htm
API Reference
Solved! Go to Solution.