Ejemplo n.º 1
0
        /// <summary>
        /// Upgrade an existing object.
        /// </summary>
        /// <param name="target">Object to upgrade.</param>
        /// <param name="document">Document that contains the object.</param>
        /// <returns>
        /// The newly created object on success, null on failure.
        /// </returns>
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }
            return(GH_UpgradeUtil.SwapComponents(component, this.UpgradeTo));
        }
Ejemplo n.º 2
0
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            PythonComponent_OBSOLETE component_OBSOLETE = target as PythonComponent_OBSOLETE;

            if (component_OBSOLETE == null)
            {
                return(null);
            }

            ZuiPythonComponent component_new = new ZuiPythonComponent();

            component_new.HiddenCodeInput = component_OBSOLETE.HiddenCodeInput;
            component_new.HiddenOutOutput = component_OBSOLETE.HiddenOutOutput;

            if (component_new.HiddenCodeInput)
            {
                component_new.Code = component_OBSOLETE.Code;
            }

            if (GH_UpgradeUtil.SwapComponents(component_OBSOLETE, component_new))
            {
                bool toRhinoScript = (component_OBSOLETE.DocStorageMode == DocReplacement.DocStorage.AutomaticMarshal);
                {
                    foreach (var c in component_new.Params.Input)
                    {
                        var sc = c as Param_ScriptVariable;
                        if (sc == null)
                        {
                            continue;
                        }

                        if (toRhinoScript)
                        {
                            IGH_TypeHint newHint;
                            if (PythonHints.ToNewRhinoscriptHint(sc.TypeHint, out newHint))
                            {
                                sc.TypeHint = newHint;
                            }
                        }
                        else
                        {
                            PythonHints.ToNewRhinoCommonHint(sc);
                        }
                    }
                }

                component_OBSOLETE.Dispose();

                return(component_new);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }

            IGH_Component swappedComp = GH_UpgradeUtil.SwapComponents(component, UpgradeTo);

            return(swappedComp);
        }
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            if (!(target is IGH_Component component))
            {
                return(null);
            }

            var upgradedComponent = GH_UpgradeUtil.SwapComponents(component, UpgradeTo);

            upgradedComponent.Params.Input[0].Access  = GH_ParamAccess.item;
            upgradedComponent.Params.Output[0].Access = GH_ParamAccess.item;
            UpgradeUtils.SwapGroups(document, component, upgradedComponent);
            return(upgradedComponent);
        }
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }
            GH_Component swappedComp = GH_UpgradeUtil.SwapComponents(component, this.UpgradeTo) as GH_Component;

            swappedComp.Params.Output[0].DataMapping = GH_DataMapping.Flatten;

            return(swappedComp);
        }
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }

            IGH_Component upgradedComponent = GH_UpgradeUtil.SwapComponents(component, UpgradeTo);

            UpgradeUtils.SwapGroups(document, component, upgradedComponent);

            return(upgradedComponent);
        }
Ejemplo n.º 7
0
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            ValueListener_Component_DEPRECATED component = target as ValueListener_Component_DEPRECATED;

            if (component == null)
            {
                return(null);
            }
            IGH_Component swappedComp = GH_UpgradeUtil.SwapComponents(component, this.UpgradeTo);

            ValueListener_Component swappedValListener = swappedComp as ValueListener_Component;

            swappedValListener.AddEventsEnabled = component.AddEventsEnabled;
            swappedValListener.updateMessage();

            return(swappedComp);
        }
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }

            IGH_Component upgradedComponent = GH_UpgradeUtil.SwapComponents(component, UpgradeTo);

            upgradedComponent.Params.Input[0].Access = GH_ParamAccess.item;
            upgradedComponent.Params.Input[2].Access = GH_ParamAccess.tree;
            UpgradeUtils.SwapGroups(document, component, upgradedComponent);

            return(upgradedComponent);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Upgrade an existing object.
        /// </summary>
        /// <param name="target">Object to upgrade.</param>
        /// <param name="document">Document that contains the object.</param>
        /// <see>https://discourse.mcneel.com/t/how-to-handle-input-output-definition-changes-when-a-component-gets-updated-in-a-new-version/64635/5</see>
        /// <returns>
        /// The newly created object on success, null on failure.
        /// </returns>
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            // ReSharper disable once UseNegatedPatternMatching
            var component = target as IGH_Component;
            var comp      = GH_UpgradeUtil.SwapComponents(component, UpgradeTo, true);

            if (comp == null)
            {
                return(null);
            }
            var param = new Param_Boolean();

            param.PersistentData.Append(new GH_Boolean(false));
            param.Name        = "Fake Shadow";
            param.NickName    = "FS";
            param.Description = "Add fake shadow to the mesh, it can help to visualize the grid.";
            param.Access      = GH_ParamAccess.item;
            comp.Params.Input.Add(param);
            return(comp);
        }
Ejemplo n.º 10
0
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }

            IGH_Component newComponent = GH_UpgradeUtil.SwapComponents(component, UpgradeTo);

            CreateSlider_Component tempComp = new CreateSlider_Component();

            IGH_Param inputParam = tempComp.Params.Input[1];

            newComponent.Params.RegisterInputParam(inputParam);


            return(newComponent);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Upgrade an existing object.
        /// </summary>
        /// <param name="target">Object to upgrade.</param>
        /// <param name="document">Document that contains the object.</param>
        /// <see>https://discourse.mcneel.com/t/how-to-handle-input-output-definition-changes-when-a-component-gets-updated-in-a-new-version/64635/5</see>
        /// <returns>
        /// The newly created object on success, null on failure.
        /// </returns>
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            // ReSharper disable once UseNegatedPatternMatching
            var component = target as IGH_Component;
            var comp      = GH_UpgradeUtil.SwapComponents(component, UpgradeTo, true);

            if (comp == null)
            {
                return(null);
            }
            var param = new Param_Integer();

            DataAccessHelper.AddEnumOptionsToParam <VoxelGridBoxes.SelectionType>(param);
            param.PersistentData.Append(new GH_Integer(1));
            param.Name        = "Selection";
            param.NickName    = "S";
            param.Description = "0 = all false voxels, 1 = all true voxels(default), -1 = all voxels";
            param.Access      = GH_ParamAccess.item;
            comp.Params.Input.Add(param);
            return(comp);
        }
Ejemplo n.º 12
0
        public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
        {
            IGH_Component component = target as IGH_Component;

            if (component == null)
            {
                return(null);
            }
            var newComponent = GH_UpgradeUtil.SwapComponents(component, this.UpgradeTo);

            //create a dummy instance of our new version of the component
            HumanUI.Components.UI_Containers.CreateGrid_Component testComp = new Components.UI_Containers.CreateGrid_Component();

            //identify the indices of the newly added params (relative to the old version of the component)
            int[] paramsToCopy = new int[] { 3, 4, 5, 6, 7, 8 };
            //grab the input params at those indices and register them to the component
            paramsToCopy.Select(i => testComp.Params.Input[i]).ToList().ForEach(p => newComponent.Params.RegisterInputParam(p));
            //make sure display and such gets cleaned up
            newComponent.Params.OnParametersChanged();
            return(newComponent);
        }