public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor)
        {
            this.functionDescriptor = functionDescriptor;

            var displayName = functionDescriptor.UserFriendlyName;
            if (functionDescriptor.IsOverloaded)
                displayName += "(" + string.Join(", ", functionDescriptor.Parameters) + ")";

            Name = displayName;
            UserFriendlyName = functionDescriptor.UserFriendlyName;
            FullCategoryName = functionDescriptor.Category;
            Description = functionDescriptor.Description;
            Assembly = functionDescriptor.Assembly;

            ElementType = ElementTypes.ZeroTouch;

            if (functionDescriptor.IsBuiltIn)
                ElementType |= ElementTypes.BuiltIn;
            // Assembly, that is located in package directory, considered as part of package.
            if (Assembly.StartsWith(functionDescriptor.PathManager.PackagesDirectory))
                ElementType |= ElementTypes.Packaged;

            inputParameters = new List<Tuple<string, string>>(functionDescriptor.InputParameters);
            outputParameters = new List<string>() { functionDescriptor.ReturnType };

            foreach (var tag in functionDescriptor.GetSearchTags())
                SearchKeywords.Add(tag);

            iconName = GetIconName();
        }
        public static FScheme.Expression CompileFunction( FunctionDefinition definition )
        {
            IEnumerable<string> ins = new List<string>();
            IEnumerable<string> outs = new List<string>();

            return CompileFunction(definition, ref ins, ref outs);
        }
Exemple #3
0
        internal override IEnumerable<AssociativeNode> BuildAst(List<AssociativeNode> inputAstNodes, CompilationContext context)
        {
            var rhs = AstFactory.BuildStringNode(Value);
            var assignment = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs);

            return new[] { assignment };
        }
Exemple #4
0
        protected AssociativeNode CreateOutputAST(
            AssociativeNode codeInputNode, List<AssociativeNode> inputAstNodes,
            List<Tuple<string, AssociativeNode>> additionalBindings)
        {
            var names =
                additionalBindings.Select(
                    x => AstFactory.BuildStringNode(x.Item1) as AssociativeNode).ToList();
            names.Add(AstFactory.BuildStringNode("IN"));

            var vals = additionalBindings.Select(x => x.Item2).ToList();
            vals.Add(AstFactory.BuildExprList(inputAstNodes));

            Func<string, IList, IList, object> backendMethod =
                IronPythonEvaluator.EvaluateIronPythonScript;

            return AstFactory.BuildAssignment(
                GetAstIdentifierForOutputIndex(0),
                AstFactory.BuildFunctionCall(
                    backendMethod,
                    new List<AssociativeNode>
                    {
                        codeInputNode,
                        AstFactory.BuildExprList(names),
                        AstFactory.BuildExprList(vals)
                    }));
        }
Exemple #5
0
        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            AssociativeNode rhs = null;

            if (IsPartiallyApplied)
            {
                var connectedInputs = new List<AssociativeNode>();
                var functionNode = new IdentifierNode(functionName);
                var paramNumNode = new IntNode(1);
                var positionNode = AstFactory.BuildExprList(connectedInputs);
                var arguments = AstFactory.BuildExprList(inputAstNodes);
                var inputParams = new List<AssociativeNode>
                {
                    functionNode,
                    paramNumNode,
                    positionNode,
                    arguments,
                    AstFactory.BuildBooleanNode(true)
                };

                rhs = AstFactory.BuildFunctionCall("_SingleFunctionObject", inputParams);
            }
            else
            {
                rhs = AstFactory.BuildFunctionCall(functionName, inputAstNodes);
            }

            return new[]
            {
               AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs)
            };
        }
