Materials, Material Assets (Appearance, Structural, Thermal) and the Visual API

Materials, Material Assets (Appearance, Structural, Thermal) and the Visual API

GaryOrrMBI
Collaborator Collaborator
874 Views
6 Replies
Message 1 of 7

Materials, Material Assets (Appearance, Structural, Thermal) and the Visual API

GaryOrrMBI
Collaborator
Collaborator

This has been a journey. The past few weeks have seen me spending all the time that I can spare reading the API help, reading posts going back years, reading blogs (which get really hard to pull targeted information out of sometimes).

 

Then came trying to put it all together, Snippets of code from the API, some of which can cause just as much confusion as the help that they provide, translating snippets of code that I can barely understand because I don't speak that particular coding language, which is made even worse by the fact that it is usually written by programming professionals that use code shortcuts (which makes reading their examples even harder) and often refer to advanced coding techniques that I simply haven't ever learned since none of this is my real occupation...

 

But hey, I did it.

 

I can now take materials and their related Assets apart and I can create/recreate them.

 

You are welcome to the attached VB file if you are struggling with these same issues. (dump it into a VS project with the appropriate references or copy the subs/functions into a VB macro with the appropriate mods for launching the included tools)

It has functions for collecting and logging the Properties of the Application resident Appearance Assets; the Assets within a Document; the materials within a document and their associated Properties and connected assets; and one for creating a new material with all new assets. Those functions will generate *.txt and *.xml log files that can be used to further examine all of the above.

 

I have attempted to document (with in line comments) the steps required and/or taken, along with why one method may have been chosen over another when such applied, as well as some cautions and some still outstanding questions and/or shortcomings that had to be worked around.

 

If you're well versed in Materials, and have both the time and desire, perhaps you can take a look and see if you have any answers for the commented questions that I still have and have left in the code.

 

There are still plenty of issues, some may just be because I haven't learned all I need to learn yet, but the bigger ones seem to be common from what I have found:

One biggie (in my opinion) is the lack of any direct correlation between the return values when you read Appearance Asset Properties to the Visual API Classes and their properties that should be used to work with them. This is a big complication and makes it really hard to avoid using strings and thereby keep your code language neutral. The descriptions in the API help do not help with that mapping the least little bit.

Another would be the absence of any clear and concise method to differentiate between Physical Property Sets... Structural vs Thermal.

 

Of course, this may all just be an exercise in vanity from a wanna-be but perhaps some may find some of it helpful.

 

-G

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
Replies (6)
Message 2 of 7

GaryOrrMBI
Collaborator
Collaborator

Oops,

The Asset Property type "List" was supposed to recurse to get the values of the list items but I had forgotten to get back and actually make it do so.

 

That is fixed now.

Along the way I decided to actually do something with that massive volume of returns from GatRevitAppearanceAssets ie: application.GetAssets(AssetType.Appearance).

So I created an option to import one of each schema type into the current document.

 

I still don't know the actual source of these assets since they don't match any of the Revit libraries (and I still don't understand why we can't access any material libraries via the API) but I did find something else that is unusual: the only PrismWoodSchema that is contained in that library

GaryOrrMBI_0-1688915465182.png

 

shows as being an "Old Style" rendering Asset once it has been imported into the document:

GaryOrrMBI_1-1688915536417.png

 

Yet, Assets using the PrismOpaqueSchema show as "New Style" Asset types (as would be expected for the above):

GaryOrrMBI_2-1688916293903.png

 

GaryOrrMBI_3-1688916387414.png

 

Just another glitch?

 

-G

 

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
Message 3 of 7

jeremy_tammik
Alumni
Alumni

Wow, thank you for sharing this. Would you like me to add it to the blog as well? Looks like a useful project worth sharing further!

  

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

GaryOrrMBI
Collaborator
Collaborator

@jeremy_tammik 

You're welcome to do so (I'm putting this out there in an effort to give back a little regardless of the method), although I do have a hard time getting around and/or finding what I'm looking for on there so any comments/questions may have to find their way back here 🙂

 

Maybe you can use a little bit of your influence to see if we can't get some of the big issues that this exposes in front of the developers 🙂

 

BTW: this was written to the 2023 API, I haven't tested it for compatibility.beyond that.

 

Happy Drafting... oops, wrong forum, Happy Coding :),

-G

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 5 of 7

jeremy_tammik
Alumni
Alumni

get some of the big issues that this exposes in front of the developers

  

Will do! Happy Sunday evening and a good new week to you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 6 of 7

jeremy_tammik
Alumni
Alumni

Revisiting this I see that don't know what to ask the development team. It needs to be extremely specific. What exactly are you struggling with? What do you observe, what would you expect, what do you require? Thx!

  

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

GaryOrrMBI
Collaborator
Collaborator
You can start with these (collected mostly from the ramblings in my posts).
One biggie (in my opinion) is the lack of any direct correlation between the return values when you read Appearance Asset Properties to the Visual API Classes and their properties that should be used to work with them. This is a big complication and makes it really hard to avoid using strings and thereby keep your code language neutral. The descriptions in the API help do not help with that mapping the least little bit.

Another big one would be the absence of any clear and concise method to differentiate between Physical Property Sets... Structural vs Thermal.

We need a firm method of being able to differentiate Structural and Thermal Property Sets. PSE elements will often return both a thermal and a structural Property Set, and EVERY PSE element will return a structural (your own Snoop will show that pretty well)... yet they can only be used for the correct Property type so something somewhere knows which one is which, we need that information as well.

Then we have: where does application.GetAssets draw from? There is nothing that matches what is found in that return list of assets anywhere that I can find in the system.
The PrismWoodSchema returned from that list shows as an "Old style" rendering Asset once pulled into a document, even though it is clearly a procedural Asset.

We need access to the the AEC material Library as well as any user created libraries (as can be browsed to in the Material Browser.
We need access to the Asset libraries (as can be browsed to in the Assets dialog)

There are a few others in my comments within the code but most end up boiling down to one of these.
Will that get you started?

-G
Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes