public override FScheme.Value Evaluate(FSharpList <FScheme.Value> args)
        {
            if (SelectedIndex < 0)
            {
                throw new Exception("Please select a nurbsCurve node.");
            }

            var node_name = Items[SelectedIndex].Name;

            Point3DCollection controlVertices;
            List <double>     weights, knots;
            int  degree;
            bool closed, rational;

            DynamoMaya.Contract.IService s = MayaCommunication.openChannelToMaya();
            s.receiveCurveFromMaya(node_name, out controlVertices, out weights, out knots, out degree, out closed, out rational);
            MayaCommunication.closeChannelToMaya(s);

            List <XYZ> controlPoints = new List <XYZ>();

            foreach (Point3D cv in controlVertices)
            {
                controlPoints.Add(new XYZ(cv.X, cv.Y, cv.Z));
            }

            NurbSpline ns = NurbSpline.Create(controlPoints, weights, knots, degree, closed, true);

            return(FScheme.Value.NewContainer(ns));
        }
        public override FScheme.Value Evaluate(FSharpList <FScheme.Value> args)
        {
            if (SelectedIndex < 0)
            {
                throw new Exception("Please select a mesh node.");
            }

            var node_name = Items[SelectedIndex].Name;

            //             if (InPorts[0].IsConnected)
            //             {
            //                 // send the to the connected node
            //                 return FScheme.Value.NewString(node_name);
            //             }

            var result = FSharpList <FScheme.Value> .Empty;

            if (OutPorts[0].IsConnected)
            {
                // get the data from the connected node
                DynamoMaya.Contract.IService s        = MayaCommunication.openChannelToMaya();
                Point3DCollection            vertices = s.receiveVertexPositionsFromMaya(node_name);

                foreach (Point3D v in vertices)
                {
                    XYZ pt = new XYZ(v.X, v.Y, v.Z);
                    result = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewContainer(pt), result);
                }

                MayaCommunication.closeChannelToMaya(s);
            }

            return(FScheme.Value.NewList(ListModule.Reverse(result)));
        }
        public override FScheme.Value Evaluate(FSharpList <FScheme.Value> args)
        {
            if (SelectedIndex < 0)
            {
                throw new Exception("Please select a nurbsCurve node.");
            }


            var node_name = Items[SelectedIndex].Name;
            var curve     = (NurbSpline)((FScheme.Value.Container)args[0]).Item;

            Point3DCollection controlPoints = new Point3DCollection();

            foreach (XYZ cpt in curve.CtrlPoints)
            {
                controlPoints.Add(new Point3D(cpt.X, cpt.Y, cpt.Z));
            }

            List <double> knots = new List <double>();

            foreach (double d in curve.Knots)
            {
                knots.Add(d);
            }

            MFnNurbsCurveForm form = curve.isClosed ? MFnNurbsCurveForm.kClosed : MFnNurbsCurveForm.kOpen;

            DynamoMaya.Contract.IService s = MayaCommunication.openChannelToMaya();
            s.sendCurveToMaya(node_name, controlPoints, knots, curve.Degree, form);

            MayaCommunication.closeChannelToMaya(s);

            return(FScheme.Value.NewDummy(node_name));
        }
        public override void PopulateItems()
        {
            Items.Clear();
            List <string> lMayaNurbsCurves = new List <string>();

            try
            {
                DynamoMaya.Contract.IService s = MayaCommunication.openChannelToMaya();
                lMayaNurbsCurves = s.getMayaNodesByType(MFnType.kNurbsCurve);
                MayaCommunication.closeChannelToMaya(s);
            }
            finally
            {
                foreach (string c in lMayaNurbsCurves)
                {
                    Items.Add(new DynamoDropDownItem(c, new object()));
                }
            }
        }
 public static void closeChannelToMaya(DynamoMaya.Contract.IService s)
 {
     (s as ICommunicationObject).Close();
 }