示例#1
0
 public PortData(string nickName, string tip, Type portType, FScheme.Value defaultValue=null)
 {
     NickName = nickName;
     ToolTipString = tip;
     PortType = portType;
     DefaultValue = defaultValue;
 }
示例#2
0
 //Returns an FScheme Expression which wraps the given ExternFunc, so that it
 //can be called by FScheme.
 public static Expression MakeFunction(FScheme.ExternFunc func)
 {
     //return Expression.NewFunction(
      //   FuncConvert.ToFSharpFunc(
      //      delegate(FSharpFunc<Expression, Expression> c)
      //      {
      //         return FuncConvert.ToFSharpFunc(
      //            delegate(FSharpList<Expression> args)
      //            {
      //               return c.Invoke(func(args));
      //            }
      //         );
      //      }
      //   )
      //);
      return FScheme.makeExternFunc(func);
 }
示例#3
0
 internal static dynamic convertFromValue(FScheme.Value exp)
 {
     if (exp.IsList)
         return ((FScheme.Value.List)exp).Item.Select(x => convertFromValue(x)).ToList();
     else if (exp.IsNumber)
         return ((FScheme.Value.Number)exp).Item;
     else if (exp.IsString)
         return ((FScheme.Value.String)exp).Item;
     else if (exp.IsContainer)
         return ((FScheme.Value.Container)exp).Item;
     //else if (exp.IsFunction)
     //{
     //   return new Func<IList<dynamic>, dynamic>(
     //      args =>
     //         ((Value.Function)exp).Item
     //            .Invoke(ExecutionEnvironment.IDENT)
     //            .Invoke(Utils.convertSequence(args.Select(
     //               x => (Value)Converters.convertToValue(x)
     //            )))
     //   );
     //}
     //else if (exp.IsSpecial)
     //{
     //   return new Func<IList<dynamic>, dynamic>(
     //      args =>
     //         ((Value.Special)exp).Item
     //            .Invoke(ExecutionEnvironment.IDENT)
     //            .Invoke(
     //}
     //else if (exp.IsCurrent)
     //{
     //   return new Func<dynamic, dynamic>(
     //      ex =>
     //         Converters.convertFromValue(
     //            ((Value.Current)exp).Item.Invoke(Converters.convertToValue(ex))
     //         )
     //   );
     //}
     else
         throw new Exception("Not allowed to pass Functions into a Python Script.");
 }
示例#4
0
 public static Expression MakeMacro(FScheme.ExternMacro macro)
 {
     //return Expression.NewSpecial(
      //   FuncConvert.ToFSharpFunc(
      //     delegate(FSharpFunc<Expression, Expression> c)
      //     {
      //        return FuncConvert.ToFSharpFunc(
      //           delegate(FSharpList<FSharpRef<FSharpMap<string, FSharpRef<Expression>>>> env)
      //           {
      //              return FuncConvert.ToFSharpFunc(
      //                 delegate(FSharpList<Expression> args)
      //                 {
      //                    return c.Invoke(macro(args, env));
      //                 }
      //              );
      //           }
      //        );
      //     }
      //   )
      //);
      return FScheme.makeExternMacro(macro);
 }
示例#5
0
        internal static dynamic convertFromValue(FScheme.Value exp, ObjectOperations invoker)
        {
            if (exp.IsList)
                return ((FScheme.Value.List)exp).Item.Select(x => convertFromValue(x, invoker)).ToList();
            else if (exp.IsNumber)
                return ((FScheme.Value.Number)exp).Item;
            else if (exp.IsString)
                return ((FScheme.Value.String)exp).Item;
            else if (exp.IsContainer)
                return ((FScheme.Value.Container)exp).Item;
            else if (exp.IsFunction)
            {
                var func = ((FScheme.Value.Function)exp).Item;

                PyWrapper wrapped =
                    args =>
                        convertFromValue(
                            func.Invoke(args.Select(a => convertToValue(a, invoker) as FScheme.Value).ToFSharpList()), invoker);

                return wrapped;
            }
            else
                throw new Exception("Not allowed to pass Functions into a Python Script.");
        }
示例#6
0
 public double GetDoubleFromFSchemeValue(FScheme.Value value)
 {
     var doubleWatchVal = 0.0;
     Assert.AreEqual(true, FSchemeInterop.Utils.Convert(value, ref doubleWatchVal));
     return doubleWatchVal;
 }
示例#7
0
 public FSharpList<FScheme.Value> GetListFromFSchemeValue(FScheme.Value value)
 {
     FSharpList<FScheme.Value> listWatchVal = null;
     Assert.AreEqual(true, FSchemeInterop.Utils.Convert(value, ref listWatchVal));
     return listWatchVal;
 }
示例#8
0
        /// <summary>
        /// Returns the objects from a Value type which have associated visualizers 
        /// along with a string tag representing the array index of the value, i.e. [0][5][3]
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Dictionary<string, object> GetDrawableFromValue(List<int> chain, FScheme.Value value)
        {
            //var drawables = new List<object>();
            var drawables = new Dictionary<string, object>();

            if (value == null)
            {
                return drawables;
            }

            var viz = dynSettings.Controller.VisualizationManager;

            if (value.IsList)
            {
                int count = 0;
                foreach (var val_inner in ((FScheme.Value.List)value).Item)
                {
                    var subChain = new List<int>(chain);
                    subChain.Add(count);
                    var innerDrawables = GetDrawableFromValue(subChain, val_inner);
                    innerDrawables.ToList().ForEach(x=>drawables.Add(x.Key, x.Value));

                    count++;
                }
                return drawables;
            }

            var container = value as FScheme.Value.Container;
            if (container == null)
                return drawables;

            var obj = ((FScheme.Value.Container)container).Item;

            if (obj != null)
            {
                var t = obj.GetType();
                var visualizer = viz.Visualizers.FirstOrDefault(x => x.Key == t || x.Key.IsAssignableFrom(t));

                if (visualizer.Value != null)
                {
                    drawables.Add(TagFromList(chain),obj);
                }
            }

            return drawables;
        }
        protected override void Run(IEnumerable<dynNodeModel> topElements, FScheme.Expression runningExpression)
        {
            //If we are not running in debug...
            if (!this.DynamoViewModel.RunInDebug)
            {
                //Do we need manual transaction control?
                bool manualTrans = topElements.Any((DynamoViewModel as DynamoRevitViewModel).CheckManualTransaction.TraverseUntilAny);

                //Can we avoid running everything in the Revit Idle thread?
                bool noIdleThread = manualTrans || !topElements.Any((DynamoViewModel as DynamoRevitViewModel).CheckRequiresTransaction.TraverseUntilAny);

                //If we don't need to be in the idle thread...
                if (noIdleThread)
                {
                    DynamoLogger.Instance.Log("Running expression in evaluation thread...");
                    (DynamoViewModel as DynamoRevitViewModel).TransMode = DynamoRevitViewModel.TransactionMode.Manual; //Manual transaction control
                    this.InIdleThread = false; //Not in idle thread at the moment
                    base.Run(topElements, runningExpression); //Just run the Run Delegate
                }
                else //otherwise...
                {
                    DynamoLogger.Instance.Log("Running expression in Revit's Idle thread...");
                    (DynamoViewModel as DynamoRevitViewModel).TransMode = DynamoRevitViewModel.TransactionMode.Automatic; //Automatic transaction control
                    this.InIdleThread = true; //Now in the idle thread.
                    IdlePromise.ExecuteOnIdle(new Action(
                        () => base.Run(topElements, runningExpression)),
                        false); //Execute the Run Delegate in the Idle thread.
                }
            }
            else //If we are in debug mode...
            {
                (DynamoViewModel as DynamoRevitViewModel).TransMode = DynamoRevitViewModel.TransactionMode.Debug; //Debug transaction control
                this.InIdleThread = true; //Everything will be evaluated in the idle thread.

                //MVVM: no need to invoke through UI
                //Bench.Dispatcher.Invoke(new Action(
                //   () => dynSettings.Controller.DynamoViewModel.Log("Running expression in debug.")
                //));

                dynSettings.Controller.DynamoViewModel.Log("Running expression in debug.");

                //Execute the Run Delegate.
                base.Run(topElements, runningExpression);
            }
        }
示例#10
0
        public static Autodesk.Revit.DB.CurveLoop CurveLoopFromContainer(FScheme.Value.Container curveOrCurveLoop)
        {
            var pathLoopBoxed = curveOrCurveLoop.Item;
            Autodesk.Revit.DB.CurveLoop curveLoop;
            var loop = pathLoopBoxed as Autodesk.Revit.DB.CurveLoop;
            if (loop != null)
            {
                curveLoop = loop;
            }
            else
            {
                curveLoop = new Autodesk.Revit.DB.CurveLoop();
                curveLoop.Append((Autodesk.Revit.DB.Curve)pathLoopBoxed);
            }

            return curveLoop;
        }
示例#11
0
        protected override void Run(IEnumerable<dynNode> topElements, FScheme.Expression runningExpression)
        {
            //If we are not running in debug...
            if (!_debug)
            {
                //Do we need manual transaction control?
                bool manualTrans = topElements.Any(checkManualTransaction.TraverseUntilAny);

                //Can we avoid running everything in the Revit Idle thread?
                bool noIdleThread = manualTrans || !topElements.Any(checkRequiresTransaction.TraverseUntilAny);

                //If we don't need to be in the idle thread...
                if (noIdleThread)
                {
                    this.TransMode = TransactionMode.Manual; //Manual transaction control
                    this.InIdleThread = false; //Not in idle thread at the moment
                    base.Run(topElements, runningExpression); //Just run the Run Delegate
                }
                else //otherwise...
                {
                    this.TransMode = TransactionMode.Automatic; //Automatic transaction control
                    this.InIdleThread = true; //Now in the idle thread.
                    IdlePromise.ExecuteOnIdle(new Action(
                        () => base.Run(topElements, runningExpression)),
                        false); //Execute the Run Delegate in the Idle thread.
                }
            }
            else //If we are in debug mode...
            {
                this.TransMode = TransactionMode.Debug; //Debug transaction control
                this.InIdleThread = true; //Everything will be evaluated in the idle thread.

                Bench.Dispatcher.Invoke(new Action(
                   () => Bench.Log("Running expression in debug.")
                ));

                //Execute the Run Delegate.
                base.Run(topElements, runningExpression);
            }
        }
示例#12
0
        protected virtual void Run(List<NodeModel> topElements, FScheme.Expression runningExpression)
        {
            //Print some stuff if we're in debug mode
            if (DynamoViewModel.RunInDebug)
            {
                if (dynSettings.Controller.UIDispatcher != null)
                {
                    foreach (string exp in topElements.Select(node => node.PrintExpression()))
                        DynamoLogger.Instance.Log("> " + exp);
                }
            }

            try
            {
                //Evaluate the expression
                FScheme.Value expr = FSchemeEnvironment.Evaluate(runningExpression);

                if (dynSettings.Controller.UIDispatcher != null)
                {
                    //Print some more stuff if we're in debug mode
                    if (DynamoViewModel.RunInDebug && expr != null)
                    {
                        DynamoLogger.Instance.Log("Evaluating the expression...");
                        DynamoLogger.Instance.Log(FScheme.print(expr));
                    }
                }
            }
            catch (CancelEvaluationException ex)
            {
                /* Evaluation was cancelled */

                OnRunCancelled(false);
                RunCancelled = false;
                if (ex.Force)
                    runAgain = false;
            }
            catch (Exception ex)
            {
                /* Evaluation failed due to error */

                DynamoLogger.Instance.Log(ex);

                OnRunCancelled(true);
                RunCancelled = true;
                runAgain = false;

                //If we are testing, we need to throw an exception here
                //which will, in turn, throw an Assert.Fail in the
                //Evaluation thread.
                if (Testing)
                    throw new Exception(ex.Message);
            }

            OnEvaluationCompleted(this, EventArgs.Empty);
        }
示例#13
0
文件: Units.cs 项目: Zhengzi/Dynamo
        public static SIUnit UnwrapToSIUnit(FScheme.Value value)
        {
            if (value.IsContainer)
            {
                var measure = ((FScheme.Value.Container)value).Item as SIUnit;
                if (measure != null)
                {
                    return measure;
                }
            }

            throw new Exception("The value was not convertible to a unit of measure.");
        }
示例#14
0
文件: Excel.cs 项目: kscalvin/Dynamo
 public static List<FScheme.Value> ConvertRow(FScheme.Value v)
 {
     if (v.IsString || v.IsNumber)
     {
         return new List<FScheme.Value>() {v};
     }
     else if (v.IsList)
     {
         return ((FScheme.Value.List) v).Item.Select(ConvertAsAtom).ToList();
     }
     else
     {
         return new List<FScheme.Value>() {ConvertAsAtom(v)};
     }
 }
