protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Types.GH_ObjectWrapper inputObj = null;
            DA.GetData(0, ref inputObj);

            var nameSpace  = "DemoGH.Handler";
            var methodName = "ModelToString";

            DA.GetData(1, ref methodName);

            object inputParam = inputObj.Value;
            object result     = null;

            if (inputParam is Model model)
            {
                // csharp object
                result = InvokeFunction(methodName, model);
            }
            else
            {
                result = InvokePythonFunction(methodName, inputParam);
            }

            DA.SetData(0, result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Types.GH_ObjectWrapper GHWrapper = null;
            DA.GetData(0, ref GHWrapper);

            if (GHWrapper.Value is System.Collections.IList && GHWrapper.Value.GetType().IsGenericType)
            {
                DA.SetDataList(0, (System.Collections.IList)GHWrapper.Value);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Types.GH_ObjectWrapper GHWrapper = null;
            DA.GetData(0, ref GHWrapper);

            List <string> props = new List <string>();

            foreach (System.Reflection.PropertyInfo prop in GHWrapper.Value.GetType().GetProperties())
            {
                props.Add(prop.Name);
            }

            DA.SetDataList(0, props);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            ghdoc = this.OnPingDocument();
            ghdoc.ContextChanged += new GH_Document.ContextChangedEventHandler(CheckDisplay);

            Model input = null;

            DA.GetData(0, ref input);
            if (input.Mesh == null)
            {
                return;
            }
            Model model = input.Clone() as Model;

            Grasshopper.Kernel.Types.GH_ObjectWrapper type0D = null;
            Grasshopper.Kernel.Types.GH_ObjectWrapper type1D = null;
            Grasshopper.Kernel.Types.GH_ObjectWrapper type2D = null;
            DA.GetData(1, ref type0D);
            DA.GetData(2, ref type1D);
            DA.GetData(3, ref type2D);

            type0D.Value.CheckResultDimension(0);
            type1D.Value.CheckResultDimension(1);
            type2D.Value.CheckResultDimension(2);
            string nodeResultType = type0D.ToString();
            string barResType     = type1D.ToString();
            string panelResType   = type2D.ToString();

            bool showVals, showNds, showEdgs, deformed, showLCS, showLoads, showSupports, showCNs, showNNs, showENs, showLVals;

            showVals = showNds = showEdgs = deformed = showLCS = showLoads = showSupports = showCNs = showNNs = showENs = showLVals = false;
            double TFactor, GFactor, Dfactor;

            TFactor = GFactor = Dfactor = 0;
            DA.GetData(4, ref showVals);
            DA.GetData(5, ref showNds);
            DA.GetData(6, ref showEdgs);
            DA.GetData(7, ref deformed);
            DA.GetData(8, ref showLCS);
            DA.GetData(9, ref showLoads);
            DA.GetData(10, ref showSupports);
            DA.GetData(11, ref showCNs);
            DA.GetData(12, ref showNNs);
            DA.GetData(13, ref showENs);
            DA.GetData(14, ref showLVals);
            DA.GetData(15, ref TFactor);
            DA.GetData(16, ref GFactor);
            DA.GetData(17, ref Dfactor);

            List <int> panelIds = new List <int>();
            List <int> barIds   = new List <int>();

            DA.GetDataList(18, barIds);
            DA.GetDataList(19, panelIds);

            double[] sizeFactors = model.sizeFactors();
            double   EFactor     = sizeFactors[0];
            double   FFactor     = sizeFactors[1];

            if (deformed)
            {
                model.Mesh.Deform(Dfactor);
            }

            m_display = new Rhino.Display.CustomDisplay(!this.Hidden);
            Grasshopper.GUI.Gradient.GH_Gradient gradient = PreviewUtil.CreateStandardGradient();

            HashSet <int> nodeIds = new HashSet <int>();
            HashSet <int> barNodeIds;
            HashSet <int> panelNodeIds;

            m_display.AddBarPreview(model, barIds, out barNodeIds, GFactor, EFactor, TFactor, showCNs, showENs, showLCS, false, barResType, showVals);
            m_display.AddPanelPreview(model, panelIds, out panelNodeIds, GFactor, EFactor, TFactor, FFactor, showCNs, showENs, showLCS, showLoads, showLVals, showEdgs, false, gradient, panelResType, showVals);

            nodeIds.UnionWith(panelNodeIds);
            nodeIds.UnionWith(barNodeIds);
            m_display.AddNodePreview(model, nodeIds, GFactor, EFactor, TFactor, FFactor, showNds, showNNs, showLoads, showLVals, gradient, nodeResultType, showVals);

            if (showSupports)
            {
                m_display.AddSupportPreview(model, nodeIds, EFactor, GFactor);
            }
        }