Exemple #6
0
        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            var worksheet = (Microsoft.Office.Interop.Excel.Worksheet)((FScheme.Value.Container)args[0]).Item;

            Microsoft.Office.Interop.Excel.Range range = worksheet.UsedRange;

            int rows = range.Rows.Count;
            int cols = range.Columns.Count;

            var rowData = new List<FScheme.Value>();

            for (int r = 1; r <= rows; r++)
            {
                var row = new List<FScheme.Value>();

                for (int c = 1; c <= cols; c++)
                {
                    row.Add(FScheme.Value.NewContainer(range.Cells[r, c].Value2));
                }

                rowData.Add(FScheme.Value.NewList(Utils.SequenceToFSharpList(row)));
            }

            return FScheme.Value.NewList(Utils.SequenceToFSharpList(rowData));
        }
        public override void PopulateItems()
        {
            // The Items collection contains the elements
            // that appear in the list. For this example, we
            // clear the list before adding new items, but you
            // can also use the PopulateItems method to add items
            // to the list.

            Items.Clear();

            // Create a number of DynamoDropDownItem objects
            // to store the items that we want to appear in our list.

            var newItems = new List<DynamoDropDownItem>()
            {
                new DynamoDropDownItem("Tywin", 0),
                new DynamoDropDownItem("Cersei", 1),
                new DynamoDropDownItem("Hodor",2)
            };

            Items.AddRange(newItems);

            // Set the selected index to something other
            // than -1, the default, so that your list
            // has a pre-selection.

            SelectedIndex = 0;
        }
Exemple #8
0
            /// <summary>
            /// Get all of the dependencies from a workspace
            /// </summary>
            /// <param name="workspace">The workspace to read the dependencies from</param>
            /// <param name="customNodeManager">A custom node manager to look up dependencies</param>
            /// <returns>A WorkspaceDependencies object containing the workspace and its CustomNodeWorkspaceModel dependencies</returns>
            public static WorkspaceDependencies Collect(HomeWorkspaceModel workspace, ICustomNodeManager customNodeManager)
            {
                if (workspace == null) throw new ArgumentNullException("workspace");
                if (customNodeManager == null) throw new ArgumentNullException("customNodeManager");

                // collect all dependencies
                var dependencies = new HashSet<CustomNodeDefinition>();
                foreach (var node in workspace.Nodes.OfType<Function>())
                {
                    dependencies.Add(node.Definition);
                    foreach (var dep in node.Definition.Dependencies)
                    {
                        dependencies.Add(dep);
                    }
                }

                var customNodeWorkspaces = new List<ICustomNodeWorkspaceModel>();
                foreach (var dependency in dependencies)
                {
                    ICustomNodeWorkspaceModel customNodeWs;
                    var workspaceExists = customNodeManager.TryGetFunctionWorkspace(dependency.FunctionId, false, out customNodeWs);

                    if (!workspaceExists)
                    {
                        throw new InvalidOperationException(String.Format(Resources.CustomNodeDefinitionNotFoundErrorMessage, dependency.FunctionName));
                    }

                    if (!customNodeWorkspaces.Contains(customNodeWs))
                    {
                        customNodeWorkspaces.Add(customNodeWs);
                    }
                }

                return new WorkspaceDependencies(workspace, customNodeWorkspaces);
            }
Exemple #9
0
        /// <summary>
        /// create a new presetsState, this will serialize all the referenced nodes by calling their serialize method, 
        /// the resulting XML elements will be used to save this state when the presetModel is saved on workspace save
        /// </summary>
        /// <param name="name">name for the state, must not be null </param>
        /// <param name="description">description of the state, can be null</param>
        /// <param name="inputsToSave">set of nodeModels, must not be null</param>
        /// <param name="id">an id GUID, can be empty GUID</param>
        public PresetModel(string name, string description, IEnumerable<NodeModel> inputsToSave):base()
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            if (inputsToSave == null || inputsToSave.Count() < 1)
            {
                throw new ArgumentNullException("inputsToSave");
            } 

           
            Name = name;
            Description = description;
            nodes = inputsToSave.ToList();

           
            var tempdoc = new XmlDocument();
            serializedNodes = new List<XmlElement>();
            foreach (var node in Nodes)
            {
                serializedNodes.Add(node.Serialize(tempdoc, SaveContext.Preset));
            }
        }
        public static Dictionary<string, object> DemandToCapacityMultiple(List<double> DCRs)
        {
            double DCR_min = 0.0;
            double DCR_max = 0.0;
            //if (DCRs is List<double>)
            //{
                List<double> DCRflat = DCRs as List<double>;
                DCR_min = DCRflat.Where(dc => dc > 0).Min();
                DCR_max = DCRflat.Where(dc => dc > 0).Max();

            //}
            //else if (DCRs is List<List<double>>)
            //{
            //    List<List<double>> DCR2d = DCRs as List<List<double>>;
            //    DCR_min = DCR2d.SelectMany(i => i).Where(dc => dc >= 0).Min();
            //}



            return new Dictionary<string, object>
            {
                { "DCR_min", DCR_min },
                { "DCR_max", DCR_max } 
            };
        }
Exemple #11
0
        public override Value Evaluate(FSharpList<Value> args)
        {
            CurveLoop firstLoop = (CurveLoop)((Value.Container)args[0]).Item;
            CurveLoop secondLoop = (CurveLoop)((Value.Container)args[1]).Item;

            List<VertexPair> vertPairs = null;

            if (dynRevitSettings.Revit.Application.VersionName.Contains("2013"))
            {
                vertPairs = new List<VertexPair>();

                int i = 0;
                int nCurves1 = firstLoop.Count();
                int nCurves2 = secondLoop.Count();
                for (; i < nCurves1 && i < nCurves2; i++)
                {
                    vertPairs.Add(new VertexPair(i, i));
                }
            }

            var result = GeometryCreationUtilities.CreateBlendGeometry(firstLoop, secondLoop, vertPairs);

            solids.Add(result);

            return Value.NewContainer(result);
        }
Exemple #12
0
        public override IEnumerable<AssociativeNode> BuildOutputAst(
            List<AssociativeNode> inputAstNodes)
        {
            if (IsPartiallyApplied)
            {
                return new[]
                {
                    AstFactory.BuildAssignment(
                        GetAstIdentifierForOutputIndex(0),
                        AstFactory.BuildFunctionObject(
                            new IdentifierListNode
                            {
                                LeftNode = AstFactory.BuildIdentifier("DataBridge"),
                                RightNode = AstFactory.BuildIdentifier("BridgeData")
                            },
                            2,
                            new[] { 0 },
                            new List<AssociativeNode>
                            {
                                AstFactory.BuildStringNode(GUID.ToString()),
                                AstFactory.BuildNullNode()
                            }))
                };
            }

            var resultAst = new[]
            {
                AstFactory.BuildAssignment(
                    AstFactory.BuildIdentifier(AstIdentifierBase + "_dummy"),
                    DataBridge.GenerateBridgeDataAst(GUID.ToString(), inputAstNodes[0])),
                AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), inputAstNodes[0])
            };

            return resultAst;
        }
 public PackageManagerClientViewModel(DynamoViewModel dynamoViewModel, PackageManagerClient packageManagerClient )
 {
     this.dynamoViewModel = dynamoViewModel;
     this.packageManagerClient = packageManagerClient;
     this.CachedPackageList = new List<PackageManagerSearchElement>();
     this.packageManagerClient.RequestAuthentication +=
         dynamoViewModel.OnRequestAuthentication;
 }
Exemple #14
0
        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            RequiresRecalc = true;

            var functionCall = AstFactory.BuildFunctionCall(new Func<string, string>(Web.WebRequestByUrl), inputAstNodes);

            return new[] {AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall)};
        }
Exemple #15
0
 //this overload is used for loading
 private PresetModel(string name, string description, List<NodeModel> nodes, List<XmlElement> serializedNodes, Guid id)
 {
     Name = name;
     Description = description;
     this.nodes = nodes;
     this.serializedNodes = serializedNodes;
     GUID = id;
 }
        public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor)
        {
            this.functionDescriptor = functionDescriptor;

            var displayName = functionDescriptor.UserFriendlyName;
            if (functionDescriptor.IsOverloaded)
                displayName += "(" + string.Join(", ", functionDescriptor.Parameters) + ")";

            Name = displayName;
            UserFriendlyName = functionDescriptor.UserFriendlyName;
            FullCategoryName = functionDescriptor.Category;
            Description = functionDescriptor.Description;
            Assembly = functionDescriptor.Assembly;

            ElementType = ElementTypes.ZeroTouch;

            if (functionDescriptor.IsBuiltIn)
                ElementType |= ElementTypes.BuiltIn;

            // Assembly, that is located in package directory, considered as part of package.
            var packageDirectories = functionDescriptor.PathManager.PackagesDirectories;
            if (packageDirectories.Any(directory => Assembly.StartsWith(directory)))
                ElementType |= ElementTypes.Packaged;

            inputParameters = new List<Tuple<string, string>>(functionDescriptor.InputParameters);
            outputParameters = new List<string>() { functionDescriptor.ReturnType };

            foreach (var tag in functionDescriptor.GetSearchTags())
                SearchKeywords.Add(tag);

            var weights = functionDescriptor.GetSearchTagWeights();
            foreach (var weight in weights)
            {
                // Search tag weight can't be more then 1.
                if (weight <= 1)
                    keywordWeights.Add(weight);
            }

            int weightsCount = weights.Count();
            // If there weren't added weights for search tags, then add default value - 0.5
            if (weightsCount != SearchKeywords.Count)
            {
                int numberOfLackingWeights = SearchKeywords.Count - weightsCount;

                // Number of lacking weights should be more than 0.
                // It can be less then 0 only if there was some mistake in xml file.
                if (numberOfLackingWeights > 0)
                {
                    for (int i = 0; i < numberOfLackingWeights; i++)
                    {
                        keywordWeights.Add(0.5);
                    }
                }

            }

            iconName = GetIconName();
        }
Exemple #17
0
 protected dynWorkspace(String name, List<dynNode> e, List<dynConnector> c, double x, double y)
 {
     this.Name = name;
     this.Nodes = e;
     this.Connectors = c;
     this.PositionX = x;
     this.PositionY = y;
     this.Notes = new List<dynNote>();
 }
        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            // Build an AST node for the type of object contained in your Items collection.

            var intNode = AstFactory.BuildIntNode((int)Items[SelectedIndex].Item);
            var assign = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), intNode);

            return new List<AssociativeNode> {assign};
        }
Exemple #19
0
        internal override IEnumerable<AssociativeNode> BuildAst(List<AssociativeNode> inputAstNodes)
        {
            var resultAst = new List<AssociativeNode>
            {
                AstFactory.BuildAssignment(AstIdentifierForPreview, inputAstNodes[0])
            };

            return resultAst;
        }
 /// <summary>
 ///     The class constructor - use this constructor for built-in types\
 ///     that are not yet loaded.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="tags"></param>
 public LocalSearchElement(string name, string description, List<string> tags)
 {
     this.Node = null;
     this._name = name;
     this.Weight = 1;
     this.Keywords = String.Join(" ", tags);
     this._type = "Node";
     this._description = description;
 }
Exemple #21
0
        public ElementGeometryObjects()
        {
            InPortData.Add(new PortData("element", "element to create geometrical references to", typeof(FScheme.Value.Container)));
            OutPortData.Add(new PortData("list", "Geometry objects of the element", typeof(FScheme.Value.List)));

            RegisterAllPorts();

            instanceGeometryObjects = null;
        }
Exemple #22
0
 public RenderDescription()
 {
     points = new Point3DCollection();
     lines = new Point3DCollection();
     meshes = new List<Mesh3D>();
     xAxisPoints = new Point3DCollection();
     yAxisPoints = new Point3DCollection();
     zAxisPoints = new Point3DCollection();
 }
Exemple #23
0
        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            var func =
                new Func<Revit.Elements.FamilySymbol, IList<Revit.Elements.Element>>(
                    ElementQueries.OfFamilyType);

            var functionCall = AstFactory.BuildFunctionCall(func, inputAstNodes);
            return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
        }
