VBA code to color code material install in Revit

VBA code to color code material install in Revit

Anonymous
Not applicable
1,906 Views
9 Replies
Message 1 of 10

VBA code to color code material install in Revit

Anonymous
Not applicable

Hello! I'd like to color code material in revit as red, yellow, or green to indicate if material was not delivered, delivered, or installed respectively. I would like to track progress of the material in excel. I have uniquely identified materials with a material ID and exported the revit schedule to excel. I would like to track each material ID with a 0 for not delivered, 1 for delivered, and 2 for installed in excel. 

 

I would like to use a macro to translate the tracking in excel back into revit, and color code materials accordingly. Could someone assist me with writing this macro? Thank you! 

0 Likes
1,907 Views
9 Replies
Replies (9)
Message 2 of 10

RPTHOMAS108
Mentor
Mentor

Visual basic for applications is not supported by RevitAPI (VB.Net is).

 

I don't understand what you mean by colour code a material? A material has a set visual appearance given to it by it's appearance asset.

 

If you actually mean that you want to colour Revit Elements in a view in accordance with the status of one or all of the materials associated with an individual element (an element can have multiple materials) then this can be done. Note however that a Revit Element has materials applied to it governed entirely by how a Family content author sets out. i.e. Materials applicable to an Element could be set by:

Category/Subcategory applied to solid in family (with object styles including materials for these set in project)

Material Parameter value applied to solid in family (with parameter set in project).

Painted surfaces of the element

 

Your task will most likely involve the following API calls:

Element.GetMaterialIds

View.GetElementOverrides

View.SetElementOverrides

OverrideGraphicSettings.SetProjectionBackGroundPatternColor

OverrideGraphicSettings.SetProjectionBackGroundPatternId (must be a solid pattern to cover surface with colour).

 

An alternative approach which seems to better suit your workflow would be to create a view visibility filter with rules for your (0, 1 ,2) parameter values and add this to a view.

View.SetFilterOverrides

OverrideGraphicSettings (as above)

ParameterFilterElement (there is an example in RevitAPI.chm for this).

 

Here is your starting point:

Revit Platform Technologies | Autodesk Developer Network

 

RevitAPI.chm within the SDK is very useful.

 

 

 

 

 

 

Message 3 of 10

Anonymous
Not applicable

I really appreciate the response! Those clarifications are correct.

 

For awareness, I work for a General Contractor and new to Autodesk products. I'd like to set up a sustainable process to track material progress (tracking if materials have been delivered/installed) for our project teams. We'd like to track in excel because we can manipulate the data to calculate production rate. To reduce data duplication, we'd also like to use the same excel template to pull data into revit. In excel, I'm aiming to create a template table that will populate a 0, 1, or 2 to indicate material status. Would it be better to leverage Dynamo or a macro to import the data into revit?  Does it make a difference?  

0 Likes
Message 4 of 10

aignatovich
Advisor
Advisor

Hi!

 

You'll try to combine the model (design) data and business data (supply process). Maybe it is better to use different tools to achieve this task. Autodesk offers a platform called "Forge" to do such integrations.

 

Leave Revit to the engineers, let them create a model, prepare material supply data by yourself and see the data combined in browser. You don't need to install Revit, you can explore this data with your smartphone.

Look at this picture. It is a web site page. On the left pane you can choose phases and select a date range with a calendar. On the right pane you'll see the model with element colorization by current phase.

aignatovich_0-1608132471979.png

 

Message 5 of 10

aignatovich
Advisor
Advisor

And how it looks in the cell phone browser

aignatovich_0-1608133354697.png

 

Message 6 of 10

RPTHOMAS108
Mentor
Mentor

You can do it with either pure API such as Macro or add-in or use Dynamo they both have similar capabilities.

 

In Dynamo you may find that someone has covered this because populating parameters from excel is quite a common task. What you choose in this instance is largely going to depend on your experience i.e. lack of API experience may lead you to Dynamo where someone has created the building blocks for this task.

 

It is also true what @aignatovich has noted there are exciting things happening with Forge and being web based means no limitations regarding the end audience i.e. they don't need to be running Revit.

Message 7 of 10

aignatovich
Advisor
Advisor

@RPTHOMAS108 , Sure you can do it with Revit, it has a good API we can use 🙂

Message 8 of 10

Anonymous
Not applicable

This is great, thank you! I'm stumbling through Forge tutorials now. I'm concerned that I'm not going to achieve my desired outcome. I want to (1) visualize the data in bim360 by overriding material graphics to denote delivery/install status, and (2) manipulate data in excel to track a handful of metrics and pull that data into powerbi for improved transparency. So I'm looking to continue to leverage excel, but I want an add-in that translates a particular set of data to the model. I'm thinking Forge will require duplicative data entry to achieve both these goals. Let me know if that's incorrect, thank you!  

0 Likes
Message 9 of 10

Anonymous
Not applicable

What about assemble? It seems that I can pull sync the model to the assemble platform to colorize and pull the data from assemble into powerbi. I should be able to translate the formulas I had in excel to dax. 

0 Likes
Message 10 of 10

aignatovich
Advisor
Advisor

You can access BIM360 models with Forge Services. There is no need to use Model Derivative API to translate the model if you have it in BIM 360 project. You can create a web site that displays models from BIM 360 with Forge viewer (you can't add your own extensions to alter BIM360 interface, unless you create a plugin for your browser).

If you have a model, you can try to extract the data with Model Derivative API. If there is no enough data, you can try to use Design Automation for Revit to get it. For example, you can't get the whole wall structure from the Revit model with Model Derivative service. If you have some data and you want to create or alter models, you can use Design Automation services

0 Likes