This page provides information about V-Ray for Revit Public APIs.

 

Overview


V-Ray for Revit Public API is a gRPC server application that allows clients to programmatically read and configure V-Ray for Revit's properties and export V-Ray Scenes.

 

 

Service Definition (public_api.proto)


V-Ray for Revit Public API provides the 

public_api.proto

 file, which represents the service definition and protocol format. Alongside the .proto file, two auto-generated C# files are provided - 

PublicApi.cs

 and 

PublicApiGrpc.cs

. These two files contain the C# classes for all requests, responses, messages, and enums. The public_api.proto can be used to generate a binding in a language different from C# and develop a client in any of the supported languages.

 

service ApiServer {

rpc GetProjectName (GetProjectNameRequest) returns (GetProjectNameResponse);

rpc GetProjectChangedNotificationStream(GetProjectChangedNotificationStreamRequest) returns (stream ProjectChangedNotification);

rpc GetViews(GetViewsRequest) returns (GetViewsResponse);

rpc SelectView(SelectViewRequest) returns (SelectViewResponse);

rpc SetBatchRenderView(SetBatchRenderViewRequest) returns (SetBatchRenderViewResponse);

rpc GetProperties(GetPropertiesRequest) returns (GetPropertiesResponse);

rpc GetProperty(GetPropertyRequest) returns (GetPropertyResponse);

rpc SetProperty(SetPropertyRequest) returns (SetPropertyResponse);

rpc ExportVRScene(ExportVRSceneRequest) returns (ExportVRSceneResponse);

rpc GetVRayMaterials(GetVRayMaterialsRequest) returns (GetVRayMaterialsResponse);

rpc SaveVRayMaterialToFile (SaveVRayMaterialToFileRequest) returns (SaveVRayMaterialToFileResponse);

}

 

GetProjectName


GetProjectName

 is a unary RPC that sends a single 

GetProjectNameRequest

 to the server and gets a single 

GetProjectNameResponse

 back. It is used to obtain the name of the currently active project in Revit.



GetProjectNameRequest

message GetProjectNameRequest {

google.protobuf.Empty empty = 1;

}

 

GetProjectNameResponse

message GetProjectNameResponse {

bool success_status = 1;
string message = 2;
string project_name = 3;

}

 

GetProjectChangedNotificationStream


GetProjectChangedNotificationStream

 is a server streaming RPCs where the client sends a 

GetProjectChangedNotificationStreamRequest

 to the server and gets a stream to read a sequence of 

ProjectChangedNotification

 messages back. It is used to receive a notification each time the active project in Revit changes.

 

GetProjectChangedNotificationStreamRequest

message GetProjectChangedNotificationStreamRequest {

google.protobuf.Empty empty = 1;

}

 

ProjectChangedNotification

message ProjectChangedNotification {

string project_name = 1;

}

 

GetViews


GetViews

 is a unary RPC that sends a single 

GetViewsRequest

 to the server and gets a single 

GetViewsResponse

 back. It is used to obtain the names and unique ids of all 3D Views in the project. This information is later used when selecting a view for export.


GetViewsRequest

message GetViewsRequest {

google.protobuf.Empty empty = 1;

}

 

GetViewsResponse

message GetViewsResponse {

bool success_status = 1;
string message = 2;
ViewMap view_map = 3;

}

 

ViewMap

message ViewMap {

map<string, View> values = 1;

}


View

message View {

string unique_id = 1;
string name = 2;
bool batch_render = 3;

}

 

SelectView


SelectView

is a unary RPC that sends a single 

SelectViewRequest

 to the server and gets a single 

SelectViewResponse

 back. It is used to select a view before exporting a V-Ray Scene.


SelectViewRequest

message SelectViewRequest {

string unique_id = 1;

}

GetViews

 RPC.

 

SelectViewResponse

message SelectViewResponse {

bool success_status = 1;
string message = 2;

}

SetBatchRenderView

SetBatchRenderView

is a unary RPC that sends a single

SetBatchRenderViewRequest

 to the server and gets a single

SetBatchRenderViewResponse

back. It is used to specify whether the view will be rendered in a Batch Render.

 

SetBatchRenderViewRequest

