public async Task <IActionResult> PutGrasshopper(int id, Grasshopper grasshopper)
        {
            if (id != grasshopper.Id)
            {
                return(BadRequest());
            }
            _context.Entry(grasshopper).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GrasshopperExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// You will need to override this method to register the outputs for the designer.
        /// </summary>
        /// <param name="pManager">Grasshopper's output parameter manager</param>
        protected override void RegisterOutputParams(Grasshopper.Kernel.GH_Component.GH_OutputParamManager pManager)
        {
            base.RegisterOutputParams(pManager);

            pManager.Register_DoubleParam("quantity", "q", "Material Quantity");
            pManager.Register_StringParam("textoutput", "t", "Textual Output");
        }
        public async Task <ActionResult <Grasshopper> > PostGrasshopper(Grasshopper grasshopper)
        {
            _context.Grasshoppers.Add(grasshopper);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetGrasshopper), new { id = grasshopper.Id }, grasshopper));
        }
예제 #4
0
    internal PythonEnvironment(Grasshopper.Kernel.GH_Component component, PythonScript script)
    {
      Component = component;
      Script = script;

      if (script != null)
      {
        Type scriptType = script.GetType();

        var scopeField = scriptType.GetField("m_scope");
        if (scopeField != null)
        {
          LocalScope = scopeField.GetValue(script);
        }

        var baseType = scriptType.BaseType;
        if (baseType != null && baseType != typeof (object))
        {
          var hostType = baseType.Assembly.GetType("RhinoPython.Host");
          if (hostType != null)
          {
            var engineInfo = hostType.GetProperty("Engine");
            if (engineInfo != null)
              Engine = engineInfo.GetValue(null, null);

            var scopeInfo = hostType.GetProperty("Scope", System.Reflection.BindingFlags.NonPublic |
                                                          System.Reflection.BindingFlags.GetProperty |
                                                          System.Reflection.BindingFlags.Static);
            if (scopeInfo != null)
              ScriptScope = scopeInfo.GetValue(null, null);
          }
        }
      }

    }
        /// <summary>
        /// You will need to override this method to solve the component.
        /// </summary>
        /// <param name="DA">Grasshopper's DataAccess interface</param>
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            /// Note that you will need to call the SolveInstance method of the base class to process the default parameters and connect them to the framework.
            base.SolveInstance(DA);

            DA.SetData(1, ((SimpleAssessmentExample)this.Assessment).EmbodiedEnergy);
            DA.SetData(2, "Embodied energy: " + ((SimpleAssessmentExample)this.Assessment).EmbodiedEnergy.ToString("0.00"));
        }
 /// <summary>
 /// You will need to override this method to register the inputs for the designer.
 /// </summary>
 /// <param name="pManager">Grasshopper's input parameter manager</param>
 protected override void RegisterInputParams(GH.Kernel.GH_Component.GH_InputParamManager pManager)
 {
     base.RegisterInputParams(pManager);
     pManager.AddPointParameter("p", "p", "Base point", GH.Kernel.GH_ParamAccess.item);
     pManager.AddNumberParameter("s", "s", "Span", GH.Kernel.GH_ParamAccess.item, 10.0);
     pManager.AddNumberParameter("h", "h", "Height", GH.Kernel.GH_ParamAccess.item, 1.0);
     pManager.AddIntegerParameter("n", "n", "Number of frames", GH.Kernel.GH_ParamAccess.item, 1);
     pManager.AddNumberParameter("sp", "sp", "Spacing", GH.Kernel.GH_ParamAccess.item, 1.0);
 }
        public async Task <ActionResult <Grasshopper> > GetGrasshopper(int id)
        {
            Grasshopper grasshopper = await _context.Grasshoppers.FindAsync(id);

            if (grasshopper == null)
            {
                return(NotFound());
            }
            return(grasshopper);
        }
        /// <summary>
        /// You will need to override this method to solve the component.
        /// </summary>
        /// <param name="DA">Grasshopper's DataAccess interface</param>
        protected override void SolveInstance(GH.Kernel.IGH_DataAccess DA)
        {
            // first set the properties in the SODesigner
            int n = 0;
            if (DA.GetData<int>(1, ref n))
            {
                ((DesignerWithInputExample)this.Designer).NumberOfBeams = n;
            }

            /// Note that you will need to call the SolveInstance method of the base class to process the default parameters and connect them to the framework.
            base.SolveInstance(DA);
        }
 public static void DocumentOverview(GH.Kernel.GH_Document doc)
 {
     if (doc != null)
     {
         foreach (GH.Kernel.GH_DocumentObject obj in doc.Objects)
         {
             string name = obj.Name;
             string uid = obj.InstanceGuid.ToString();
             Rhino.RhinoApp.WriteLine("- " + name + " (" + uid + ")");
         }
     }
 }
예제 #10
0
        public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args)
        {
            if (Hidden)
            {
                return;
            }
            if (listArrow != null)
            {
                args.Display.DrawLines(listArrow, System.Drawing.Color.Red);
            }
            //eigenvectors
            if (crossCyan != null)
            {
                args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan);
            }
            if (crossMagenta != null)
            {
                args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta);
            }
            foreach (var leaf in listLeaf)
            {
                if (leaf.forceSrf != null)
                {
                    var srf = leaf.forceSrf.Duplicate() as Rhino.Geometry.NurbsSurface;
                    //srf.Transform(zScale);
                    args.Display.DrawSurface(srf, System.Drawing.Color.Aqua, 2);
                    if (leaf.tuples != null)
                    {
                        foreach (var tup in leaf.tuples)
                        {
                            var P = leaf.formSrf.PointAt(tup.u, tup.v);
                            var Q = leaf.forceSrf.PointAt(tup.u, tup.v);
                            Rhino.Geometry.Vector3d D = new Rhino.Geometry.Vector3d(Q.X, Q.Y, Q.Z);
                            D.Unitize();
                            D *= 0.3;
                            args.Display.DrawLine(new Rhino.Geometry.Line(P, P + D), System.Drawing.Color.Magenta);
                        }
                    }
                }
            }
            foreach (var leaf in listLeaf)
            {

                /*
                if (leaf.shellSrf != null)
                {
                    var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface;
                    srf.Transform(zDown_eq);
                    args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3);
                }*/
            }
        }
        public async Task <ActionResult <Grasshopper> > DeleteGrasshopper(int id)
        {
            Grasshopper grasshopper = await _context.Grasshoppers.FindAsync(id);

            if (grasshopper == null)
            {
                return(NotFound());
            }
            _context.Grasshoppers.Remove(grasshopper);
            await _context.SaveChangesAsync();

            return(grasshopper);
        }
        public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e)
        {
            if ((ContentBox.Contains(e.CanvasLocation)))
            {
                CurrentOwner.SOLVE = true;

                // hit the export straight away, where we handle the folder selection! 
                CurrentOwner.Export();
                CurrentOwner.ExpireSolution(true);

                return Grasshopper.GUI.Canvas.GH_ObjectResponse.Handled;
            }

            return Grasshopper.GUI.Canvas.GH_ObjectResponse.Ignore;
        }
 public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args)
 {
     if (Hidden)
     {
         return;
     }
     if (this.Attributes.Selected)
     {
         args.Display.DrawLines(lGeometry, System.Drawing.Color.Magenta, 3);
     }
     else
     {
         args.Display.DrawLines(lGeometry, System.Drawing.Color.DarkMagenta, 3);
     }
     base.DrawViewportWires(args);
 }
 /// <summary>
 /// Decrypts the cipherbytes. Implements <see cref="IAESService.Decrypt(byte[])"/>.
 /// </summary>
 /// <param name="cipherbytes">The cipherbytes to be decrypted.</param>
 /// <returns>The JSON object.</returns>
 public JObject Decrypt(byte[] cipherbytes)
 {
     helperAES = new AESHelper();
     algorithm = new Grasshopper();
     byte[] plainbytes = new byte[cipherbytes.Length];
     using (MemoryStream stream = new MemoryStream(cipherbytes))
     {
         byte[] block = new byte[16];
         int    count = 0;
         while (stream.Read(block, 0, blockLength) > 0)
         {
             Array.Copy(algorithm.Decrypt(block, Keys.GrasshopperKey), 0, plainbytes, count, blockLength);
             count += blockLength;
         }
         return(helperAES.ParseToJson(plainbytes));
     }
 }
 /// <summary>
 /// Encrypts the message. Implements <see cref="IAESService.Encrypt(dynamic)"/>.
 /// </summary>
 /// <param name="json">The JSON object to be encrypted.</param>
 /// <returns>The cipherbytes.</returns>
 public byte[] Encrypt(dynamic json)
 {
     helperAES = new AESHelper();
     byte[] message = helperAES.Normalize(json);
     algorithm = new Grasshopper();
     using (MemoryStream stream = new MemoryStream(message))
     {
         byte[] block       = new byte[16];
         byte[] cipherbytes = new byte[0];
         while (stream.Read(block, 0, blockLength) > 0)
         {
             Array.Resize(ref cipherbytes, cipherbytes.Length + blockLength);
             Array.Copy(algorithm.Encrypt(block, Keys.GrasshopperKey), 0, cipherbytes, cipherbytes.Length - blockLength, blockLength);
         }
         return(cipherbytes);
     }
 }
 /// <summary>
 /// Overloaded Implementation of Dispose. Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">True if managed resources should be disposed; otherwise, false.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (helperAES != null)
             {
                 helperAES = null;
             }
             if (algorithm != null)
             {
                 algorithm = null;
             }
             disposed = true;
         }
     }
 }
        /// <summary>
        /// Singleton
        /// </summary>
        public static SOGrasshopperController GetInstance(GH.Kernel.GH_Document ghDocument)
        {
#if DEBUG
            Rhino.RhinoApp.Write("Trying to make controlller... ");
#endif
            if (m_Instance == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_Instance == null)
                    {
                        m_Instance = new SOGrasshopperController();
                        m_Instance.m_Controller = SOController.Instance;
#if DEBUG
                        Rhino.RhinoApp.Write("new... ");
#endif
                    }
                }
            }
#if DEBUG
            Rhino.RhinoApp.WriteLine("done");
#endif
            if (ghDocument != null)
            {
                if (!m_Instance.m_Registered)
                {
                    ghDocument.RaiseEvents = true;
                    ghDocument.SolutionStart += new GH.Kernel.GH_Document.SolutionStartEventHandler(ghDocument_SolutionStart);
                    ghDocument.SolutionEnd += new GH.Kernel.GH_Document.SolutionEndEventHandler(ghDocument_SolutionEnd);
                    ghDocument.ObjectsAdded += new GH.Kernel.GH_Document.ObjectsAddedEventHandler(ghDocument_ObjectsAdded);
                    ghDocument.ObjectsDeleted += new GH.Kernel.GH_Document.ObjectsDeletedEventHandler(ghDocument_ObjectsDeleted);
                    m_Instance.m_Registered = true;
#if DEBUG
                    Rhino.RhinoApp.WriteLine("Events registered");
#endif
                }
            }
            return m_Instance;
        }
예제 #18
0
 public bool AddVolatileDataList(Grasshopper.Kernel.Data.GH_Path path, System.Collections.IEnumerable list)
 {
     throw new NotImplementedException();
 }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;
            DA.GetData(1, ref v);
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Curve c = null;
                if (!DA.GetData(0, ref c)) return;
                if (c.IsPolyline())
                {
                    Rhino.Geometry.Polyline pl = null;
                    if (c.TryGetPolyline(out pl))
                    {
                        nNewNodes = pl.Count();
                        nElements = nNewNodes - 1;
                        newNodes.Clear();
                        newNodes.AddRange(pl);
                        lGeometry.Clear();
                        for (int i = 0; i < nElements; i++)
                        {
                            lGeometry.Add(new Rhino.Geometry.Line(newNodes[i], newNodes[i + 1]));
                        }


                        mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]);
                        }
                        List<mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List<mikity.NumericalMethodHelper.elements.isoparametricElement>();
                        for (int i = 0; i < nElements; i++)
                        {
                            e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1));
                        }
                        lCV.Clear();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < e.Count; i++)
                        {
                            lCV.Add(new constrainVolumeObject(v / nElements));
                            lCV[i].addElement(e[i]);
                            pS.Value.addObject(lCV[i]);
                        }

                        lGeometry.Clear();
                        for (int i = 0; i < nElements; i++)
                        {
                            lGeometry.Add(new Rhino.Geometry.Line(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2], pS.Value.particles[i + 1, 0], pS.Value.particles[i + 1, 1], pS.Value.particles[i + 1, 2]));
                        }
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }

            }
            else
            {
                if (lCV != null && v > 0)
                {
                    for (int i = 0; i < lCV.Count; i++)
                    {
                        lCV[i].refVolume = v / nElements;
                    }
                }
            }
            DA.SetData(0, pS);
            DA.SetDataList(1, newNodes);
        }
 protected override void RegisterInputParams(Grasshopper.Kernel.GH_Component.GH_InputParamManager pManager)
 {
     pManager.AddCurveParameter("Curve", "c", "Curve", Grasshopper.Kernel.GH_ParamAccess.item);
     pManager.AddNumberParameter("Length", "L", "Prescribed value for the length", Grasshopper.Kernel.GH_ParamAccess.item);
 }
 protected override void RegisterOutputParams(Grasshopper.Kernel.GH_Component.GH_OutputParamManager pManager)
 {
     pManager.AddGenericParameter("Particle System", "pS", "Particle System", Grasshopper.Kernel.GH_ParamAccess.item);
     pManager.Register_PointParam("Points", "P", "Particle System", Grasshopper.Kernel.GH_ParamAccess.list);
 }