示例#15
0
文件: Excel.cs 项目: kscalvin/Dynamo
        public List<List<FScheme.Value>> ConvertTo2DList(FScheme.Value v)
        {
            if (v.IsList)
            {
                return ((FScheme.Value.List)v).Item.Select(ConvertRow).ToList();
            }

            var list = new List<List<FScheme.Value>>();
            list.Add(ConvertRow(v));
            return list;
        }
示例#16
0
文件: Excel.cs 项目: kscalvin/Dynamo
 public static FScheme.Value ConvertAsAtom(FScheme.Value v)
 {
     if (v == null)
     {
         return FScheme.Value.NewString("");
     }
     else if (v.IsString || v.IsNumber)
     {
         return v;
     }
     else
     {
         return FScheme.Value.NewString(v.ToString());
     }
 }
示例#17
0
        public static string PrintValue(
            FScheme.Value eIn,
            int currentListIndex,
            int maxListIndex,
            int currentDepth,
            int maxDepth,
            int maxStringLength = 20)
        {
            if (eIn == null)
                return "<null>";

            string accString = String.Concat(Enumerable.Repeat("  ", currentDepth));

            if (maxDepth == currentDepth || currentListIndex == maxListIndex)
            {
                accString += "...";
                return accString;
            }

            if (eIn.IsContainer)
            {
                string str = (eIn as FScheme.Value.Container).Item != null
                                 ? (eIn as FScheme.Value.Container).Item.ToString()
                                 : "<empty>";

                accString += str;
            }
            else if (eIn.IsFunction)
                accString += "<function>";
            else if (eIn.IsList)
            {
                accString += "List";

                FSharpList<FScheme.Value> list = (eIn as FScheme.Value.List).Item;

                if (!list.Any())
                    accString += " (empty)";

                // when children will be at maxDepth, just do 1
                if (currentDepth + 1 == maxDepth)
                    maxListIndex = 0;

                // build all elements of sub list
                accString =
                    list.Select((x, i) => new { Element = x, Index = i })
                        .TakeWhile(e => e.Index <= maxListIndex)
                        .Aggregate(
                            accString,
                            (current, e) =>
                            current + "\n"
                            + PrintValue(e.Element, e.Index, maxListIndex, currentDepth + 1, maxDepth, maxStringLength));
            }
            else if (eIn.IsNumber)
            {
                double num = (eIn as FScheme.Value.Number).Item;
                var numFloat = (float)num;
                accString += numFloat.ToString();
            }
            else if (eIn.IsString)
            {
                string str = (eIn as FScheme.Value.String).Item;
                if (str.Length > maxStringLength)
                    str = str.Substring(0, maxStringLength) + "...";

                accString += "\"" + str + "\"";
            }
            else if (eIn.IsSymbol)
                accString += "<" + (eIn as FScheme.Value.Symbol).Item + ">";

            return accString;
        }
示例#18
0
 //Binds symbols of the given string to the given Expression.
 //private void DefineExternal(string name, Expression func)
 //{
 //   this.env.Add(name, func);
 //}
 //Binds symbols of the given string to the given External Function.
 public void DefineExternal(string name, FScheme.ExternFunc func)
 {
     this.DefineSymbol(name, FuncContainer.MakeFunction(func));
 }
示例#19
0
文件: Units.cs 项目: Zhengzi/Dynamo
 public static FScheme.Value ConvertListToHostUnits(FScheme.Value.List value)
 {
     var list = value.Item;
     return FScheme.Value.NewList(FSchemeInterop.Utils.SequenceToFSharpList(list.Select(UnwrapToDoubleWithHostUnitConversion)));
 }
示例#20
0
 public void Log(FScheme.Expression expression)
 {
     Log(FScheme.printExpression("\t", expression));
 }
示例#21
0
文件: Units.cs 项目: Zhengzi/Dynamo
        /// <summary>
        /// Unwrap an FScheme value containing a number or a unit to a double.
        /// If the value contains a unit object, convert the internal value of the
        /// unit object to the units required by the host application as specified
        /// in the preference settings. If the value contains a number, do not 
        /// apply a conversion.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static FScheme.Value UnwrapToDoubleWithHostUnitConversion(FScheme.Value value)
        {
            if (value.IsList)
            {
                //recursively convert items in list
                return ConvertListToHostUnits((FScheme.Value.List)value);
            }

            if (value.IsContainer)
            {
                var unit = ((FScheme.Value.Container)value).Item as SIUnit;
                if (unit != null)
                {
                    return FScheme.Value.NewNumber(unit.ConvertToHostUnits());
                }
            }

            return value;
        }
