Page History
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.
UI Button | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
UI Button | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
UI Button | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
...
|
Service Definition (public_api.proto)
...
V-Ray for Revit Public API provides the
Highlight | ||
---|---|---|
| ||
|
file, which represents the service definition and protocol format. Alongside the .proto file, two auto-generated C# files are provided -
Highlight | ||
---|---|---|
| ||
|
and
Highlight | ||
---|---|---|
| ||
|
. 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.
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
serviceApiServer{ rpcGetProjectName(GetProjectNameRequest)returns(GetProjectNameResponse); rpcGetProjectChangedNotificationStream(GetProjectChangedNotificationStreamRequest)returns(streamProjectChangedNotification); rpcGetViews(GetViewsRequest)returns(GetViewsResponse); rpcSelectView(SelectViewRequest)returns(SelectViewResponse); rpcSetBatchRenderView(SetBatchRenderViewRequest)returns(SetBatchRenderViewResponse); rpcGetProperties(GetPropertiesRequest)returns(GetPropertiesResponse); rpcGetProperty(GetPropertyRequest)returns(GetPropertyResponse); rpcSetProperty(SetPropertyRequest)returns(SetPropertyResponse); rpcExportVRScene(ExportVRSceneRequest)returns(ExportVRSceneResponse); rpcGetVRayMaterials(GetVRayMaterialsRequest)returns(GetVRayMaterialsResponse); rpcSaveVRayMaterialToFile(SaveVRayMaterialToFileRequest)returns(SaveVRayMaterialToFileResponse); } |
...
GetProjectName
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
back. It is used to obtain the name of the currently active project in Revit.
...
GetProjectNameRequest
has no properties.
...
GetProjectNameResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
success_status:
A boolean indicating whether the RPC succeeded.message:
A string containing an error message in case the RPC failed for some reason.project_name:
The name of the project that is currently active in Revit.
...
GetProjectChangedNotificationStream
...
Highlight | ||
---|---|---|
| ||
|
is a server streaming RPCs where the client sends a
Highlight | ||
---|---|---|
| ||
|
to the server and gets a stream to read a sequence of
Highlight | ||
---|---|---|
| ||
|
messages back. It is used to receive a notification each time the active project in Revit changes.
GetProjectChangedNotificationStreamRequest
...
GetProjectChangedNotificationStreamRequest
has no properties.
...
ProjectChangedNotification
...
project_name
: A string containing the name of the project that is currently active in Revit.
...
GetViews
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
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
has no properties.
...
GetViewsResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
success_status
: A boolean indicating whether the RPC succeeded.message:
A string containing an error message in case the RPC failed for some reason.view_map:
AHighlight color #DBDBDB ViewMap
containing information about all 3D Views in the active project.
ViewMap
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
values:
A map containing all views, where the key is the unique id of theHighlight color #DBDBDB View
, and the value is the
Highlight color #DBDBDB View
itself.
View
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
unique_id
: A string in GUID format that represents the unique id of the view.name:
A string containing the name of the view, i.e. what the user sees in Revit.batch_render:
A boolean specifying whether this view will be rendered as part of Batch Render.
SelectView
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
SelectViewResponse |
back. It is used to select a view before exporting a V-Ray Scene.
...
unique_id:
A string in GUID format that represents the unique id of the view. This is the same string that is obtained with the
Highlight | ||
---|---|---|
| ||
|
RPC.
SelectViewResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
success_status:
A boolean indicating whether the RPC succeeded.message:
A string containing an error message in case the RPC failed for some reason.
SetBatchRenderView
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
back. It is used to specify whether the view will be rendered in a Batch Render.
SetBatchRenderViewRequest
...
unique_id:
A string in GUID format that represents the unique id of the view. This is the same string that is obtained with theGetViews
RPC.batch_render:
A boolean value specifying whether the view will be rendered in a Batch Render.
SetBatchRenderViewResponse
...
success_status:
A boolean indicating whether the RPC succeeded.message:
A string containing an error message in case the RPC failed for some reason.
GetProperties
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
back. It is used to get all V-Ray properties for the active project.
...
GetPropertiesRequest
has no properties.
...
GetPropertiesResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
- success_status: A boolean indicating whether the RPC succeeded.
- message: A string containing an error message in case the RPC failed for some reason.
property_map: A
Highlight color #DBDBDB PropertyMap
containing all properties of the active project.
...
PropertyMap
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
values
: A map containing all properties, where the key is the unique name of the Property, and the value is the Property itself.
...
Property
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
unique_name:
A string that contains the unique name of the property.readable_name:
A string that contains the human-friendly readable name of the property.type:
A string containing the type of the property, i.e. bool, int, string, etc.category:
A PropertyCategory containing the category of the property, i.e. Camera, Environment, etc.value:
A PropertyValue containing the value of the property.
...
PropertyCategory
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
PropertyCategory
is enumeration that contains all possible property categories. Currently, the V-Ray for Revit Public API returns only properties fromCamera, Channel, Environment,
andLocal
categories.
...
PropertyValue
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
value:
Contains oneof the possible values for a property depending on its type.
...
GetProperty
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
back. It is used to get a single V-Ray property from the active project.
...
unique_name:
A string that contains the unique name of the property.
...
GetPropertyResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
- success_status: A boolean indicating whether the RPC succeeded.
- message: A string containing an error message in case the RPC failed for some reason.
- property: A Property instance representing the requested property.
SetProperty
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
back. It is used to set a single V-Ray property in the active project.
...
unique_name:
A string that contains the unique name of the property.value:
A PropertyValue containing the value to be set to the property.
SetPropertyResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
success_status:
A boolean indicating whether the RPC succeeded.message:
A string containing an error message in case the RPC failed for some reason.
...
ExportVRScene
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
back. It is used to export a V-Ray Scene of the currently selected 3D View.
ExportVRSceneRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
export_file_path:
A string containing the absolute path where the V-Ray Scene should be exported.export_compressed:
A boolean indicating whehter to compress plugin property values of lists. Requires export_hex_format to be true.export_hex_format:
A boolean indicating whether to use hex format for arrays and transforms in the V-Ray Scene.export_as_archive:
A boolean indicating whether to export the V-Ray Scene as a 7-Zip archive along with all referenced assets, i.e. textures, HDRs, images, etc.
ExportVRSceneResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
success_status:
A boolean indicating whether the RPC succeeded.message:
If the RPC succeeded, this message would contain the actual path of the exported scene. If the RPC failed, this would be a string containing an error message.
...
GetVRayMaterials
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
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
has no properties.
...
GetVRayMaterialsResponse
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
bool success_status = 1; } |
- success_status: A boolean indicating whether the RPC succeeded.
- message: A string containing an error message in case the RPC failed for some reason.
- material_names: A repeated string field containing the names of all V-Ray materials in the project.
...
SaveVRayMaterialToFile
...
Highlight | ||
---|---|---|
| ||
|
is a unary RPC that sends a single
Highlight | ||
---|---|---|
| ||
|
to the server and gets a single
Highlight | ||
---|---|---|
| ||
|
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
Highlight | ||
---|---|---|
| ||
|
appears next to the .vrmat file. This folder contains all assets, i.e. textures, used by the material. Always keep the
Highlight | ||
---|---|---|
| ||
|
folder and the .vrmat file in the same folder.
...
material_name:
A string containing the name of the V-Ray material that should be saved.file_path:
A string containing the absolute path where the V-Ray Material should be saved.
...
SaveVRayMaterialToFileResponse
...
success_status:
A boolean indicating whether the RPC succeeded.message:
If the RPC failed, this would be a string containing an error message.
...
Enums and custom types
...
LightingAnalysisQuantity
...
Linear:
The colors are mapped in linear scale.Logarithmic:
The colors are mapped in logarithmic scale.
LightingAnalysisDisplayLightingAnalysisDisplay
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
FalseColors:
Fills the frame with a gradient ranging from blue (low values) to red (high values). For the out of range values it uses, respectively, black and white.GridOverlay:
Displays the values at distinct grid points over the frame. They use the same grading colors.
DenoiserMode
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
ReplaceRGB:
Generates all render elements required for denoising, but does not compute a denoised version of the image, neither is the VRayDenoiser render element present.DoNotCalculate:
The VRayDenoiser channel is not present separately in the VFB. The effectsResult channel is generated with the denoised image.GenerateChannel:
The VRayDenoiser and effectsResult channels are generated.
DenoiserEngine
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Default:
Default V-Ray DenoiserNVIDIA:
NVidia Al Denoiser
DenoiserRadiusType
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
CustomType:
Allows the strength and radius parameters to be set to custom values.Mild:
Applies a subtler level of denoising than the Default preset.Normal:
Applies default denoising.Strong:
Applies a stronger level of denoising than the Default preset.
...
VRayRenderEngine
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
CPU:
CPUGPU:
CUDA(GPU)RTX:
RTX(GPU)
VRayResolutionRatio
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
...
DPI75:
75 dpiDPI96:
96 dpiDPI150:
150 dpiDPI300:
300 dpiDPI600:
600 dpi
VRayResolutionPrinterUnit
...
Inches:
InchesMillimeters:
Millimeters
...
EnvironmentType
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Sun = 0;
|
Sun:
V-Ray SunDome:
V-Ray Dome LightNone:
No V-Ray Lights
...
ScreenPlacementType
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
ScreenPlacement = 0;
|
ScreenPlacement:
Screen PlacementSphericalPlacement:
SphericalPlacement
...
BackgroundType
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
NoBackground = 0;
|
NoBackground:
No BackgroundCustomBackground:
Custom BackgroundRevitBackground:
Revit Background
...
VRaySceneQuality
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Draft = 0;
|
Draft:
Draft QualityLow:
Low QualityMedium:
Medium QualityHigh:
High QualityVeryHigh:
VeryHigh Quality
...
VRayImageSamplerType
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
UnusedVRayImageSamplerType = 0;
|
UnusedVRayImageSamplerType:
NEVER USE THIS VALUE. IT WAS INTRODUCED DUE TO PROTO SYNTAX LIMITATIONS.Buckets:
This sampler takes a variable number of samples per pixel based on the difference in intensity between the pixel and its neighbors.Progressive:
This is the default image sampler set in V-Ray for Revit. It renders the entire image progressively in passes.
...
VRayGIEngine
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
IrradianceMap = 0;
|
IrradianceMap:
Indirect Illumination is computed for a few points in a scene. The remaining points use interpolated values. It is built adaptively but is view-dependent.BruteForce:
The simplest approach where indirect illumination is computed individually for each shaded surface point.LightCache:
Traces multiple paths from the camera. It is view-dependent, but handles details and corners better.
...
VRayLightEvaluation
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Full = 0;
|
...
Standard:
A traditional pinhole camera.Orthogonal:
An orthogonal camera.SphericalPanorama:
Spherical camera with independent horizontal and vertical FOV selection that is useful for generating latlong images for spherical VR use.Cube:
A variant of the Box camera with the cube sides arranged in a single row. Unlike the Box camera output, Cube6x1 does not produce an empty space in the output image and is useful for generating cubic VR output.
VRayCameraStereoLayout
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
UnusedVRayCameraStereoLayout = 0;
|
...
FixedDistance:
Fixes the camera focus to the Focus Distance value.FixedPoint:
The focus distance is automatically calculated before the rendering starts, and equals the distance between the camera position and the 3D point selected using the Pick Focus Point Command from the toolbar menu. If no point has been selected, the camera target is used as a default point instead.
LightMixGroupBy
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
FamilyType = 0;
|
FamilyType:
All instances of the same family type are put in a separate Light Select.IndividualLights:
Each light goes to a separate Light Select.LightGroups:
Separate Light Select for each group of lights.
...
VRaySkyModel
Panel |
---|
Preetham = 0;
|
Preetham:
V-Ray Sky procedural texture is generated based on the Preetham et al. method. (UI label: Preetham et al.)CIEClear:
V-Ray Sky procedural texture is generated based on the CIE method for clear sky. (UI label: CIE Clear)CIEOvercast:
V-Ray Sky procedural texture is generated based on the CIE method for cloudy sky. (UI label: CIE Overcast)Hosek:
V-Ray Sky procedural texture is generated based on the Hosek et al. method. (UI label: Hosek et al.)Improved:
V-Ray Sky procedural texture is generated based on the Improved method which has enhanced sunrise and sunset sky. (UI label: PRG Clear Sky)
...
VolumeVRayToonWidthUnits
Panel |
---|
Pixels = 0;
|
Pixels:
Specifies that all of the Contour parameters are considered in pixels.Project:
Specifies that all of the Contour parameters are considered in the project units.
AColor
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
float r = 1;
|
r
: Value between 0.0 and 1.0 for the red color.g
: Value between 0.0 and 1.0 for the green color.b
: Value between 0.0 and 1.0 for the blue color.alpha:
Value between 0.0 and 1.0 for the alpha.
...
Color
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
float r = 1;
|
r
: Value between 0.0 and 1.0 for the red color.g
: Value between 0.0 and 1.0 for the green color.b
: Value between 0.0 and 1.0 for the blue color.
...
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
Highlight | ||
---|---|---|
| ||
C:\Users\%USERPROFILE%\AppData\Roaming\Chaos |
...
\V-Ray for Revit |
...
20##\config.json |
, where
Highlight | ||
---|---|---|
|
...
|
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
Highlight | ||
---|---|---|
| ||
|
entry might look like in config.json:
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
private const int RevitVersion = 2020; $"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; JObject apiServer; apiServer = apiServers.OfType<JObject>().SingleOrDefault(jo => (int)jo["PID"] == Process.GetCurrentProcess().Id); } 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
Highlight | ||
---|---|---|
| ||
|
.
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
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<bool> ConnectAsync() { var serverPort = GetServerPort(); this.channel = new Channel($"localhost:{serverPort}", ChannelCredentials.Insecure); var deadline = DateTime.UtcNow.AddSeconds(1); await this.channel.ConnectAsync(deadline); return true; } return false; } } Debug.WriteLine("Public API Server has not started yet!"); } } |
Highlight | ||
---|---|---|
| ||
|
is from the previous code snippet.
Get the active project name
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<string> GetProjectNameAsync() try var client = new ApiServerClient(this.channel); return response.ProjectName; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
,
Highlight | ||
---|---|---|
| ||
GetProjectNameRequest |
, and
Highlight | ||
---|---|---|
| ||
|
are all classes auto-generated by the proto-buffer compiler.
Get all 3D Views from the active project
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<IEnumerable<View>> GetViewsAsync() try var client = new ApiServerClient(this.channel); return response.ViewMap.Values.Values; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
,
Highlight | ||
---|---|---|
| ||
|
, and
Highlight | ||
---|---|---|
| ||
|
are all classes auto-generated by the proto-buffer compiler.
Select a 3D View
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<bool> SelectViewAsync(string uniqueId) try var client = new ApiServerClient(this.channel); return true; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
is one of the unique ids of the views retrieved in the previous code snippet.
Set Batch Render for a 3D View
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<bool> SetBatchRenderViewAsync(string uniqueId, bool batchRender) try var client = new ApiServerClient(this.channel); return true; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error) } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
is one of the unique ids of the views retrieved in the GetViews code snippet.
Highlight | ||
---|---|---|
| ||
|
is a boolean value specifying whether the view will be rendered in a Batch Render.
Get all properties
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<IEnumerable<Property>> GetPropertiesAsync() try var client = new ApiServerClient(this.channel); return response.PropertyMap.Values.Values; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
,
Highlight | ||
---|---|---|
| ||
|
, and
Highlight | ||
---|---|---|
| ||
|
are all classes auto-generated by the proto-buffer compiler.
Get a single property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<Property> GetPropertyAsync(string uniqueName) try var client = new ApiServerClient(this.channel); return response.Property; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
is one of the unique names of the properties retrieved in the previous code snippet.
Set property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<bool> SetPropertyAsync(string uniqueName, PropertyValue propertyValue) try var client = new ApiServerClient(this.channel); UniqueName = uniqueName, }; return true; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
is one of the unique names of the properties retrieved in the
Highlight | ||
---|---|---|
| ||
|
code snippet.
Highlight | ||
---|---|---|
| ||
|
is a
Highlight | ||
---|---|---|
| ||
|
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.
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
...
Set int property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
...
Set float property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
...
Set string property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
...
Set enum property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
...
Set AColor property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Set Color property
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Export V-Ray Scene
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<Tuple<bool, string>> ExportVRSceneAsync(string exportFilePath, bool exportAsArchive, bool exportCompressed, bool exportHexFormat) { try var client = new ApiServerClient(this.channel); var response = await client.ExportVRSceneAsync(new ExportVRSceneRequest() ExportFilePath = exportFilePath, }); // If the export was successfull, response.Message will contain the } Debug.WriteLine(e); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
,
Highlight | ||
---|---|---|
| ||
|
, and
Highlight | ||
---|---|---|
| ||
|
are all classes auto-generated by the proto-buffer compiler.
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<IEnumerable<string>> GetVRayMaterialsAsync() try var client = new ApiServerClient(this.channel); var response = await client.GetVRayMaterialsAsync(new GetVRayMaterialsRequest()); return response.MaterialNames; } MessageBox.Show(response.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
,
Highlight | ||
---|---|---|
| ||
|
, and
Highlight | ||
---|---|---|
| ||
|
are all classes auto-generated by the proto-buffer compiler.
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public async Task<Tuple<bool, string>> SaveVRayMaterialToFileAsync(string materialName, string filePath) { try var client = new ApiServerClient(this.channel); var response = await client.SaveVRayMaterialToFileAsync(new SaveVRayMaterialToFileRequest() MaterialName = materialName, }); return new Tuple<bool, string>(response.SuccessStatus, response.Message); } Debug.WriteLine(e); } } Debug.WriteLine(e); } } |
Highlight | ||
---|---|---|
| ||
|
,
Highlight | ||
---|---|---|
| ||
|
, and
Highlight | ||
---|---|---|
| ||
|
are all classes auto-generated by the proto-buffer compiler.
...
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
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(e); } } |
...
Resources
...
Fancy Bullets | ||
---|---|---|
| ||
...
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.
UI Text Box | ||
---|---|---|
| ||
For versions prior to V-Ray 7, the default location of the reference implementation of a C# client is C:\Program Files\Chaos Group\V-Ray\V-Ray for Revit\PublicAPIClient.zip. |
Section | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||
Section | |||||||||||||||||||
|
Copyrights
...
Copyright (c) 2016-2023, Chaos Software EOOD
All rights reserved. These coded instructions, statements and computer programs contain information proprietary to Chaos Software EOOD, which is protected by the appropriate copyright laws and may not be disclosed to third parties or copied or duplicated, in whole or in part, without prior written consent of Chaos Software EOOD.