Reputation: 1
We are facing a problem when trying to modify object transparencies via API.
Please see our code below.
The issue we are having, is in a certain model, objects are set to 100% transparency, even though in the code we are setting 50%. It is only affecting certain objects in the model.
Any ideas what could be causing this?
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Application = Autodesk.Navisworks.Api.Application;
namespace NavisworksTransparencyModifier
{
[PluginAttribute("Trasnparency", //Plugin name
"ADSK", //4 character Developer ID or GUID
ToolTip = "Transparency modifier",//The tooltip for the item in the ribbon
DisplayName = "Transparency modifier plugin")]
public class TransparencyModifier : AddInPlugin
{
public override int Execute(params string[] parameters)
{
Document doc = Application.ActiveDocument;
List<ModelItem> list = doc.CurrentSelection.SelectedItems.ToList();
if (list != null)
{
//Application.ActiveDocument.Models.ResetAllPermanentMaterials();
Application.ActiveDocument.Models.OverridePermanentTransparency(list,50);
}
else
{
// Handle case when no object is selected
Console.WriteLine("Please select an object first.");
}
return 0;
}
}
}`
Upvotes: 0
Views: 55
Reputation: 51
Please make sure the value is between 0 and 1. If you wish to set the transparency to 50%, please use 0.5.
Upvotes: 0