Creating Materials With Appearance asset

Creating Materials With Appearance asset

Anonymous
Not applicable
6,979 Views
12 Replies
Message 1 of 13

Creating Materials With Appearance asset

Anonymous
Not applicable

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

 color 2.PNGcolor.PNGoutputoutput

 

http://www.revitapidocs.com/2018.1/d02d0677-341a-8d1a-d3eb-35ff82f01695.htm

 

API Reference

Accepted solutions (1)
6,980 Views
12 Replies
Replies (12)
Message 2 of 13

jeremytammik
Autodesk
Autodesk

Have you looked at the Appearance Asset Editing sample demonstrating the use of the Visual Materials API added to the Revit 2018.1 SDK?

 

http://thebuildingcoder.typepad.com/blog/2017/11/modifying-material-visual-appearance.html

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 13

Anonymous
Not applicable

I saw the Post and even saw the AU Class, But They get existing materials with appearance assets and edit them, I create new materials that apparently doesn't have appearance asset to it (although it has a default generic appearance asset), I cant access it or edit it.

Capture.JPGThis is exactly what im getting. But the Color property from the graphics is not rendering as it has a default appearance asset that doesn't have an id?? or is not associated  with the material??

0 Likes
Message 4 of 13

jeremytammik
Autodesk
Autodesk
Accepted solution

Thank you for doing your research first!

 

Does this discussion help better then?

 

https://forums.autodesk.com/t5/revit-api-forum/changing-material-texture-path-with-editscope/m-p/801...

 

If so, maybe I should create a blog post from it...

 

Thank you!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 13

Anonymous
Not applicable

Almost , But they leave it unfinshed at the end , Il try creating a 'template material' and duplicating and creating new ones from it.I hope i can duplicate the appearance asset with it

 

I also found this on the API docs , so il even try create new appearanceassets and try to link it wtih the mateiral.

 

Capture.PNG

http://www.revitapidocs.com/2018.1/f1daea30-3585-3332-adb1-dfe30d8a8180.htm

 

 

0 Likes
Message 6 of 13

jeremytammik
Autodesk
Autodesk

Great!

 

Glad to hear that it helps and you can move forward.

 

I very much look forward to hearing how it goes for you.

 

So you agree that this solution should make it onto The Building Coder blog as well, then, do you?

 

Thank you!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 13

Anonymous
Not applicable

Yes, Definelty Since most of the posts regarding this are dead ends, you should post this solution  on the blog.

Smiley Happy

 

 

0 Likes
Message 8 of 13

Anonymous
Not applicable

I Finally managed to do it.. It was  pretty Simple...All i had to do was duplicate a asset and apply  to all the materials created thru API

0 Likes
Message 9 of 13

Anonymous
Not applicable

can you post it how you did it will be very helpful .one more question can we have material assets from one folder having image with name to create

0 Likes
Message 10 of 13

Anonymous
Not applicable

I Wrote an article about it a few months ago, & recently the code has been added as nodes in 'Genus Loci' Package.

 

https://www.linkedin.com/pulse/extracting-online-paint-color-catalog-create-material-kumar-igbc-ap

Message 11 of 13

Anonymous
Not applicable

So it sounds like you wouldn't be able to do this in a project with no materials.  You would need at least one material that has had its AppearanceAssetElement activated in order to duplicate it.  This seems like a huge oversight on Autodesk part.  Why can't a new material in API created with AppearanceAssetElement without duplicating an existing asset??  This seems very silly if I'm understanding this correctly.

Message 12 of 13

Anonymous
Not applicable

i have installed  revit working properly but merial family is empty only showing catagory options how can i fix it

0 Likes
Message 13 of 13

jeremy_tammik
Alumni
Alumni

I do not know what the 'merial family' might be.

 

Are you doing anything yourself programmatically with the Revit API?

 

If not, please be aware that this is not the best place to ask your question.

 

Please note that this discussion forum is dedicated to programming Revit using the Revit API.

 

If you are not doing anything programmatically yourself using the Revit API, I am afraid this is not the best place to ask such a question.

  

You cannot expect an answer to a question relating to system requirements, installation, product setup, optimisation, usage or other end user support issues here.

 

You should try one of the non-API Revit product support discussion forums instead for that:

 

https://forums.autodesk.com/t5/revit-api-forum/this-forum-is-for-revit-api-programming-questions-not...

  

The people there are much better equipped to address this topic than us programming nerds.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes