Page History
This page provides information about V-Ray Next 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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
service ApiServer { rpc GetProjectName (GetProjectNameRequest) returns (GetProjectNameResponse); rpc GetProjectChangedNotificationStream(GetProjectChangedNotificationStreamRequest) returns (stream ProjectChangedNotification); rpc GetViews(GetViewsRequest) returns (GetViewsResponse); rpc SelectView(SelectViewRequest) returns (SelectViewResponse); 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
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
GetProjectNameRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
message GetProjectNameRequest { google.protobuf.Empty empty = 1; } |
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
GetProjectChangedNotificationStreamRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
GetProjectChangedNotificationStreamRequest
has no properties.
ProjectChangedNotification
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
project_name
: A string containing the name of the project that is currently active in Revit.
GetViews
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
GetViewsRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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:
A
containing information about all 3D Views in the active project.Highlight color #DBDBDB ViewMap
ViewMap
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
values:
A map containing all views, where the key is the unique id of the
, and the value is theHighlight color #DBDBDB View
itself.Highlight color #DBDBDB View
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.
SelectView
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
SelectViewResponse |
SelectViewRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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 | ||
---|---|---|
| ||
|
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.
GetProperties
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
GetPropertiesRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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
containing all properties of the active project.Highlight color #DBDBDB PropertyMap
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
GetPropertyRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
message GetPropertyRequest { string unique_name = 1; } |
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
SetPropertyRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
GetVRayMaterialsRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
SaveVRayMaterialToFileRequest
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
bool success_status = 1;
|
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
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
LuminanceCD:
Uses the Illuminance of the rendered frame in lux.IlluminanceLX:
Uses the Luminance of the rendered frame in candelas.
LightingAnalysisScale
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Linear:
The colors are mapped in linear scale.Logarithmic:
The colors are mapped in logarithmic scale.
LightingAnalysisDisplay
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Widescreen:
16:9 - WidescreenScreen:
8:5 - ScreenSquare:
1:1 - SquarePicture:
4:3 - PictureLandscape:
5:4 - LandscapePortrait:
4:5 - PortraitCropRegion:
The default Aspect Ratio, which allows for rendering the exact boundary of Revit’s Crop Region.Custom:
Allows manual input of the proportions of the image.
VRayResolutionDPIType
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
UnusedVRayResolutionDPIType: NEVER USE THIS VALUE. IT WAS INTRODUCED DUE TO PROTO SYNTAX LIMITATIONS.
DPI75:
75 dpiDPI96:
96 dpiDPI150:
150 dpiDPI300:
300 dpiDPI600:
600 dpi
VRayResolutionPrinterUnit
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
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;
|
Full:
Full light evaluation.Adaptive:
Optimizes the sampling of lights in scenes with many lights.
VRayCameraMode
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Standard = 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;
|
UnusedVRayCameraStereoLayout:
NEVER USE THIS VALUE. IT WAS INTRODUCED DUE TO PROTO SYNTAX LIMITATIONS.SideBySide:
Stereoscopic images are rendered Side-by-side.TopBottom:
Stereoscopic images are rendered Top-bottom.
VRayCameraFocusSource
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
FixedDistance = 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.
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 Group\V-Ray for Revit 20XX\config.json |
Highlight | ||
---|---|---|
| ||
|
Here is how the
Highlight | ||
---|---|---|
| ||
|
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
"apiServers": [ { "PID": 22920, }, "PID": 14792, } ] |
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:
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 | ||
---|---|---|
| ||
|
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 |
Highlight | ||
---|---|---|
| ||
|
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
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 | ||
---|---|---|
| ||
|
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
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 | ||
---|---|---|
| ||
|
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Set bool property
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Get all V-Ray Material Names
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Save V-Ray Material to File
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 | ||
---|---|---|
| ||
|
Highlight | ||
---|---|---|
| ||
|
Listen for project changed
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.
Section | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|