I have been exploring the C# plugin examples for Maya 2014. Now I am looking at the example in the “wpfexamples” folder called “DAGExplorer”. When I run the command, the window pops up fine; but when I click the “Search DAG” button, I get an error like the following:
Search Condition is invalid:
pk0qoeo1.0.cs(20,82) : error CS1594: Delegate 'Script.QueryFunc' has some invalid arguments
pk0qoeo1.0.cs(20,91) : error CS1503: Argument 1: cannot convert from 'Autodesk.Maya.OpenMaya.MItDag' to 'Autodesk.Maya.OpenMaya.MDagPath'
pk0qoeo1.0.cs(22,48) : error CS0266: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<Autodesk.Maya.OpenMaya.MItDag>' to 'System.Collections.Generic.IEnumerable<Autodesk.Maya.OpenMaya.MDagPath>'. An explicit conversion exists (are you missing a cast?)
Here is the code it is having a problem with:
string MyScript = @"using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Maya.Runtime;
using Autodesk.Maya.OpenMaya;
using Autodesk.Maya;
public class Script
{
delegate bool QueryFunc(MDagPath dp);
public System.Collections.Generic.IEnumerable<MDagPath> Main()
{
var dag = new MCDag();
QueryFunc myLambda = (dagpath) => " + textBox1.Text.Trim() + @";
var elements = from dagpath in dag where myLambda(dagpath) select dagpath; // Here it doesn't like "myLambda(dagpath)"
return elements; // Here it doesn't like "elements"
}
}";
(This code is a string that gets executed later. When it is executed, the error appears.) Does anyone know what the problem is? I am not really familiar with this LINQ query syntax, so I am not sure what the “from-where-select” line is returning. Also, I am not familiar with the MCDag class.