예제 #22
0
 private Point3d GraphPoint(int hour_of_year, float value, Plane plane, Interval ival_y, Grasshopper.Kernel.Types.UVInterval ival2d)
 {
     // returns a point in graph coordinates, ready to be plotted on a given plane
     double x = ival2d.U.ParameterAt((hour_of_year + 0.5) / 8760.0);
     double y = ival2d.V.ParameterAt(ival_y.NormalizedParameterAt(value));
     Point3d pt = new Point3d(x, y, 0);
     return pt;
 }
예제 #23
0
 public void RecordUndoEvent(Grasshopper.Kernel.Undo.GH_UndoRecord record)
 {
     throw new NotImplementedException();
 }
예제 #24
0
 public bool AddVolatileDataTree(Grasshopper.Kernel.Data.IGH_Structure tree)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// You will need to override this method to register the outputs for the designer.
 /// </summary>
 /// <param name="pManager">Grasshopper's output parameter manager</param>
 protected override void RegisterOutputParams(GH.Kernel.GH_Component.GH_OutputParamManager pManager)
 {
     // Note that you will need to call the RegisterOutputParams method of the base class to register the default output parameters.
     base.RegisterOutputParams(pManager);
     pManager.AddLineParameter("l", "l", "l", GH.Kernel.GH_ParamAccess.list);
 }
예제 #26
0
 public static bool UniformDataType(Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.IGH_Goo> tree, ref String UniformType)
 {
     if (tree.get_FirstItem(true) == null) return false;
     Type t = tree.get_FirstItem(true).GetType();
     foreach (IGH_Goo obj in tree.AllData(false)) {
         if (obj == null) return false;
         if (obj.GetType() != t) return false;
     }
     UniformType = TypeToString(tree.get_FirstItem(true));
     return true;
 }
