Announcements
Welcome to the Revit Ideas Board! Before posting, please read the helpful tips here. Thank you for your Ideas!
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API to create / delete Area Scheme

API to create / delete Area Scheme

The UI allows creating and deleting area scheme

API has an AreaScheme class but seems to be no way to create or delete them.

 

api%20help

area%20scheme%20ui

7 Comments
michael_coffey
Advocate

I tried making a copy of the "Gross Building" ViewFamilyType and seems to allow it but I'm not sure where it goes.

Edit... i figured out that you can make a copy of the Area Scheme instead...

 

public void DuplicateAreaScheme()
		{
			Document doc = this.ActiveUIDocument.Document;
		
			AreaScheme areaScheme = (from v in new FilteredElementCollector(doc).OfClass(typeof(AreaScheme)).Cast<AreaScheme>()
			                         where v.Name == "Gross Building"
			                         select v).First();
			
			if (areaScheme != null)
			{
				using (Transaction t = new Transaction(doc, "New Area Plan Type"))
				{
					t.Start();
					ICollection<ElementId> newElemIds = ElementTransformUtils.CopyElement(doc, areaScheme.Id, XYZ.Zero);
					AreaScheme newVft = doc.GetElement(newElemIds.First()) as AreaScheme;
					newVft.Name = "Plannable";
					View v = ViewPlan.CreateAreaPlan(doc, newVft.Id, new ElementId(1526));
					t.Commit();
				}
			}
			else
				TaskDialog.Show("Error", "areaScheme was null");
		}
cig_ad
Enthusiast

Thanks Micheal for the idea to use ElementTransformUtils.CopyElement to add a new AreaScheme. However, the area plans created using the new scheme don't have a default Color Scheme and the Revit UI doesn't allow adding a new color scheme (you can only duplicate an existing). Any ideas of how to create a new AreaScheme and default Color Scheme for new area plans based on that scheme?

 

Peter

michael_coffey
Advocate

I would imagine that it would be the same, duplicate an existing Color Scheme element using the same method.  Then you could set the color scheme to the plan.  Changing the properties in that element may not be accessible by the API though.  I'm not seeing anything related to Color Schemes in the API help doc.

cig_ad
Enthusiast

Thanks Michael, yeah - this isn't supported by the API (yet?).

I can't find any way to get an existing view's color scheme, let alone set it. There is a builtin category named VIEW_SCHEMA_SETTING_FOR_BUILDING for which get_Parameter returns null.

You can find existing color schemes by filtering for BuiltInCategory.OST_ColorFillSchema, but these have no properties pointing back to views. Maybe there's some kind of binding map but it's surely not in the API.

 

michael_coffey
Advocate

Looks like you will have to vote for the idea here to improve the API:  https://forums.autodesk.com/t5/revit-ideas/api-for-color-schemes-and-ability-to-control-rgb-colors/i...

Unfortunately, they will probably never add it.  As a potential workaround, you could pre-set the color scheme in a View Template and then apply the template to the view.

matthew_conwayN7C2G
Enthusiast

@michael_coffey @cig_ad I'm not able to access any of the Color Scheme utilities manually in Revit after creating an Area Scheme with the code above. Image below shows everything greyed out, any thoughts?: 

matthew_conwayN7C2G_0-1618970381833.png

 

KentBurns
Advocate

Sorry to revise an old thread, but I'm at this point, it seems 2022 has more ColorFillScheme options, but when it comes to creating a default for a new Area Scheme it comes unstuck.

 

Has anyone figured out a way to generate the initial colour scheme associated to the newly created Area plan / Scheme?

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea  

Autodesk Design & Make Report


Autodesk Design & Make Report