message SetBatchRenderViewRequest {

string unique_id = 1;
bool batch_render = 2;

}

 

SetBatchRenderViewResponse

message SelectViewResponse {

bool success_status = 1;
string message = 2;

}

 

GetProperties


GetProperties

is a unary RPC that sends a single 

GetPropertiesRequest

 to the server and gets a single 

GetPropertiesResponse

 back. It is used to get all V-Ray properties for the active project.


GetPropertiesRequest

message GetPropertiesRequest {

google.protobuf.Empty empty = 1;

}

 

GetPropertiesResponse

message GetPropertiesResponse {

bool success_status = 1;
string message = 2;
PropertyMap property_map = 3;

}

 

PropertyMap

message PropertyMap {

map<string, Property> values = 1;

}

 

Property

message Property {

string unique_name = 1;
string readable_name = 2;
string type = 3;
PropertyCategory category = 4;
PropertyValue value = 5;

}

 

PropertyCategory

enum PropertyCategory {

Global = 0;
Material = 1;
Environment = 2;
Camera = 3;
Local = 4;
Swarm = 5;
Channel = 6;
Proxy = 7;
VRayMaterial = 8;

};

 

PropertyValue

message PropertyValue {

oneof value
{

bool bool_value = 1;
int32 int_value = 2;
float float_value = 3;
string string_value = 4;

LightingAnalysisQuantity LightingAnalysisQuantity_value = 5;
LightingAnalysisScale LightingAnalysisScale_value = 6;
LightingAnalysisDisplay LightingAnalysisDisplay_value = 7;
DenoiserMode DenoiserMode_value = 8;
DenoiserEngine DenoiserEngine_value = 9;
DenoiserRadiusType DenoiserRadiusType_value = 10;
VRayRenderEngine VRayRenderEngine_value = 11;
VRayResolutionRatio VRayResolutionRatio_value = 12;
VRayResolutionDPIType VRayResolutionDPIType_value = 13;
VRayResolutionPrinterUnit VRayResolutionPrinterUnit_value = 14;
EnvironmentType EnvironmentType_value = 15;
ScreenPlacementType ScreenPlacementType_value = 16;
BackgroundType BackgroundType_value = 17;
VRaySceneQuality VRaySceneQuality_value = 18;
VRayImageSamplerType VRayImageSamplerType_value = 19;
VRayGIEngine VRayGIEngine_value = 20;
VRayLightEvaluation VRayLightEvaluation_value = 21;
VRayCameraMode VRayCameraMode_value = 22;
VRayCameraStereoLayout VRayCameraStereoLayout_value = 23;
VRayCameraFocusSource VRayCameraFocusSource_value = 24;
LightMixGroupBy LightMixGroupBy_value = 25;
VRaySkyModel VRaySkyModel_value = 26;
VolumeVRayToonWidthUnits VolumeVRayToonWidthUnits_value = 27;

AColor AColor_value = 28;
Color Color_value = 29;

}

}

 

GetProperty


GetProperty

 is a unary RPC that sends a single 

GetPropertyRequest

 to the server and gets a single 

GetPropertyResponse

 back. It is used to get a single V-Ray property from the active project.


GetPropertyRequest

message GetPropertyRequest {

string unique_name = 1;

}

 

GetPropertyResponse

message GetPropertyResponse {

bool success_status = 1;
string message = 2;
Property property = 3;

}

 

SetProperty


SetProperty

 is a unary RPC that sends a single 

SetPropertyRequest

 to the server and gets a single 

SetPropertyResponse

 back. It is used to set a single V-Ray property in the active project.


SetPropertyRequest

message SetPropertyRequest {

string unique_name = 1;
PropertyValue value = 2;

}

 

SetPropertyResponse

message SetPropertyResponse {

bool success_status = 1;
string message = 2;

}

 

ExportVRScene


ExportVRScene

 is a unary RPC that sends a single 

ExportVRSceneRequest

 to the server and gets a single 

ExportVRSceneResponse

 back. It is used to export a V-Ray Scene of the currently selected 3D View.

 

ExportVRSceneRequest

message ExportVRSceneRequest {

string export_file_path = 1;
bool export_compressed = 2;
bool export_hex_format = 3;
bool export_as_archive = 4;

}

 