예제 #27
0
        public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args)
        {
            if (Hidden)
            {
                return;
            }
            if (listArrow != null)
            {
                args.Display.DrawLines(listArrow, System.Drawing.Color.Red);
            }
            //targetSrf
            if (listPnt != null)
            {
                args.Display.DrawPoints(targetSrf, Rhino.Display.PointStyle.Simple, 1, System.Drawing.Color.White);
            }
            //eigenvectors
            if (crossCyan != null)
            {
                args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan);
            }
            if (crossMagenta != null)
            {
                args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta);
            }
            if (listError != null)
            {
                foreach (var error in listError)
                {
                    args.Display.DrawCurve(error, System.Drawing.Color.Red, 10);
                }
            }
            /*if (listSlice != null)
            {
                foreach (var slice in listSlice.Values)
                {
                    var pl = slice.pl;
                    args.Display.DrawPolygon(new Rhino.Geometry.Point3d[] { pl.PointAt(-2, -2), pl.PointAt(-2, 2), pl.PointAt(2, 2), pl.PointAt(2, -2) }, System.Drawing.Color.Azure, true);
                }
            }*/
            foreach (var branch in listBranch)
            {
                switch (branch.branchType)
                {
                    case Mothra4.branch.type.fix:
                        args.Display.DrawCurve(branch.crv, System.Drawing.Color.Orange, 3);
                        break;
                    case Mothra4.branch.type.reinforce:
                        args.Display.DrawCurve(branch.crv, System.Drawing.Color.Cyan, 3);
                        break;
                    case Mothra4.branch.type.kink:
                        args.Display.DrawCurve(branch.crv, System.Drawing.Color.Purple, 3);
                        break;
                    case Mothra4.branch.type.open:
                        args.Display.DrawCurve(branch.crv, System.Drawing.Color.Green, 3);
                        break;
                }
            }
            foreach (var leaf in listLeaf)
            {
                if (leaf.airySrf != null)
                {
                    var srf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface;
                    srf.Transform(zScale);
                    args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3);
                }
            }
            foreach (var leaf in listLeaf)
            {
                if (leaf.shellSrf != null)
                {
                    var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface;
                    srf.Transform(zDown_eq);
                    args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3);
                }
            }
            /*foreach (var branch in listBranch)
            {
                if (branch.airyCrv != null)
                {
                    var crv = branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve;
                    crv.Transform(zScale);
                    args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 4);
                }
            }*/
            foreach (var branch in listBranch)
            {
                if (branch.branchType == branch.type.fix)
                {
                    double x = 0, y = 0, z = branch.slice2.height;
                    for (int i = 0; i < branch.N; i++)
                    {
                        x += branch.crv.Points[i].Location.X;
                        y += branch.crv.Points[i].Location.Y;
                        z += branch.crv.Points[i].Location.Z;
                    }
                    x /= branch.N;
                    y /= branch.N;
                    args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue);
                    args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue);
                    args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue);
                    args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue);
                }
            }
            foreach (var branch in listBranch)
            {
                if (branch.shellCrv != null)
                {
                    if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce || branch.branchType == branch.type.open)
                    {

                        var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve;
                        crv.Transform(zDown_eq);
                        args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 3);
                    }
                }
            }
            //find max value of reinforcement
            if (listBranch != null)
            {
                foreach (var branch in listBranch)
                {
                    if (branch.tuples != null)
                    {
                        if (branch.branchType == branch.type.fix)
                        {
                            foreach (var tup in branch.tuples)
                            {
                                var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5);
                                circle.Transform(zDown);
                                args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2);
                                circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5);
                                circle.Transform(zDown_eq);
                                args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2);
                            }
                        }
                        else
                        {
                            foreach (var tup in branch.tuples)
                            {
                                var D = tup.SPK[0, 0]/2d;
                                if (D > 0)
                                {
                                    var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D));
                                    line.Transform(zDown);
                                    args.Display.DrawLine(line, System.Drawing.Color.Red, 2);
                                }
                                else
                                {
                                    var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D));
                                    line.Transform(zDown);
                                    args.Display.DrawLine(line, System.Drawing.Color.Blue, 2);
                                }
                            }
                        }
                    }
                }
            }

            /*
            if (a != null)
            {
                args.Display.DrawPoints(a, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue);

            }*/
            if (a2 != null)
            {
                args.Display.DrawPoints(a2, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue);

            }
        }
