Edit Light Fixture Asset programmatically

Edit Light Fixture Asset programmatically

rossen.hristov
Enthusiast Enthusiast
510 Views
4 Replies
Message 1 of 5

Edit Light Fixture Asset programmatically

rossen.hristov
Enthusiast
Enthusiast

Hello,

 

I have obtained an instance of Autodesk.Revit.DB.Visual.Asset from a Autodesk.Revit.DB.LightNode.  I know that materials for example can be edited with Revit's API by using AppearanceAssetEditorScope, creating a transaction, etc. 

 

My question is, can the same thing be done for lights? Can we edit lights programmatically? I need to change the "intensityValue" and "filterColor" parameters of a light. When I try to set the property value, I get the InvalidOperationException "The asset property is not editable. Asset can be edited only in an edit scope."

 

How to I get a AppearanceAssetEditorScope for a light? Maybe it is not possible for lights?

 

In other words, is there a similar example to this one, but for lights: https://www.revitapidocs.com/2019/743c74ba-12de-4d77-a677-325229525955.htm

0 Likes
511 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

All you need in order to instantiate the AppearanceAssetEditScope is the document, isn't it?

 

I don't see where the problem is.

 

Ah, looking further, I see the generic EditScope base class, and some derived classes:

 

https://www.revitapidocs.com/2019/bac11282-3a3b-953e-8bc4-960c62da4946.htm

 

Do you mean the error message is saying that an edit scope is required for lights, and there is no such thing available?

 

Can you please submit a minimal reproducible case so we can see what your steps are and what might be wrong?

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Then I can share that with the development team for further analysis if required.

 

Thank you!

  



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

0 Likes
Message 3 of 5

rossen.hristov
Enthusiast
Enthusiast

Do you mean the error message is saying that an edit scope is required for lights, and there is no such thing available?

 

That is exactly what I mean. Materials have the AppearanceAssetId property and you can create an AppearanceAssetEditScope class and call its Start and Commit methods. 

 

There is no such thing for lights. Or is there? I read your blog post here: https://thebuildingcoder.typepad.com/blog/2017/11/modifying-material-visual-appearance.html

 

Can we do the same for lights?

 

My question is very simple, can you edit lights programmatically like you can edit materials. It is a yes/no question.

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Okey-doke. I asked the devteam for you. I did not tell them that you only want a yes or no answer. You might end up being frustrated if they did.

 



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

0 Likes
Message 5 of 5

rossen.hristov
Enthusiast
Enthusiast

Thank you!

0 Likes