Exemple #24
0
 /// <summary>
 ///     The class constructor - use this constructor for built-in types\
 ///     that are not yet loaded.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="tags"></param>
 public NodeSearchElement(string name, string description, List<string> tags)
 {
     ToggleDescriptionVisibilityCommand = new DelegateCommand(ToggleIsVisible);
     this.Node = null;
     this._name = name;
     this.Weight = 1;
     this.Keywords = String.Join(" ", tags);
     this._type = "Node";
     this._description = description;
 }
        private void UpdateUpstream()
        {
            OnClear();

            var gathered = new List<NodeModel>();
            watchNode.VisibleUpstreamNodes(gathered);

            gathered.ForEach(n => n.WasInvolvedInExecution = true);
            gathered.ForEach(n => n.RequestVisualUpdateAsync(scheduler, engineManager.EngineController, renderPackageFactory));
        }
Exemple #26
0
        public dynPort(int index)
        {
            connectors = new List<dynConnector>();
            //this.workBench = workBench;
            this.index = index;
            InitializeComponent();

            this.MouseEnter += delegate { foreach (var c in connectors) c.Highlight(); };
            this.MouseLeave += delegate { foreach (var c in connectors) c.Unhighlight(); };
        }
Exemple #27
0
        public ParticleSystem()
        {
            hasDeadParticles = false;
            integrator = new VerletIntegrator(this);

            particles = new List<Particle>();
            springs = new List<ParticleSpring>();

            gravity = new XYZ(0, 0, DEFAULT_GRAVITY);
            drag = DEFAULT_DRAG;
        }
Exemple #28
0
 public override IEnumerable<AssociativeNode> BuildOutputAst(
     List<AssociativeNode> inputAstNodes)
 {
     return new[]
     {
         CreateOutputAST(
             AstFactory.BuildStringNode(_script),
             inputAstNodes,
             new List<Tuple<string, AssociativeNode>>())
     };
 }
Exemple #29
0
        protected override AssociativeNode GetFunctionApplication(NodeModel model, List<AssociativeNode> inputAstNodes)
        {
            if (!model.IsPartiallyApplied)
                return AstFactory.BuildFunctionCall(Definition.FunctionName, inputAstNodes);

            var count = Definition.Parameters.Count();
            return AstFactory.BuildFunctionObject(
                Definition.FunctionName,
                count,
                Enumerable.Range(0, count).Where(model.HasInput),
                inputAstNodes);
        }
        public override Value Evaluate(FSharpList<Value> args)
        {
            FSharpList<Value> pts = ((Value.List)args[0]).Item;
            FamilySymbol fs = (FamilySymbol)((Value.Container)args[1]).Item;

            FamilyInstance ac = null;

            //if the adapative component already exists, then move the points
            if (Elements.Any())
            {
                //mutate
                Element e;
                //...we attempt to fetch it from the document...
                if (dynUtils.TryGetElement(this.Elements[0], typeof(FamilyInstance), out e))
                {
                    ac = e as FamilyInstance;
                    ac.Symbol = fs;
                }
                else
                {
                    //create
                    ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs);
                    Elements[0] = ac.Id;
                }
            }
            else
            {
                //create
                ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs);
                Elements.Add(ac.Id);
            }

            if (ac == null)
                throw new Exception("An adaptive component could not be found or created.");

            IList<ElementId> placePointIds = new List<ElementId>();
            placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(ac);

            if (placePointIds.Count() != pts.Count())
                throw new Exception("The input list of points does not have the same number of values required by the adaptive component.");

            // Set the position of each placement point
            int i = 0;
            foreach (ElementId id in placePointIds)
            {
                ReferencePoint point = dynRevitSettings.Doc.Document.GetElement(id) as ReferencePoint;
                XYZ pt = (XYZ)((Value.Container)pts.ElementAt(i)).Item;
                point.Position = pt;
                i++;
            }

            return Value.NewContainer(ac);
        }