예제 #28
0
 protected override void RegisterInputParams(Grasshopper.Kernel.GH_Component.GH_InputParamManager pManager)
 {
     pManager.AddSurfaceParameter("listSurface1", "lstSrf1", "list of surfaces1", Grasshopper.Kernel.GH_ParamAccess.list);
     pManager.AddSurfaceParameter("listSurface2", "lstSrf2", "list of surfaces2", Grasshopper.Kernel.GH_ParamAccess.list);
     pManager.AddCurveParameter("fixedBoundary", "listCrv", "list of boundary curves(force diagram!)", GH_ParamAccess.list);
     pManager.AddPointParameter("fixedPoints", "listPnt", "list of fixed points (form diagram!)", GH_ParamAccess.list);
 }
예제 #29
0
 protected override void RegisterOutputParams(Grasshopper.Kernel.GH_Component.GH_OutputParamManager pManager)
 {
 }
예제 #30
0
 public override void AddedToDocument(Grasshopper.Kernel.GH_Document document)
 {
     base.AddedToDocument(document);
 }
 /// <summary>
 /// You will need to override this method to register the inputs for the designer.
 /// </summary>
 /// <param name="pManager">Grasshopper's input parameter manager</param>
 protected override void RegisterInputParams(Grasshopper.Kernel.GH_Component.GH_InputParamManager pManager)
 {
     // Note that you will need to call the RegisterInputParams method of the base class to register the default input parameters.
     base.RegisterInputParams(pManager);
 }
예제 #32
0
 public Guid RecordUndoEvent(string name, Grasshopper.Kernel.Undo.IGH_UndoAction action)
 {
     throw new NotImplementedException();
 }
예제 #33
0
 public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e)
 {
     return c.SelectFolderDialog();
 }
예제 #34
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            init();
            _listSrf1 = new List<Surface>();
            _listSrf2 = new List<Surface>();
            _listCrv = new List<Curve>();
            _listPnt = new List<Point3d>();
            if (!DA.GetDataList(0, _listSrf1)) { return; }
            if (!DA.GetDataList(1, _listSrf2)) { return; }
            if (!DA.GetDataList(2, _listCrv)) { _listCrv = new List<Curve>(); }
            if (!DA.GetDataList(3, _listPnt)) { _listPnt=new List<Point3d>(); }
            listNode = new List<node>();
            listLeaf = new List<leaf>();
            for (int i = 0; i < _listSrf1.Count; i++)
            {
                var formSrf = _listSrf1[i];
                var forceSrf = _listSrf2[i];
                var leaf = new leaf();
                listLeaf.Add(leaf);
                leaf.formSrf = formSrf as NurbsSurface;
                leaf.forceSrf = forceSrf as NurbsSurface;
                leaf.nU = leaf.formSrf.Points.CountU;
                leaf.nV = leaf.formSrf.Points.CountV;
                leaf.domU = leaf.formSrf.Domain(0);
                leaf.domV = leaf.formSrf.Domain(1);
                leaf.uDim = leaf.formSrf.OrderU;
                leaf.vDim = leaf.formSrf.OrderV;
                leaf.uDdim = leaf.formSrf.OrderU - 1;
                leaf.vDdim = leaf.formSrf.OrderV - 1;
                leaf.nUelem = leaf.nU - leaf.uDdim;
                leaf.nVelem = leaf.nV - leaf.vDdim;
                leaf.scaleU = (leaf.domU.T1 - leaf.domU.T0) / leaf.nUelem;
                leaf.scaleV = (leaf.domV.T1 - leaf.domV.T0) / leaf.nVelem;
                leaf.originU = leaf.domU.T0;
                leaf.originV = leaf.domV.T0;
                var domainU = leaf.formSrf.Domain(0);
                var domainV = leaf.formSrf.Domain(1);
                var key = "leaf";
            }
            // Connect nodes
            foreach (var leaf in listLeaf)
            {
                leaf.globalIndex = new int[leaf.formSrf.Points.CountU * leaf.formSrf.Points.CountV];
                for (int j = 0; j < leaf.formSrf.Points.CountV; j++)
                {
                    for (int i = 0; i < leaf.formSrf.Points.CountU; i++)
                    {
                        var P = leaf.formSrf.Points.GetControlPoint(i, j).Location;
                        var Q = leaf.forceSrf.Points.GetControlPoint(i, j).Location;
                        bool flag = false;
                        foreach (var node in listNode)
                        {
                            if (node.compare2(Q))
                            {
                                flag = true;
                                node.N++;
                                node.shareL.Add(leaf);
                                node.numberLU.Add(i);
                                node.numberLV.Add(j);
                                leaf.globalIndex[i + j * leaf.nU] = listNode.IndexOf(node);
                                break;
                            }
                        }
                        if (!flag)
                        {
                            var newNode = new node();
                            newNode.forceNodeType = node.type.fr;
                            newNode.formNodeType = node.type.fr;
                            listNode.Add(newNode);
                            newNode.N = 1;
                            newNode.x = P.X;
                            newNode.y = P.Y;
                            newNode.z = P.Z;
                            newNode.X = Q.X;
                            newNode.Y = Q.Y;
                            newNode.Z = Q.Z;

                            newNode.shareL.Add(leaf);
                            newNode.numberLU.Add(i);
                            newNode.numberLV.Add(j);
                            leaf.globalIndex[i + j * leaf.nU] = listNode.IndexOf(newNode);
                        }
                    }
                }
            }
            //judge which node is fixed...
            foreach (var node in listNode)
            {
                foreach (var _crv in _listCrv)
                {
                    var crv = _crv as NurbsCurve;
                    for (int i = 0; i < crv.Points.Count; i++)
                    {
                        if (node.compare2(crv.Points[i].Location))
                        {
                            node.forceNodeType = node.type.fx;
                        }
                    }
                }
                foreach (var P in _listPnt)
                {
                    if (node.compare2(P))
                    {
                            node.forceNodeType = node.type.fx;
                    }
                }
            }
            myControlPanel.state = controlPanel._state.forceDiagramReady;
        }
