ForgeViewer.NET
1.0.0
dotnet add package ForgeViewer.NET --version 1.0.0
NuGet\Install-Package ForgeViewer.NET -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ForgeViewer.NET" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ForgeViewer.NET --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ForgeViewer.NET, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ForgeViewer.NET as a Cake Addin
#addin nuget:?package=ForgeViewer.NET&version=1.0.0
// Install ForgeViewer.NET as a Cake Tool
#tool nuget:?package=ForgeViewer.NET&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
About ForgeViewer.NET
- Bring the Forge Viewer JS library to c# using JSInterop and .Net 5
- This library is under construction and is for now closer to a POC than production.
- You will need a Forge Application
- There is a live demo here
How to install
Add ForgeViewer.NET package :
PM> Install-Package ForgeViewer.NET
Add Forge Viewer dependencies :
• Blazor Server
In Pages\_Host.cshtml
, add the following code :
<head>
...
<link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.css" type="text/css"/>
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.js"></script>
</head>
In wwwroot\css\site.css
, add the following code :
.content {
...
height: calc(100% - 120px);
}
• Blazor Web Assembly
In wwwroot\index.html
, add the following code :
<head>
...
<link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.css" type="text/css"/>
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.js"></script>
</head>
In wwwroot\css\app.css
, add the following code :
.content {
...
height: calc(100% - 120px);
}
Example
- General implementation to display a model
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
//Instantiate on first rende the viewing class
Viewing = Viewing.Create(ServiceProvider);
//get options such as Env, Api, GetAccessToken
var opt = GetOptions();
//Initialize the Viewing class
await Viewing.Initializer(opt, OnInit);
}
await base.OnAfterRenderAsync(firstRender);
}
private async Task OnInit()
{
GuiViewer3d = GuiViewer3d.Create(ServiceProvider);
//get the element to hold the viewer
await GuiViewer3d.Initializer("id");
//subscribe to events
await GuiViewer3d.AddEventListener(ViewerEvent.ExtensionLoadedEvent, OnExtLoaded);
await GuiViewer3d.AddEventListener(ViewerEvent.SelectionChangedEvent, OnSelectionChanged);
//Start the viewer
await GuiViewer3d.Start();
//load the provided document
await Document.Load(ServiceProvider, Urn, OnSuccess);
}
private async Task OnSuccess(Document document)
{
var bubbleNode = await document.GetRoot();
var getDefaultGeometry = await bubbleNode.GetDefaultGeometry();
var model = await GuiViewer3d.LoadDocumentNode(document, getDefaultGeometry, null);
}
- Sample to unload an extension
private async Task OnExtLoaded(object? arg)
{
var ext = new[] {"Autodesk.Explode"};
//All event response has a corresponding class
if (arg is not ExtensionResponse extensionResponse || !ext.Contains(extensionResponse.ExtensionId))
return;
await GuiViewer3d.GetExtensions(extensionResponse.ExtensionId, Callback);
}
private async Task Callback(Extension extension)
{
await extension.Unload();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Microsoft.AspNetCore.Components.Web (>= 5.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 409 | 12/18/2020 |