Fill rooms with a color based on a parameter value, and printing

Fill rooms with a color based on a parameter value, and printing

m.vallee
Advocate Advocate
5,975 Views
16 Replies
Message 1 of 17

Fill rooms with a color based on a parameter value, and printing

m.vallee
Advocate
Advocate

Hi,

 

I have made a plugin that automates the following process :

  • create view filters based on chosen category(ies) and parameter.
  • apply these filters to newly created views (view plans, view sections, etc).

My issue comes when dealing with rooms.

 

To fill rooms with some color (based on a parameter value), it seems that Revit encourages us to use the "color scheme" dialog box (awfully named BTW).

 

This part of Revit is as far as I know still not accessible with the API, the BuiltInParameter VIEW_SCHEMA_SETTING_FOR_BUILDING never returns a value (so for instance you cannot set the color scheme ElementId to InvalidElementId to remove it) :

 

                    // remove color scheme - no API access, built-in param not working
                      
                    Parameter vcc = view.get_Parameter(BuiltInParameter.VIEW_SCHEMA_SETTING_FOR_BUILDING);
                   // vcc is always null here

if (null != vcc && !vcc.IsReadOnly) { vcc.Set(ElementId.InvalidElementId); }

 

So I tried to do as I did for other Revit categories : I made my rule-based view filters, and, provided that I enable the Room's visibility subcategory "Interior fills" in the V/G settings of a view, I can see the colored filters applied to it. Nice !

 

But after all this work, I read that room interior fills are no longer printable (apparently since Revit 2010), only the color schemes are printable.

It's even more complicated : when you have linked files, the room interior fills of the linked documents print, whereas those of the main document don't !

 

So here we are : on one side, the "color scheme" way which would be "printable" but is not accessible with the API ; and on the other side, the "classic" way of doing things, with view filters and "interior fills" visibility enabled, which can be API-driven but produces views that can't be correctly printed !

 

Does someone have an idea ?

 

Thanks for your help.

 

Maxime

 

0 Likes
5,976 Views
16 Replies
Replies (16)
Message 2 of 17

jeremytammik
Autodesk
Autodesk

Dear Maxime,

 

I just happen to know one possible approach to achieve this.

 

It is done by my Revit MEP HVAC sample application now named AdnRme:

 

https://github.com/jeremytammik/AdnRme

 

It is described in a number of blog posts:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.40

 

It populates a parameter on rooms or spaces, and that parameter is used to drive a colour fill.

 

adnrme_2013_hvac_colour_fill.png

 

 

 

 

 

I hope that matches your needs.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 17

m.vallee
Advocate
Advocate

Hi Jeremy,

 

Thank you for your anwer.

 

Unless I am wrong, in you sample application, you set the CFM/SF parameter on each space programmatically, but the color scheme that uses this parameter to produce a colored view is not made with the API. This is precisely what I want to do.

 

Maxime

0 Likes
Message 4 of 17

jeremytammik
Autodesk
Autodesk

Dear Maxime,

 

You are exactly right. Sorry I missed that.

 

Can you possibly achieve that via PostCommand, or 'Create similar', or the Copy and Paste API?

 

Cheers,

 

Jeremy



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

0 Likes
Message 5 of 17

m.vallee
Advocate
Advocate

"PostCommand": no, I cannot do that because the whole process may create multiple "color schemes" for multiple views, and PostCommand can be called once, at the end. Moreover, the goal is specifically to not asking the user to do it, but to do it programmatically.

 

"Create Similar" or "Copy and Paste" : I cannot even get one "color scheme" to copy, because as I said in my first post the corresponding BuiltInParameter always returns null.

 

I just can't understand why room interior fills (2nd solution) are no longer printable... 

0 Likes
Message 6 of 17

m.vallee
Advocate
Advocate

Has someone faced the same problem, or found an acceptable workaround?

 

Thanks.

 

Maxime

0 Likes
Message 7 of 17

m.vallee
Advocate
Advocate

Hi,

 

I would like to put this topic on top again, as it is Autodesk's Answer Day and I am optimistic :).

 

What can Autodesk propose to us, developers, who want to programmatically produce colored viewplans based on rooms' parameters values AND print these viewplans?

 

  • We can't access with the API what Revit calls "color schemes"
  • If we use the subcategory "Interior fills" and make colored view filters, these rooms' "interior fills" are then NOT printable ! This seems to be intended behavior (so that only color schemes "print"). This behaviour is however not respected when dealing with linked files : rooms'"interior fills" from the linked file DO print...

Thanks for your help.

0 Likes
Message 8 of 17

jeremytammik
Autodesk
Autodesk

Dear Maxime,

 

Thank you for re-prompting.

 

I checked the database, found a corresponding entry CF-3558 [API wish: create colouring scheme with full access to control RGB colors -- 11225814], and added your request to that. Please make a note of this number for future reference.

 

It is marked critical and the customers requesting this include Arup, SOM and now Bouygues, so there is hope.

 

Have you created a wish list entry in the Revit Idea Station for this as well?

 

Thank you!

 

Cheers,

 

Jeremy



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

0 Likes
Message 9 of 17

m.vallee
Advocate
Advocate

Hi Jeremy,

 

Thanks for this feedback.

I hope this question will be solved soon, then.

 

I have not created a wish list entry in the Revit Idea Station, does it worth doing it considering there is already an Autodesk internal API wish ?

 

Maxime

0 Likes
Message 10 of 17

jeremytammik
Autodesk
Autodesk

Hi Maxime,

 

Thank you for your appreciation.

 

Yes, it still helps. You can mention the wish list number in your idea station entry.

 

Cheers,

 

Jeremy



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

0 Likes
Message 12 of 17

Ning_Zhou
Advocate
Advocate

is it possible to just turn on/off the existing color scheme (for instance room name based) for (plan) views on sheets via API? we want to use same views to print "different" set of sheets w/o manually turning on/off color scheme, one w/ color scheme, one w/o color scheme

0 Likes
Message 13 of 17

aignatovich
Advisor
Advisor

Hi!

 

You can try to control these color schemes via view template. Prepare your view template manually, then copy it to your project using ElementTransformUtils.CopyElement method, then set view.ViewTemplateId, print and then restore previous view template

Message 14 of 17

Ning_Zhou
Advocate
Advocate

good idea! thanks aignatovich

0 Likes
Message 15 of 17

Ning_Zhou
Advocate
Advocate

looks like no need of using ElementTransformUtils.CopyElement method,

view.ApplyViewTemplateParameters(vt) will be enough in which vt is color scheme view template,

but still have to create vt manually and beforehand, i assume still no way to create it on the fly?!

0 Likes
Message 16 of 17

aignatovich
Advisor
Advisor

Yes, unfortunately, there is no way to do it programmatically. So it should be created manually in project template or in rvt file near your addin. ElementTransformUtils.CopyElement should be used in the second case to copy view template from other rvt file.

 

Special thanks for suggestion about view.ApplyViewTemplateParameters.

0 Likes
Message 17 of 17

ciganek
Enthusiast
Enthusiast

Just FYI:

 

there's a kind of hack where you can get view filter overrides on rooms to show as defined (i.e. - not washed out and printable).

 

Make sure the Color Fill subcategory is visible, then add a 'dummy' Color Scheme to the view. For instance, create a new 'by range' Color Scheme based on the room's area with an unlikely upper limit, set the fill to solid + white and make it the active scheme for the view.

 

colorscheme.PNG

 

Now add filter overrides to the view - these override the color scheme fill.

 

 

 

We still need the Color Scheme API, though.

 

Peter