示例#22
0
        /// <summary>
        /// Utility method to get the Revit geometry associated with nodes.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private static List<GeometryObject> RevitGeometryFromNodes(FScheme.Value value)
        {
            var geoms = new List<GeometryObject>();

            if (value == null)
            {
                return geoms;
            }

            if (value.IsList)
            {
                foreach (var val_inner in ((FScheme.Value.List)value).Item)
                {
                    geoms.AddRange(RevitGeometryFromNodes(val_inner));
                }
                return geoms;
            }

            var container = value as Value.Container;
            if (container == null)
                return geoms;

            var geom = ((FScheme.Value.Container)value).Item as GeometryObject;
            if (geom != null && !(geom is Face))
                geoms.Add(geom);

            var ps = ((FScheme.Value.Container) value).Item as ParticleSystem;
            if (ps != null)
            {
                geoms.AddRange(ps.Springs.Select(spring => Line.CreateBound(spring.getOneEnd().getPosition(), spring.getTheOtherEnd().getPosition())).Cast<GeometryObject>());
            }

            var cl = ((FScheme.Value.Container) value).Item as Autodesk.Revit.DB.CurveLoop;
            if (cl != null)
            {
                geoms.AddRange(cl);
            }

            //draw xyzs as Point objects
            var pt = ((FScheme.Value.Container)value).Item as XYZ;
            if (pt != null)
            {
                Type pointType = typeof(Point);
                MethodInfo[] pointTypeMethods = pointType.GetMethods(BindingFlags.Static | BindingFlags.Public);
                var method = pointTypeMethods.FirstOrDefault(x => x.Name == "CreatePoint");

                if (method != null)
                {
                    var args = new object[3];
                    args[0] = pt.X;
                    args[1] = pt.Y;
                    args[2] = pt.Z;
                    geoms.Add((Point)method.Invoke(null, args));
                }
            }

            return geoms;
        }
示例#23
0
        protected override bool AcceptsListOfLists(FScheme.Value value)
        {
            if (Utils.IsListOfListsOfLists(value))
                return false;

            FSharpList<FScheme.Value> vals = ((FScheme.Value.List)value).Item;
            if (!vals.Any() || !(vals[0] is FScheme.Value.List))
                return true;
            FSharpList<FScheme.Value> firstListInList = ((FScheme.Value.List)vals[0]).Item;
            if (!firstListInList.Any() || !(firstListInList[0] is FScheme.Value.Container))
                return true;
            var var1 = ((FScheme.Value.Container)firstListInList[0]).Item;
            if (var1 is ModelCurveArray)
                return false;

            return true;
        }
示例#24
0
 public virtual bool acceptsListOfLists(FScheme.Value value)
 {
     return false;
 }
示例#25
0
 void DrawPython(FScheme.Value val, string id)
 {
     //DrawContainers(val, id);
 }
示例#26
0
        protected internal virtual void Run(bool RunInDebug, IEnumerable<dynNodeModel> topElements, FScheme.Expression runningExpression)
        {
            //Print some stuff if we're in debug mode
            if (RunInDebug)
            {
            // NOPE
                //if (dynSettings.Bench != null)
                //{
                //    //string exp = FScheme.print(runningExpression);
                //    //dynSettings.Bench.Dispatcher.Invoke(new Action(
                //    //                            delegate
                //    //                            {
                //    //                                foreach (dynNodeModel node in topElements)
                //    //                                {
                //    //                                    string exp = node.PrintExpression();
                //    //                                    dynSettings.Controller.DynamoViewModel.Log("> " + exp);
                //    //                                }
                //    //                            }
                //    //                            ));
                //}
            }

            try
            {
                //Evaluate the expression
                FScheme.Value expr = this.FSchemeEnv.Evaluate(runningExpression);

                if (dynSettings.Bench != null)
                {
                    //Print some more stuff if we're in debug mode
                    if (RunInDebug && expr != null)
                    {
            // NOPE
                        //dynSettings.Bench.Dispatcher.Invoke(new Action(
                        //                            () =>
                        //                            dynSettings.Controller.DynamoViewModel.Log(FScheme.print(expr))
                        //                            ));
                    }
                }
            }
            catch (CancelEvaluationException ex)
            {
                /* Evaluation was cancelled */

                OnRunCancelled(false);
                //this.RunCancelled = false;
                if (ex.Force)
                    runAgain = false;
            }
            catch (Exception ex)
            {
                /* Evaluation failed due to error */
            // NOPE
                //if (dynSettings.Bench != null)
                //{
                //    //Print unhandled exception
                //    if (ex.Message.Length > 0)
                //    {
                //        dynSettings.Bench.Dispatcher.Invoke(new Action(
                //                                    delegate { dynSettings.Controller.DynamoViewModel.Log(ex); }
                //                                    ));
                //    }
                //}

                OnRunCancelled(true);
                RunCancelled = true;
                runAgain = false;
            }

            OnEvaluationCompleted();
        }