예제 #35
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (!(RhinoApp.GetPlugInObject("Grasshopper") is GH_RhinoScriptInterface Grasshopper))
            {
                return(Result.Cancel);
            }

            GetOption go = null;

            while (true)
            {
                var port     = new OptionInteger(Port, 1024, 65535);
                var toggle   = new OptionToggle(ShowEditor, "Hide", "Show");
                var debugger = new OptionToggle(Debug, "Off", "On");

                go = new GetOption();

                go.SetCommandPrompt("Noah Server");
                go.AddOption("Connect");
                go.AddOption("Stop");
                go.AddOption("Observer");
                go.AddOptionInteger("Port", ref port);
                go.AddOptionToggle("Editor", ref toggle);
                go.AddOptionToggle("Debug", ref debugger);
                go.AddOption("Workspace");

                GetResult result = go.Get();
                if (result != GetResult.Option)
                {
                    break;
                }

                ShowEditor = toggle.CurrentValue;
                Debug      = debugger.CurrentValue;

                string whereToGo = go.Option().EnglishName;

                if (whereToGo == "Connect")
                {
                    if (Port == 0)
                    {
                        RhinoApp.WriteLine("Please set Port you want to connect!");
                        continue;
                    }

                    if (WorkDir == null)
                    {
                        RhinoApp.WriteLine("Noah can not work without workspace!");
                        continue;
                    }

                    if (Client == null)
                    {
                        try
                        {
                            Grasshopper.DisableBanner();

                            if (!Grasshopper.IsEditorLoaded())
                            {
                                Grasshopper.LoadEditor();
                            }

                            Client               = new NoahClient(Port, WorkDir);
                            Client.InfoEvent    += Client_MessageEvent;
                            Client.ErrorEvent   += Client_ErrorEvent;
                            Client.WarningEvent += Client_WarningEvent;
                            Client.DebugEvent   += Client_DebugEvent;
                        }
                        catch (Exception ex)
                        {
                            RhinoApp.WriteLine("Error: " + ex.Message);
                        }

                        Client.Connect();
                    }
                    else
                    {
                        Client.Reconnect();
                    }

                    if (Debug)
                    {
                        try
                        {
                            if (Logger == null)
                            {
                                Panels.OpenPanel(LoggerPanel.PanelId);
                            }
                            Logger = Panels.GetPanel <LoggerPanel>(doc);
                        }
                        catch (Exception ex)
                        {
                            RhinoApp.WriteLine("Error: " + ex.Message);
                        }
                    }

                    if (ShowEditor)
                    {
                        Grasshopper.ShowEditor();
                    }

                    break;
                }

                if (whereToGo == "Stop")
                {
                    if (Port == 0)
                    {
                        continue;
                    }

                    if (Client != null)
                    {
                        Client.Close();
                    }
                    break;
                }

                if (whereToGo == "Workspace")
                {
                    RhinoGet.GetString("Noah Workspace", false, ref WorkDir);
                }

                if (whereToGo == "Observer")
                {
                    if (Port == 0)
                    {
                        RhinoApp.WriteLine("Server connecting need a port!");
                        continue;
                    }

                    Process.Start("http://localhost:" + Port + "/data/center");
                    break;
                }

                if (whereToGo == "Port")
                {
                    Port = port.CurrentValue;
                    RhinoApp.WriteLine("Port is set to " + Port.ToString());
                    continue;
                }
            }

            return(Result.Nothing);
        }