ExportVRSceneResponse

message ExportVRSceneResponse {

bool success_status = 1;
string message = 2;

}

 

GetVRayMaterials


GetVRayMaterials

 is a unary RPC that sends a single 

GetVRayMaterialsRequest

 to the server and gets a single 

GetVRayMaterialsResponse

 back. It is used to obtain the names of all V-Ray materials in the project. This information is later used when saving a V-Ray material to a .vrmat file.


GetVRayMaterialsRequest

message GetVRayMaterialsRequest {

google.protobuf.Empty empty = 1;

}

 

GetVRayMaterialsResponse

message GetVRayMaterialsResponse {

bool success_status = 1;
string message = 2;
repeated string material_names = 3;

}

 

SaveVRayMaterialToFile


SaveVRayMaterialToFile

 is a unary RPC that sends a single 

SaveVRayMaterialToFileRequest

 to the server and gets a single 

SaveVRayMaterialToFileResponse

 back. It is used to save a V-Ray material along with all of its assets to the file system. When the material is saved, a folder named 

maps

 appears next to the .vrmat file. This folder contains all assets, i.e. textures, used by the material. Always keep the 

maps

 folder and the .vrmat file in the same folder.


SaveVRayMaterialToFileRequest

message SaveVRayMaterialToFileRequest {

string material_name = 1;
string file_path = 2;

}

 

SaveVRayMaterialToFileResponse

message SaveVRayMaterialToFileResponse {

bool success_status = 1;
string message = 2;

}

 

Enums and custom types



LightingAnalysisQuantity

enum LightingAnalysisQuantity {

LuminanceCD = 0;
IlluminanceLX = 1;

}


LightingAnalysisScale

enum LightingAnalysisScale {

Linear = 0;
Logarithmic = 1;

}

 

LightingAnalysisDisplay

enum LightingAnalysisDisplay {

FalseColors = 0;
GridOverlay = 1;

}

 

DenoiserMode

enum DenoiserMode {

ReplaceRGB = 0;
DoNotCalculate = 1;
GenerateChannel = 2;

}

 

DenoiserEngine

enum DenoiserEngine {

Default = 0;
NVIDIA = 1;

}

 

DenoiserRadiusType

enum DenoiserRadiusType {

CustomType = 0;
Mild = 1;
Normal = 2;
Strong = 3;

}

 

VRayRenderEngine

enum VRayRenderEngine {

CPU = 0;
GPU = 4;
RTX = 7;

}

 

VRayResolutionRatio

enum VRayResolutionRatio {

Widescreen = 0;
Screen = 1;
Square = 2;
Picture = 3;
Landscape = 4;
Portrait = 5;
CropRegion = 6;
Custom = 7;

}


VRayResolutionDPIType

enum VRayResolutionDPIType {

UnusedVRayResolutionDPIType = 0;
DPI75 = 75;
DPI96 = 96;
DPI150 = 150;
DPI300 = 300;
DPI600 = 600;

}

UnusedVRayResolutionDPIType: NEVER USE THIS VALUE. IT WAS INTRODUCED DUE TO PROTO SYNTAX LIMITATIONS.

 

VRayResolutionPrinterUnit

enum VRayResolutionPrinterUnit {

Inches = 0;
Millimeters = 1;

}

 

EnvironmentType

enum EnvironmentType {

Sun = 0;
Dome = 1;
None = 2;

}

 

ScreenPlacementType

enum ScreenPlacementType {

ScreenPlacement = 0;
SphericalPlacement = 1;

}

 

BackgroundType

enum BackgroundType {

NoBackground = 0;
CustomBackground = 1;
RevitBackground = 2;

}

 

VRaySceneQuality

enum VRaySceneQuality {

Draft = 0;
Low = 1;
Medium = 2;
High = 3;
VeryHigh = 4;

}

 

VRayImageSamplerType

enum VRayImageSamplerType  {

UnusedVRayImageSamplerType = 0;
Buckets = 1;
Progressive = 3;

}

 

VRayGIEngine

enum VRayGIEngine {

IrradianceMap = 0;
BruteForce = 2;
LightCache = 3;

}

 

VRayLightEvaluation

