Developer: FlamingoScript
Summary: Demonstrates how to get a the Flamingo nXt material list from the current document.
I am trying to figure out how to get a list of Flamingo nXt materials from the current document. What can I do?
The following are examples of how to extract a list of Flamingo nXt materials from the Flamingo material table in the active document.
RhinoScript
Option Explicit Call Main() Sub Main() Dim objPlugIn, materials, i, count, material On Error Resume Next Set objPlugIn = Rhino.GetPluginObject("8008880f-8d13-4b2d-92b0-727e12878a4c") If Err Then MsgBox Err.Description Exit Sub End If materials = objPlugIn.GetMaterials() If IsNull(materials) Then Rhino.Print("Error getting Flamingo nXt material list") Else count = UBound(materials) Rhino.Print("==============================================================================") Rhino.Print("Flamingo nXt Material List") Rhino.Print("------------------------------------------------------------------------------") If count < 0 Then Rhino.Print("No Flamingo materials in the current document") End If For i = 0 to count Set material = materials(i) If IsObject(material) Then Rhino.Print("Material " & (i + 1) & ": ID: " & material.Id & " Name: " & material.Name) End If Next End If Set material = Nothing Set objPlugIn = Nothing End Sub
Python
import clr # Load the Flamingo nXt SDK DLL clr.AddReference("FlamingoNXtSDK") import FlamingoNXtSDK # Get the Flamingo nXt plug-in's SDK implimentaion, this will force the # plug-in to load if it is not currently loaded flSDK = FlamingoNXtSDK.SDK.FlamingoSDK def ListMaterials(): materials = flSDK.GetMaterials() if materials: print "Flamingo nXt materials" i = 0 for material in materials: print "\t", i + 1, ": \"", material.Name, "\", ", material.Id i += 1; else: print "No Flamingo nXt materials in the current model" if __name__=="__main__": ListMaterials()
C#
using System; using Rhino; using Rhino.DocObjects; using Rhino.Input; using Rhino.Commands; using FlamingoNXtSDK; partial class Examples { public static Result GetMaterials(RhinoDoc doc, Rhino.Commands.RunMode mode) { SDK sdk = SDK.FlamingoSDK; if (null == sdk) return Rhino.Commands.Result.Failure; FlamingoNXtSDK.Material[] materials = sdk.GetMaterials(); if (null == materials || materials.Length < 1) RhinoApp.WriteLine("No Flamingo materials found in the current model"); else for (int i = 0; i < materials.Length; i++) { FlamingoNXtSDK.Material material = materials[i]; RhinoApp.WriteLine("Material " + (i + 1) + ": ID: " + material.Id + " Name: " + material.Name); } return Result.Success; } }