예제 #36
0
 public void ManagerConstructed(GH_VarParamSide side, Grasshopper.GUI.GH_VariableParameterManager manager)
 {
     string pool = (side == GH_VarParamSide.Input) ? "xyzuvw" : "abcdef";
       manager.NameConstructor = new GH_CharPatternParamNameConstructor(pool, 4);
 }
        /// <summary>
        /// You will need to override this method to solve the component.
        /// </summary>
        /// <param name="DA">Grasshopper's DataAccess interface</param>
        protected override void SolveInstance(GH.Kernel.IGH_DataAccess DA)
        {
            // Retrieve the data and pass it to the designer component
            Point3d point = new Point3d(0, 0, 0);
            double span = 10.0;
            double height = 1.0;
            int n = 1;
            double spacing = 1.0;
            if (DA.GetData<Point3d>(1, ref point))
            {
                ((DesignerWithVisualOutputExample)this.Designer).basePoint = new SOPoint3d(
                    point.X,
                    point.Y,
                    point.Z);
            }
            if (DA.GetData<double>(2, ref span))
            {
                ((DesignerWithVisualOutputExample)this.Designer).Span = span;
            }
            if (DA.GetData<double>(3, ref height))
            {
                ((DesignerWithVisualOutputExample)this.Designer).Height = height;
            }
            if (DA.GetData<int>(4, ref n))
            {
                ((DesignerWithVisualOutputExample)this.Designer).NumberOfFrames = n;
            }
            if (DA.GetData<double>(5, ref spacing))
            {
                ((DesignerWithVisualOutputExample)this.Designer).Spacing = spacing;
            }

            /// Note that you will need to call the SolveInstance method of the base class to process the default parameters and connect them to the framework.
            base.SolveInstance(DA);

            DesignerWithVisualOutputExample dsn = (DesignerWithVisualOutputExample)this.Designer;

            List<Line> lines = new List<Line>();
            for (int i = 0; i < dsn.NumberOfFrames; i++)
            {
                lines.Add(new Line(dsn.Points2[i].X, dsn.Points2[i].Y, dsn.Points2[i].Z, dsn.Points4[i].X, dsn.Points4[i].Y, dsn.Points4[i].Z));
                lines.Add(new Line(dsn.Points1[i].X, dsn.Points1[i].Y, dsn.Points1[i].Z, dsn.Points2[i].X, dsn.Points2[i].Y, dsn.Points2[i].Z));
                lines.Add(new Line(dsn.Points3[i].X, dsn.Points3[i].Y, dsn.Points3[i].Z, dsn.Points4[i].X, dsn.Points4[i].Y, dsn.Points4[i].Z));
            }
            DA.SetDataList(1, lines);
        }
예제 #38
0
 public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e)
 {
     ((GHClient)Owner).DisplayForm();
     return Grasshopper.GUI.Canvas.GH_ObjectResponse.Handled;
 }