enum VRayLightEvaluation {

Full = 0;
Adaptive = 2;

}


VRayCameraMode

enum VRayCameraMode {

Standard = 0;
Orthogonal = 7;
SphericalPanorama = 9;
Cube = 10;

}

 

VRayCameraStereoLayout

enum VRayCameraStereoLayout {

UnusedVRayCameraStereoLayout = 0;
SideBySide = 1;
TopBottom = 2;

}


VRayCameraFocusSource

enum VRayCameraFocusSource {

FixedDistance = 0;
FixedPoint = 2;

}

 

LightMixGroupBy

enum LightMixGroupBy {

FamilyType = 0;
IndividualLights = 1;
LightGroups = 2;

}

 

VRaySkyModel

enum VRaySkyModel {

Preetham = 0;
CIEClear = 1;
CIEOvercast = 2;
Hosek = 3;
Improved = 4;

}

 

VolumeVRayToonWidthUnits

enum VolumeVRayToonWidthUnits

Pixels = 0;
Project = 1;

}

 

AColor

message AColor {

float r = 1;
float g = 2;
float b = 3;
float alpha = 4;

}

 

Color

message Color {

float r = 1;
float g = 2;
float b = 3;

}

 

Code Samples (C#)


 

Obtaining the Server Port

In order to connect to the Public API Server, the client needs to know which port the server is running on. When the the V-Ray for Revit Public API Server starts, it chooses a random free port to start on and writes this information in the 

C:\Users\%USERPROFILE%\AppData\Roaming\Chaos Group\V-Ray for Revit 20XX\config.json

, where 

XX

 is the Revit version. When your code is running from within a Revit Addin, use the current process id (i.e. of Revit.exe) to locate the V-Ray for Revit API Server running in the same instance of Revit.exe. When your code is running from a standalone application (console app, WPF app, etc.) and there is more than one instance of the same Revit.exe version running, it is up to you to decide to which instance of V-Ray for Revit API Server to connect to.

Here is how the 

apiServers

 entry might look like in config.json:

"apiServers": [

{

"PID": 22920,
"port": 58538

},
{

"PID": 14792,
"port": 58611

}

]

And here is how you can obtain the port, depending on whether your code is executing from within a Revit Addin or from standalone application:

private const int RevitVersion = 2020;
private static readonly string ConfigJsonPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),

$"Chaos Group\\V-Ray for Revit {RevitVersion}", "config.json");

private static int GetServerPort()

{

var runningInRevitAddon = true;

using (var reader = new StreamReader(ConfigJsonPath))
{

var json = JObject.Parse(reader.ReadToEnd());

var apiServers = json["apiServers"] as JArray;

if (apiServers != null && apiServers.Count > 0)
{

JObject apiServer;
if (runningInRevitAddon)
{

apiServer = apiServers.OfType<JObject>().SingleOrDefault(jo => (int)jo["PID"] == Process.GetCurrentProcess().Id);

}
else
{

apiServer = apiServers.OfType<JObject>().FirstOrDefault();

}

if (apiServer != null)
{

return (int)apiServer["port"];

}

}

}

return -1;

}

 

When the Public API Server is shutdown, i.e. the user closes Revit, its entry is deleted from 

config.json

.

Note that the code above uses the Newtonsoft Json.NET library, but you can read the json file in any way that you prefer.

 

Connecting to the Server


public async Task<bool> ConnectAsync()

{

var serverPort = GetServerPort();
if (serverPort != -1)
{

this.channel = new Channel($"localhost:{serverPort}", ChannelCredentials.Insecure);

var deadline = DateTime.UtcNow.AddSeconds(1);
try
{

await this.channel.ConnectAsync(deadline);

return true;

}
catch (TaskCanceledException)
{

return false;

}

}
else
{

Debug.WriteLine("Public API Server has not started yet!");
return false;

}

}

GetServerPort

is from the previous code snippet.

 

Get the active project name