示例#27
0
        protected override void Run(List<NodeModel> topElements, FScheme.Expression runningExpression)
        {
            var model = (DynamoRevitViewModel)DynamoViewModel;

            //If we are not running in debug...
            if (!DynamoViewModel.RunInDebug)
            {
                //Do we need manual transaction control?
                bool manualTrans = topElements.Any(CheckManualTransaction.TraverseUntilAny);

                //Can we avoid running everything in the Revit Idle thread?
                bool noIdleThread = manualTrans ||
                    !topElements.Any(CheckRequiresTransaction.TraverseUntilAny);

                //If we don't need to be in the idle thread...
                if (noIdleThread || IsTestMode)
                {
                    //DynamoLogger.Instance.Log("Running expression in evaluation thread...");
                    TransMode = TransactionMode.Manual; //Manual transaction control

                    if (IsTestMode)
                        TransMode = TransactionMode.Automatic;

                    InIdleThread = false; //Not in idle thread at the moment
                    base.Run(topElements, runningExpression); //Just run the Run Delegate
                }
                else //otherwise...
                {
                    //DynamoLogger.Instance.Log("Running expression in Revit's Idle thread...");
                    TransMode = TransactionMode.Automatic; //Automatic transaction control

                    Debug.WriteLine("Adding a run to the idle stack.");
                    InIdleThread = true; //Now in the idle thread.
                    IdlePromise.ExecuteOnIdle(
                        () => base.Run(topElements, runningExpression),
                        false); //Execute the Run Delegate in the Idle thread.

                }
            }
            else //If we are in debug mode...
            {
                TransMode = TransactionMode.Debug; //Debug transaction control
                InIdleThread = true; //Everything will be evaluated in the idle thread.

                DynamoLogger.Instance.Log("Running expression in debug.");

                //Execute the Run Delegate.
                base.Run(topElements, runningExpression);
            }
        }
示例#28
0
 private static FScheme.Value setParam(FamilySymbol fi, Definition paramDef, FScheme.Value valueExpr)
 {
     var p = fi.get_Parameter(paramDef);
     if (p != null)
     {
         return _setParam(fi, p, valueExpr);
     }
     throw new Exception("Parameter \"" + paramDef.Name + "\" was not found!");
 }
示例#29
0
 /// <summary>
 /// Log an expression
 /// </summary>
 /// <param name="expression"></param>
 public void Log(FScheme.Expression expression)
 {
     Instance.Log(FScheme.printExpression("\t", expression), LogLevel.Console);
 }
示例#30
0
 private static FScheme.Value _setParam(FamilySymbol ft, Parameter p, FScheme.Value valueExpr)
 {
     if (p.StorageType == StorageType.Double)
     {
         p.Set(((FScheme.Value.Number)valueExpr).Item);
     }
     else if (p.StorageType == StorageType.Integer)
     {
         p.Set((int)((FScheme.Value.Number)valueExpr).Item);
     }
     else if (p.StorageType == StorageType.String)
     {
         p.Set(((FScheme.Value.String)valueExpr).Item);
     }
     else if (valueExpr.IsNumber)
     {
         p.Set(new ElementId((int)(valueExpr as FScheme.Value.Number).Item));
     }
     else
     {
         p.Set((ElementId)((FScheme.Value.Container)valueExpr).Item);
     }
     return FScheme.Value.NewContainer(ft);
 }