Creating a material with texture is slow

Creating a material with texture is slow

jnbagaleP8GZP
Explorer Explorer
1,409 Views
13 Replies
Message 1 of 14

Creating a material with texture is slow

jnbagaleP8GZP
Explorer
Explorer

I am following Jeremy's post on https://jeremytammik.github.io/tbc/a/1850_material_level_pixel.html  to create material and apply te...

 

The part with AppearanceAssetEditScope start and Commit takes almost 0.7 second. 

The speed doesn't seem to change with number of materials.

On my test 100 materials take around 74 seconds and 1000 materials take around 737 seconds.

Typically, we need to create more than 200 materials, which takes more than 2 minutes but worst case scenarios have 1400 materials which is taking more than 15 minutes.

 

The model size doesn't seem to have any affect as it takes similar time in empty model and model with objects.

 

I have created a minimal example on github.

 https://github.com/jnbagale/RevitMaterialTexture/tree/master/RevitMaterialTexture

 

A dll built for Revit 2021 and Revit 2022 and the .addin files are included there as well.

To run simply click on the Create Materials with texture button on the toolbar menu for the addin.

 

Any suggestions on how to improve the speed or if I am doing anything wrong which is affecting the speed will be hugely  appreciated. I am using the materials to show results of daylight calculations and the material part is now taking longer than the actual calculation. 

 

Regards

Jiva

 

0 Likes
Accepted solutions (1)
1,410 Views
13 Replies
Replies (13)
Message 2 of 14

jeremy_tammik
Alumni
Alumni

Interesting. I looked at your repository and see that the code does other things at the same time besides creating the materials. I would suggest that you instrument your code to measure separate times for the material creation versus the direct shape and face creation. Otherwise, there is no way to know where the time is actually spent. On a second look, I don't really understand what is going on in your code at all. It looks as if some of the transactions that you start are never committed, so all the work you do in those is lost anyway. Can you clean it up and streamline a bit to make it more readable. I would suggest refactoring into smaller logical units.

  

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

jnbagaleP8GZP
Explorer
Explorer

Hi Jeremy,

 

Thank you for the prompt reply.

 

I have tidied up the code to separate the texture material property part now.

 

I am trying to improve the speed of the ApplyTextureProperties method.

The delete face, create face and applying empty material part is fast.

 

The measured time only included the texture property method but I have now added separate time measurement for all major parts.  The transactions were all committed but everything being in the same method made it confusing. I have moved transactions to separate methods as well. 

 

Please suggest if any speed improvement is possible.

 

Kind Regards

Jiva

 

 

0 Likes
Message 4 of 14

jnbagaleP8GZP
Explorer
Explorer

Hi @jeremy_tammik 

 

Have you had time to look at the issue.

I will work on alternate solutions if the speed cannot be improved than this.

Please let me know if you need any further changes/simplifications to the minimal problem example.

 

Many thanks in advance

Jiva

0 Likes
Message 5 of 14

jeremy_tammik
Alumni
Alumni

Thank you for cleaning up the sample. I have asked the development team for advice on this and hope they will be able to suggest something for you.

  

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

jeremy_tammik
Alumni
Alumni

I received interesting feedback from the devteam: we have identified this performance issue for AppearanceAssetEditScope and this has been fixed in the upcoming next major release of Revit based on the development ticket REVIT-181639. We are currently analysing the possibility to improve the performance for shipped versions.

   

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

jnbagaleP8GZP
Explorer
Explorer

Hi @jeremy_tammik 

 

Thank you so much for the update. 

Great to know it will be fixed in the next major update.

Please keep me updated if you hear anything about existing versions.

 

Regards

Jiva

0 Likes
Message 8 of 14

jeremy_tammik
Alumni
Alumni
Accepted solution

Good news! Also fixed in update releases:

  

The improvement for this performance issue is integrated into 2021.1.6 and 2022.1.2. After these 2 hotfix versions release, users will see the improvement on 2021 and 2022.

  

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

JASONBIRD
Contributor
Contributor

Hi @jeremy_tammik,

 

That's great. I will keep an eye for the new hotfix updates. 

I will mark it solved once I test on those versions.

 

Many thanks for your help on resolving this issue.

 

Reagards

Jiva

0 Likes
Message 10 of 14

jnbagaleP8GZP
Explorer
Explorer

Hi @jeremy_tammik,

 

I can confirm the speed issue is resolved after the hotfixes on  2021 and 2022 versions.

Many thanks for your help regarding this.

 

Regards

Jiva

0 Likes
Message 11 of 14

jeremy_tammik
Alumni
Alumni

Great! Thank you for your appreciation, and thank you even more for your helpful confirmation.

  

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

moe.elsayed
Explorer
Explorer

Hi @jeremy_tammik  any hope for this fix or a workaround on Revit 2020.2.9?

0 Likes
Message 13 of 14

jeremy_tammik
Alumni
Alumni

Sure. Submit a sufficiently convincing business case for the development team and the program manager to show the the importance it has for you and their business. . Please be aware that they are already extremely busy working on the upcoming next major release for this year and the development releases for future major releases in coming years. You will need to prove to them that it is more important for them to make this enhancement to a release that is four or five years old than to continue working on future products, and why it is more important for them to perform this work than for you to update to a newer version of Revit yourself. Good luck!

  

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

moe.elsayed
Explorer
Explorer

Understood, thanks....

0 Likes