public async Task<string> GetProjectNameAsync()
{

try
{

var client = new ApiServerClient(this.channel);
var response = await client.GetProjectNameAsync(new GetProjectNameRequest());
if (response.SuccessStatus)
{

return response.ProjectName;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return string.Empty;

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return string.Empty;

}

}

ApiServerClient

GetProjectNameRequest
, and 

GetProjectNameResponse

 are all classes auto-generated by the proto-buffer compiler.

 

Get all 3D Views from the active project


public async Task<IEnumerable<View>> GetViewsAsync()
{

try
{

var client = new ApiServerClient(this.channel);
var response = await client.GetViewsAsync(new GetViewsRequest());
if (response.SuccessStatus)
{

return response.ViewMap.Values.Values;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return Enumerable.Empty<View>();

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return Enumerable.Empty<View>();

}

}

ApiServerClient

GetViewsRequest

, and 

GetViewsResponse

 are all classes auto-generated by the proto-buffer compiler.

 

Select a 3D View


public async Task<bool> SelectViewAsync(string uniqueId)
{

try
{

var client = new ApiServerClient(this.channel);
var response = await client.SelectViewAsync(new SelectViewRequest() { UniqueId = uniqueId });

if (response.SuccessStatus)
{

return true;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return false;

}

}

uniqueId

 is one of the unique ids of the views retrieved in the previous code snippet.

 

Set Batch Render for a 3D View


public async Task<bool> SetBatchRenderViewAsync(string uniqueId, bool batchRender)
{

try
{

var client = new ApiServerClient(this.channel);
var response = await client.SetBatchRenderViewAsync(new SetBatchRenderViewRequest() { UniqueId = uniqueId, BatchRender = batchRender });
if (response.SuccessStatus)
{

return true;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error)
return false;

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return false;

}

}

uniqueId

is one of the unique ids of the views retrieved in the GetViews code snippet.

batchRender

is a boolean value specifying whether the view will be rendered in a Batch Render.

 

Get all properties


public async Task<IEnumerable<Property>> GetPropertiesAsync()
{

try
{

var client = new ApiServerClient(this.channel);
var response = await client.GetPropertiesAsync(new GetPropertiesRequest());
if (response.SuccessStatus)
{

return response.PropertyMap.Values.Values;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return Enumerable.Empty<Property>();

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return Enumerable.Empty<Property>();

}

}

ApiServerClient

GetPropertiesRequest

, and 

GetPropertiesResponse

 are all classes auto-generated by the proto-buffer compiler.

 

Get a single property


public async Task<Property> GetPropertyAsync(string uniqueName)
{

try
{

var client = new ApiServerClient(this.channel);
var response = await client.GetPropertyAsync(new GetPropertyRequest() { UniqueName = uniqueName });
if (response.SuccessStatus)
{

return response.Property;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return null;

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return null;

}

}

uniqueName 

is one of the unique names of the properties retrieved in the previous code snippet.

 

Set property


 public async Task<bool> SetPropertyAsync(string uniqueName, PropertyValue propertyValue)
{

try
{

var client = new ApiServerClient(this.channel);

var request = new SetPropertyRequest()
{

UniqueName = uniqueName,
Value = propertyValue

};

var response = await client.SetPropertyAsync(request);

if (response.SuccessStatus)
{

return true;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return false;

}

}

uniqueName

 is one of the unique names of the properties retrieved in the 

Get all properties

 code snippet. 

propertyValue

 is a 

PropertyValue

 initialized with the correct type of value, based on the property type. The 7 code snippets below use the method defined in this code snippet.


Set bool property


var uniqueName = "GlobalArtificialLightsEnabled";
var propertyValue = new PropertyValue() { BoolValue = true };
SetPropertyAsync(uniqueName, propertyValue);

 

Set int property


var uniqueName = "customResolutionWidth";
var propertyValue = new PropertyValue() { IntValue = 800 };
SetPropertyAsync(uniqueName, propertyValue);

 

Set float property


var uniqueName = "GlobalArtificialLightsIntensity";
var propertyValue = new PropertyValue() { FloatValue = 2.0f };
SetPropertyAsync(uniqueName, propertyValue);

 

Set string property


var uniqueName = "backgroundImagePath";
var propertyValue = new PropertyValue() { StringValue = "C:\myimage.png" };
SetPropertyAsync(uniqueName, propertyValue);

 

Set enum property


var uniqueName = "environmentType";
var propertyValue = new PropertyValue() { EnvironmentTypeValue = EnvironmentType.Dome };
SetPropertyAsync(uniqueName, propertyValue);

 

Set AColor property


var uniqueName = "EnvFogColor";
var propertyValue = new PropertyValue() { AColorValue = new AColor() { R = 0.5f, G = 0.5f, B = 0.5f, Alpha = 1.0f } };
SetPropertyAsync(uniqueName, propertyValue);

 

Set Color property


var uniqueName = "SunFilterColor";
var propertyValue = new PropertyValue() { ColorValue = new Color() { R = 0.5f, G = 0.5f, B = 0.5f } };
SetPropertyAsync(uniqueName, propertyValue);

 

Export V-Ray Scene


public async Task<Tuple<bool, string>> ExportVRSceneAsync(string exportFilePath, bool exportAsArchive, bool exportCompressed, bool exportHexFormat)

{

try
{

var client = new ApiServerClient(this.channel);
try
{

var response = await client.ExportVRSceneAsync(new ExportVRSceneRequest()
{

ExportFilePath = exportFilePath,
ExportAsArchive = exportAsArchive,
ExportCompressed = exportCompressed,
ExportHexFormat = exportHexFormat

});

// If the export was successfull, response.Message will contain the
// actual file path of the exported V-Ray Scene
return new Tuple<bool, string>(response.SuccessStatus, response.Message);

}
catch (TaskCanceledException e)
{

Debug.WriteLine(e);
return new Tuple<bool, string>(false, e.ToString());

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
await this.ShutdownAsync();
return new Tuple<bool, string>(false, e.ToString());

}

}

ApiServerClient

ExportVRSceneRequest

, and

ExportVRSceneResponse

 are all classes auto-generated by the proto-buffer compiler.


Get all V-Ray Material Names


public async Task<IEnumerable<string>> GetVRayMaterialsAsync()
{

try
{

var client = new ApiServerClient(this.channel);

var response = await client.GetVRayMaterialsAsync(new GetVRayMaterialsRequest());
if (response.SuccessStatus)
{

return response.MaterialNames;

}
else
{

MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return Enumerable.Empty<string>();

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return Enumerable.Empty<string>();

}

}

ApiServerClient

GetVRayMaterialsRequest

, and 

GetVRayMaterialsResponse

 are all classes auto-generated by the proto-buffer compiler.


Save V-Ray Material to File


public async Task<Tuple<bool, string>> SaveVRayMaterialToFileAsync(string materialName, string filePath)

{

try
{

var client = new ApiServerClient(this.channel);
try
{

var response = await client.SaveVRayMaterialToFileAsync(new SaveVRayMaterialToFileRequest()
{

MaterialName = materialName,
FilePath = filePath

});

return new Tuple<bool, string>(response.SuccessStatus, response.Message);

}
catch (TaskCanceledException e)
{

Debug.WriteLine(e);
return new Tuple<bool, string>(false, e.ToString());

}

}
catch (RpcException e)
{

Debug.WriteLine(e);
return new Tuple<bool, string>(false, e.ToString());

}

}

ApiServerClient

SaveVRayMaterialToFileRequest

, and 

SaveVRayMaterialToFileResponse

 are all classes auto-generated by the proto-buffer compiler.


Listen for project changed


public async void ListenForProjectChangedAsync()
{

try
{

var client = new ApiServerClient(this.channel);

using (var call = client.GetProjectChangedNotificationStream(new GetProjectChangedNotificationStreamRequest(), null, null, this.cts.Token))
{

while (await call.ResponseStream.MoveNext())
{

var projectName = call.ResponseStream.Current.ProjectName;
Debug.WriteLine("Project has changed to " + projectName);

}

}

}
catch (RpcException e)
{

Debug.WriteLine(e);

}

}

 

Resources


 

V-Ray for Revit Public API Client Reference Implementation


After you install V-Ray for Revit, you can find a reference implementation of a C# client at the following location: C:\Program Files\Chaos Group\V-Ray\V-Ray for Revit\PublicAPIClient.zip. Unzip the archive somewhere on your machine and explore the Visual Studio solution. Most of the code snippets above are taken directly from this sample application. The sample application is just a reference implementation and is provided as is.