protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.RegisterParam(new GHParam_DHr(), "Dhours", "Dhrs", "The Dhours to plot", GH_ParamAccess.list); pManager.Register_StringParam("Value Key", "Key", "The name of the value to plot", GH_ParamAccess.item); pManager.Register_IntervalParam("Domain", "Rng", "The [optional] domain to plot, with black corresponding to the low value and white to the high value. Defaults to the max and min of the given values", GH_ParamAccess.item); Params.Input[2].Optional = true; }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { base.RegisterInputParams(pManager); pManager.AddIntegerParameter("radius", "r", "the radius in index space, point pairs with distance below this value will be tested", GH_ParamAccess.item); pManager.AddNumberParameter("possibility", "p", "the possibility of connect a pair of points ", GH_ParamAccess.item); pManager.AddNumberParameter("near level", "nl", "if the chemoattractor level dffenrence between a pair of points is lower than this value, we connect them with possibility.", GH_ParamAccess.item); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddBooleanParameter("write?", "W?", "Write the va3c JSON file to disk?", GH_ParamAccess.item); pManager.AddTextParameter("filePath", "Fp", "Full filepath of the file you'd like to create. Files will be overwritten automatically.", GH_ParamAccess.item); pManager.AddTextParameter("Mesh Geo", "Me", "va3c geometry", GH_ParamAccess.list); pManager.AddTextParameter("Materials", "Mat", "va3c materials", GH_ParamAccess.list); }
/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddCurveParameter("Struts", "Struts", "Cleaned curve network.", GH_ParamAccess.list); pManager.AddPointParameter("Nodes", "Nodes", "List of unique nodes.", GH_ParamAccess.list); pManager.AddIntegerParameter("CurveStart", "I", "Index in 'Nodes' for the start of each curve in 'Struts'.", GH_ParamAccess.list); pManager.AddIntegerParameter("CurveEnd", "J", "Index in 'Nodes' for the end of each curve in 'Struts'.", GH_ParamAccess.list); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddMeshParameter("Mesh", "M", "Mesh of the model", GH_ParamAccess.item); pManager.AddNumberParameter("Thickness", "T", "Thickness of the parts", GH_ParamAccess.item); pManager.AddPlaneParameter("Plane", "P", "Base plane", GH_ParamAccess.item, Plane.WorldXY); pManager.AddNumberParameter("Border", "B", "Overlapping of the layers", GH_ParamAccess.item, 0); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddMeshParameter("Mesh", "M", "Mesh of the model", GH_ParamAccess.item); pManager.AddPlaneParameter("Planes", "P", "Section Planes", GH_ParamAccess.list); pManager.AddNumberParameter("Thickness", "T", "Thickness of the parts", GH_ParamAccess.item); pManager.AddNumberParameter("Deeper", "D", "Makes the slits deeper", GH_ParamAccess.item, 0.0); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddCurveParameter("Curves", "C", "", GH_ParamAccess.list); pManager.AddPlaneParameter("Plane", "P", "", GH_ParamAccess.item); pManager[1].Optional = true; }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddLineParameter("Line", "L", "A line to convert into a va3c JSON representation of the line", GH_ParamAccess.item); pManager.AddGenericParameter("Line Material", "Lm", "Line Material", GH_ParamAccess.item); pManager.AddTextParameter("Layer", "[L]", "Layer", GH_ParamAccess.item); pManager[2].Optional = true; }
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.Register_GenericParam("Feedback", "F", "Feedback Output. Here you get a copy of the data at the \"*D\" input, or the \"*S\" input if the first is empty."); pManager.Register_GenericParam("Feedback History", "H", "History Output. Here you get the history of all Hoopsnake iterations."); pManager.Register_IntegerParam("Loops Counter", "L", "Loops Counter."); pManager.Register_IntegerParam("Iterations Counter", "I", "Iterations Counter."); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddCurveParameter("Struts", "Struts", "Wireframe to thicken", GH_ParamAccess.list); pManager.AddTextParameter("Gradient String", "Grad", "The spatial gradient as an expression string", GH_ParamAccess.item, "0"); pManager.AddNumberParameter("Maximum Radius", "Rmax", "Maximum radius in gradient", GH_ParamAccess.item, 0.5); pManager.AddNumberParameter("Minimum Radius", "Rmin", "Minimum radius in gradient", GH_ParamAccess.item, 0.2); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { base.RegisterInputParams(pManager); pManager.AddGenericParameter("Environment", "Env", "Environment", GH_ParamAccess.item); pManager.AddIntegerParameter("detect radius", "detr", "Below this value, pairs of agents locations will be connected at a possibility.", GH_ParamAccess.item); pManager.AddNumberParameter("select possibility", "selp", "The possibility of a pair of agents locations are connected", GH_ParamAccess.item); }
public static List<object[]> Run(GH_Component component, IList<object> data, System.Collections.IDictionary kwargs) { Type t = component.GetType(); var method = t.GetMethod("SolveInstance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); List<object[]> input = BuildInputList(data); int output_count = component.Params.Output.Count; int iterations = input.Count; List<object[]> output = new List<object[]>(output_count); for (int i = 0; i < output_count; i++) output.Add(new object[iterations]); bool run_parallel = false; if (kwargs != null && kwargs.Contains("multithreaded")) run_parallel = (bool)kwargs["multithreaded"]; if (run_parallel) { System.Threading.Tasks.Parallel.For(0, input.Count, (iteration) => SolveIteration(iteration, component, input, output, method)); } else { for( int iteration=0; iteration<input.Count; iteration++) { SolveIteration(iteration, component, input, output, method); }; } return output; }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddGenericParameter("Input", "I", "Input value", GH_ParamAccess.tree); pManager.AddBooleanParameter("Enumerate", "E", "Enumerate lists to sequentally named items, or create a list of values", GH_ParamAccess.item, false); this.Params.Input[0].ObjectChanged += resetMapping; this.Params.Input[0].AttributesChanged += resetMapping; }
/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddIntegerParameter("PIndexBending", "PI12", "The particle index associated with the calculated moment", GH_ParamAccess.item); pManager.AddPlaneParameter("Plane", "pl", "The bending plane", GH_ParamAccess.item); pManager.AddNumberParameter("BendingMoment", "M", "The bending moment [kNm]", GH_ParamAccess.item); pManager.AddNumberParameter("BendingStress", "stressB", "The bending stress [MPa]", GH_ParamAccess.item); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.RegisterParam(new GHParam_SpatialGraph(), "Spatial Graph", "S", "The Spatial Graph.", GH_ParamAccess.item); pManager.Register_StringParam("Script", "Func", "The function to execute", GH_ParamAccess.item); pManager.Register_DoubleParam("Value", "V", "Initial Values", GH_ParamAccess.list); pManager.Register_IntegerParam("Generations", "G", "Number of Generations to create.", 0, GH_ParamAccess.item); }
/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddVectorParameter("TotalDisplacements", "vDispl", "The total displacement of each node [mm]", GH_ParamAccess.list); pManager.AddNumberParameter("MaximumDisplacementX", "Xmax", "The maximum displacement in the x direction [mm]", GH_ParamAccess.item); pManager.AddNumberParameter("MaximumDisplacementY", "Ymax", "The maximum displacement in the y direction [mm]", GH_ParamAccess.item); pManager.AddNumberParameter("MaximumDisplacementZ", "Zmax", "The maximum displacement in the z direction [mm]", GH_ParamAccess.item); }
/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddPointParameter("Position", "P", "Position", GH_ParamAccess.item); pManager.AddVectorParameter("Velocity", "V", "Velocity", GH_ParamAccess.item); pManager.AddVectorParameter("Acceleration", "A", "Acceleration", GH_ParamAccess.item); pManager.AddIntegerParameter("Lifespan", "L", "Lifespan", GH_ParamAccess.item); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { var p = new GH_TurtleMeshParam(); p.Name = "TurtleMesh"; p.NickName = "T"; pManager.AddParameter(p); }
//set up input parameters - token, filter, and refresh trigger protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddParameter(new AuthToken_Param(), "Token", "T", "Google Authentication Token, obtained with Google Authenticator component.", GH_ParamAccess.item); //description of filter parameter string desc = string.Concat(new string[] { "Allows you to filter spreadsheets from your drive.", "\n", "Filter is case sensitive.", "\n", "The following wildcards are allowed:", "\n", "? (any single character)", "\n", "* (zero or more characters)", "\n", "# (any single digit [0-9])", "\n", "[chars] (any single character in chars)", "\n", "[!chars] (any single character not in chars)" }); pManager.AddTextParameter("Filter", "F", desc, GH_ParamAccess.item); pManager[1].Optional = true; //filter is optional pManager.AddBooleanParameter("Refresh", "R", "Send a new value to this parameter to cause the list of spreadsheets to refresh.", GH_ParamAccess.tree, true); //refresh parameter value is never actually used, but any new data passed into it will trigger a new solveinstance. }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddCurveParameter("Polyline", "Pl", "A list of polylines to offset", GH_ParamAccess.item); pManager.AddPointParameter("Point", "P", "Offset Distance", GH_ParamAccess.item); pManager.AddPlaneParameter("Plane", "Pln", "Plane to project the polylines to", GH_ParamAccess.item, default(Plane)); pManager.AddNumberParameter("Tolerance", "T", "Tolerance: all floating point data beyond this precision will be discarded.", GH_ParamAccess.item, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddPointParameter("Position", "pos", "The position of the load", GH_ParamAccess.list); pManager.AddVectorParameter("Load", "load", "The nodal load", GH_ParamAccess.list); pManager.AddColourParameter("Colour", "c", "The colour of the load", GH_ParamAccess.item, Color.DarkCyan); pManager.AddNumberParameter("Scale", "sc", "Scale factor", GH_ParamAccess.item, 1.0); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddLineParameter("Lines", "ln", "The lines to display", GH_ParamAccess.list); pManager.AddPointParameter("DisplacedNodes", "pFinal", "The displaced nodes", GH_ParamAccess.list); pManager.AddNumberParameter("Displacement", "displ", "The nodal displacements", GH_ParamAccess.list); pManager.AddColourParameter("ColourRange", "c", "The colour range (use gradient)", GH_ParamAccess.list); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.Register_CurveParam("Path Curve", "PC", "Path Curve"); pManager.Register_PlaneParam("Path Plane", "PP", "Path Plane"); pManager.Register_CurveParam("Section Curve", "SC", "Section Curve"); pManager.Register_PlaneParam("Section Plane", "SP", "Section Plane"); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddBooleanParameter("write?", "W?", "Write the VA3C JSON file to disk?", GH_ParamAccess.item); pManager.AddTextParameter("filePath", "Fp", "Full filepath of the file you'd like to create. Files will be overwritten automatically.", GH_ParamAccess.item); pManager.AddGenericParameter("Elements", "E", "va3c Elements to add to the scene.", GH_ParamAccess.list); pManager[2].DataMapping = GH_DataMapping.Flatten; }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddSurfaceParameter("Surface", "Surf", "Surface to adjust.", GH_ParamAccess.item); pManager.AddBooleanParameter("Swap UV", "SwapUV", "Swap the uv parameters.", GH_ParamAccess.item, false); pManager.AddBooleanParameter("Reverse U", "ReverseU", "Reverse the u-parameter direction.", GH_ParamAccess.item, false); pManager.AddBooleanParameter("Reverse V", "ReverseV", "Reverse the v-parameter direction.", GH_ParamAccess.item, false); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddNumberParameter("Width", "w", "The larger value of the rectangle dimensions in mm", GH_ParamAccess.item); pManager.AddNumberParameter("Height", "h", "The smaller value of the rectangle dimensions in mm", GH_ParamAccess.item); pManager.AddNumberParameter("Thickness", "t", "The thickness of the cross section in mm. If nothing specified, the default is a solid", GH_ParamAccess.item); pManager[2].Optional = true; }
/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddBrepParameter("Unrolled Breps", "UnrolledBreps", "Unrolled Breps", GH_ParamAccess.tree); //0 pManager.AddPlaneParameter("Planes for Orientation", "OrientPlanes", "1st item origin plane, 2nd item target plane", GH_ParamAccess.tree); //1 pManager.AddCurveParameter("Shared Curves", "SharedCrv", "Shared Curves between Stripes", GH_ParamAccess.tree); //2 pManager.AddPointParameter("Points", "P", "Points unrolled with Brep", GH_ParamAccess.tree);//3 }
/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddNumberParameter("BucklingLoadFactor", "BLF", "The buckling load factor [-]", GH_ParamAccess.item); pManager.AddNumberParameter("LoadFactors", "LF", "Load factor for each iteration", GH_ParamAccess.list); pManager.AddNumberParameter("DisplacementRMS", "dRMS", "The displacements as a RMS value in [m] for each iteration", GH_ParamAccess.list); pManager.AddPointParameter("VertexPositions", "V", "The vertex positions for each iteration", GH_ParamAccess.tree); pManager.AddGenericParameter("GoalOutput", "O", "The output from the goals for each iteration. The data structure is identical to the PGoals input", GH_ParamAccess.tree); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddMeshParameter("Mesh", "M", "A Grasshopper Mesh", GH_ParamAccess.item); pManager.AddTextParameter("Attribute Names", "[aN]", "Attribute Names", GH_ParamAccess.list); pManager[1].Optional = true; pManager.AddTextParameter("Attribute Values", "[aV]", "Attribute Values", GH_ParamAccess.list); pManager[2].Optional = true; }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddNumberParameter("Heigth", "H", "Height of cross section", GH_ParamAccess.item, 100); pManager.AddNumberParameter("Width", "W", "Width of cross section", GH_ParamAccess.item, 100); pManager[0].Optional = true; pManager[1].Optional = true; }
public static List <object[]> Run(GH_Component component, IList <object> data, System.Collections.IDictionary kwargs) { Type t = component.GetType(); var method = t.GetMethod("SolveInstance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); List <object[]> input = BuildInputList(data); int output_count = component.Params.Output.Count; int iterations = input.Count; List <object[]> output = new List <object[]>(output_count); for (int i = 0; i < output_count; i++) { output.Add(new object[iterations]); } bool run_parallel = false; if (kwargs != null && kwargs.Contains("multithreaded")) { run_parallel = (bool)kwargs["multithreaded"]; } if (run_parallel) { System.Threading.Tasks.Parallel.For(0, input.Count, (iteration) => SolveIteration(iteration, component, input, output, method)); } else { for (int iteration = 0; iteration < input.Count; iteration++) { SolveIteration(iteration, component, input, output, method); } ; } return(output); }
/// <summary> /// Sets the message at the bottom of the Grasshopper component with run time information /// </summary> /// <param name="Component">The component to display</param> /// <param name="engineType">Which engine are we running</param> public void DisplayMessage(IGH_Component Component, string engineType, int cycles, bool display) { GH_Component thisobj = Component as GH_Component; if (display) { if (engineType == "Single") { thisobj.Message = "Creeper Engine | Cycles : " + cycles; } else if (engineType == "Double") { thisobj.Message = "Multi Creeper Engine | Cycles : " + cycles; } else if (engineType == "Bundling") { thisobj.Message = "Bundling Engine | Cycles : " + cycles; } } else { thisobj.Message = ""; } }
public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { System.Drawing.RectangleF rec = GrabBound; GH_Component comp = Owner as GH_Component; if (rec.Contains(e.CanvasLocation)) { dragMouseStartX = e.CanvasLocation.X; dragX = true; comp.ExpireSolution(true); return(GH_ObjectResponse.Capture); } for (int i = 0; i < dropdownlists.Count; i++) { if (unfolded[i]) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { rec = scrollBar; comp = Owner as GH_Component; if (rec.Contains(e.CanvasLocation)) { dragMouseStartY = e.CanvasLocation.Y; dragY = true; comp.ExpireSolution(true); return(GH_ObjectResponse.Capture); } } } } } return(base.RespondToMouseDown(sender, e)); }
public CreateSpeckleObjectByKeyValueWorker(GH_Component parent, ISpeckleConverter converter) : base(parent) { Converter = converter; }
public static string ReadVariable(ref Socket clientSocket, string variableRead, GH_Component component) { if (clientSocket == null) { throw new ArgumentNullException(nameof(clientSocket)); } if (variableRead == null) { throw new ArgumentNullException(nameof(variableRead)); } if (component == null) { throw new ArgumentNullException(nameof(component)); } byte[] messageReq = ReadMessageRequest(variableRead, out var outputString); byte[] receivedData = new byte[256]; int receivedBytes = 0; try //Try to receive message. { int sentBytes = clientSocket.Send(messageReq); //Request a specific message according to VarRead variable component.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Sent:" + sentBytes.ToString() + " bytes as " + outputString); component.Message = "Sent"; receivedBytes = clientSocket.Receive(receivedData); //Receive data back. } catch (SocketException e) { component.ClearRuntimeMessages(); component.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Your connection is abruptly closed by the host, make sure to check your cables and if the server is running."); } catch (ArgumentNullException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Read Variable :{0}" + e.ToString()); } catch (ObjectDisposedException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Read Variable :{0}" + e.ToString()); } catch (SecurityException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Write Variable Receive :{0}" + e.ToString()); } //Format received data to extract value. MessageReceiveFormat response = new MessageReceiveFormat(receivedData); component.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Received:" + receivedBytes.ToString() + " bytes as" + response._varValue); component.Message = "Received"; return(response._varValue); }
public Attributes_Custom(GH_Component owner) : base(owner) { thisowner = owner; }
public SendLocalWorker(GH_Component _parent) : base(_parent) { }
public ToNativeWorker(ISpeckleConverter _Converter, GH_Component parent) : base(parent) { Converter = _Converter; Objects = new GH_Structure <GH_ObjectWrapper>(); ConvertedObjects = new GH_Structure <IGH_Goo>(); }
public DeserializeWorker(GH_Component parent) : base(parent) { Objects = new GH_Structure <GH_String>(); ConvertedObjects = new GH_Structure <GH_SpeckleBase>(); }
public ReceiveComponentAttributes(GH_Component owner) : base(owner) { }
/// <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) { Plane plane = new Plane(); string text = ""; double size = 5; int justify = 0; string font = ""; bool bold = false; double offsetDis = 0; DA.GetData("Location", ref plane); DA.GetData("Text", ref text); DA.GetData("Size", ref size); DA.GetData("Justification", ref justify); DA.GetData("Font", ref font); DA.GetData("Bold", ref bold); DA.GetData("OffsetDistance", ref offsetDis); if (justify < 0 || justify > 8) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Justification.Only 0-8 are allowed."); justify = 4; } TextJustification justification = TextJustification.MiddleCenter; if (justify == 0) { Message = "BottomLeft"; justification = TextJustification.BottomLeft; } else if (justify == 1) { Message = "BottomCenter"; justification = TextJustification.BottomCenter; } else if (justify == 2) { Message = "BottomRight"; justification = TextJustification.BottomRight; } else if (justify == 3) { Message = "MiddleLeft"; justification = TextJustification.MiddleLeft; } else if (justify == 4) { Message = "MiddleCenter"; justification = TextJustification.MiddleCenter; } else if (justify == 5) { Message = "MiddleRight"; justification = TextJustification.MiddleRight; } else if (justify == 6) { Message = "TopLeft"; justification = TextJustification.TopLeft; } else if (justify == 7) { Message = "TopCenter"; justification = TextJustification.TopCenter; } else if (justify == 8) { Message = "TopRight"; justification = TextJustification.TopRight; } TextEntity t = new TextEntity(); t.Plane = plane; t.PlainText = text; t.DimensionScale = size; t.Font = Rhino.DocObjects.Font.InstalledFonts(font)[0]; t.Justification = justification; t.SetBold(bold); List <Curve> curves = new List <Curve>(t.Explode()); List <Point3d> boxCorner = new List <Point3d>(); foreach (Curve crv in curves) { foreach (Point3d pt in crv.GetBoundingBox(plane).GetCorners()) { boxCorner.Add(pt); } } Box box = new Box(plane, new BoundingBox(boxCorner)); Point3d[] corners = box.GetCorners(); Point3d[] pts = new Point3d[5] { corners[0], corners[1], corners[2], corners[3], corners[0] }; PolylineCurve polyCrv = new PolylineCurve(pts); Curve bound; if (offsetDis == 0) { bound = polyCrv; } else { bound = polyCrv.Offset(plane, offsetDis, GH_Component.DocumentTolerance(), CurveOffsetCornerStyle.Round)[0]; } DA.SetDataList("Curve", curves); DA.SetData("Bound", bound); }
//TODO: fix keyboard loop. public void keyboardLoop(string _keyInput, long _stepResolution, ref Socket _clientSocket, GH_Component component) { string presentValue = Util.ReadVariable(ref _clientSocket, "$POS_ACT", component); E6POS currentPos = new E6POS(); currentPos.DeserializeE6POS(presentValue); if (_keyInput != "None") { var k = keyToVectorCalc(_keyInput, _stepResolution); currentPos.UpdateE6Pos(k[0], k[1], k[2], k[3], k[4], k[5]); } }
public Normal_ButtonAttribute(GH_Component owner, List <HuControl> ControlList) : base(owner, ControlList) { //这里会自动调用基类的构造函数 }
public CustomGUI(GH_Component owner) : base(owner) { }
//将Parameter固定为12*20的方块大小 public Normal_DropDownAttribute(GH_Component owner, List <string> MenuNames, DropDownControl DropDown) : base(owner) { this.ContextMenuName = MenuNames; this.DropDownControl = DropDown; }
protected int FindFrameObject(IGH_DataAccess DA) { if (this.Params.Input[0].SourceCount == 0) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Please input a NumberSlider or a VrayTimeLine to Input Frame."); return(int.MinValue); } FrameObject = this.Params.Input[0].Sources[0].Attributes.GetTopLevel.DocObject; if (FrameObject is GH_NumberSlider) { this.IsInputASlider = true; GH_NumberSlider frameSlider = FrameObject as GH_NumberSlider; if (frameSlider.Slider.Maximum != this.MaxFrame) { frameSlider.Slider.Maximum = this.MaxFrame; } if (frameSlider.Slider.Minimum != 0) { frameSlider.Slider.Minimum = 0; } frameSlider.Slider.Type = Grasshopper.GUI.Base.GH_SliderAccuracy.Integer; if (frameSlider.Slider.Value > frameSlider.Slider.Maximum) { frameSlider.Slider.Value = frameSlider.Slider.Maximum; } else if (frameSlider.Slider.Value < frameSlider.Slider.Minimum) { frameSlider.Slider.Value = frameSlider.Slider.Minimum; } frameSlider.NickName = "Frames"; frameSlider.Expression = "X * " + this.FrameTimeLast.ToString() + " + " + (this.TimeInFrame * FrameTimeLast).ToString(); this.SliderWidth = (float)(this.MaxTime * SliderMultiple) + 20; this.SliderWidth = SliderWidth > 120 ? SliderWidth : 120; float beforeWidth = frameSlider.Attributes.Bounds.Width; int SliderBigger = (int)SliderWidth - frameSlider.Slider.Bounds.Width; frameSlider.Attributes.Bounds = new RectangleF(frameSlider.Attributes.Bounds.X, frameSlider.Attributes.Bounds.Y, frameSlider.Attributes.Bounds.Width + SliderBigger, frameSlider.Attributes.Bounds.Height); float afterWidth = frameSlider.Attributes.Bounds.Width; float X = frameSlider.Attributes.Pivot.X - (afterWidth - beforeWidth); frameSlider.Attributes.Pivot = new PointF(X, frameSlider.Attributes.Pivot.Y); frameSlider.OnPingDocument().DestroyAttributeCache(); frameSlider.Attributes.ExpireLayout(); frameSlider.Attributes.PerformLayout(); this.Params.Input[1].Optional = false; return((int)frameSlider.Slider.Value); } else if (FrameObject.GetType().ToString() == "VRayForGrasshopper.VRayTimelineComponent") { this.IsInputASlider = false; GH_Component VrayComponent = FrameObject as GH_Component; SliderWidth = VrayComponent.Attributes.Bounds.Width - VrayComponent.Params.InputWidth - VrayComponent.Params.OutputWidth - 4; if ((VrayComponent.Params.Input[0].VolatileData.AllData(true).ElementAt(0) as GH_Integer).Value != this.MaxFrame) { VrayComponent.Params.Input[0].VolatileData.Clear(); VrayComponent.Params.Input[0].AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, this.MaxFrame); VrayComponent.ExpireSolution(true); } this.Params.Input[1].Optional = true; this.Save = false; int inputFrame = 0; DA.GetData("Current Frame", ref inputFrame); return(inputFrame); } else { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Only NumberSlider and VrayTimeLine are allowed for Input Frame!"); FrameObject = null; return(int.MinValue); } }
// Note that inheritors should provide parents using this constructor so state can be passed back up protected WorkerInstance(GH_Component parent) { Parent = parent; }
public ReceiveLocalWorker(GH_Component _parent) : base(_parent) { }
public static string WriteVariable(ref Socket clientSocket, string variableWrite, string dataWrite, GH_Component component) { if (clientSocket == null) { throw new ArgumentNullException(nameof(clientSocket)); } if (variableWrite == null) { throw new ArgumentNullException(nameof(variableWrite)); } if (dataWrite == null) { throw new ArgumentNullException(nameof(dataWrite)); } if (component == null) { throw new ArgumentNullException(nameof(component)); } byte[] messageReq = WriteMessageRequest(variableWrite, dataWrite, out string outputString); byte[] receivedData = new byte[256]; int receivedBytes = 0; try { int sentBytes = clientSocket.Send(messageReq); component.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Sent:" + sentBytes.ToString() + " bytes as " + outputString); component.Message = "Sent"; receivedBytes = clientSocket.Receive(receivedData); } catch (SocketException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "SocketException :{0}" + e.ToString()); } catch (ArgumentNullException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Write Variable :{0}" + e.ToString()); } catch (ObjectDisposedException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Write Variable :{0}" + e.ToString()); } catch (SecurityException e) { component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Write Variable Receive :{0}" + e.ToString()); } MessageReceiveFormat response = new MessageReceiveFormat(receivedData); component.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Received:" + receivedBytes.ToString() + " bytes as " + response._varValue); component.Message = "Received"; return(response._varValue); }
public Component(GH_Component comp) { MappedComponent = comp; }
public ReceiveComponentWorker(GH_Component p) : base(p) { }
public InputChecker(GH_Component _ghc) { ghc = _ghc; }
public CreateSpeckleObjectWorker(GH_Component parent, ISpeckleConverter converter) : base(parent) { Converter = converter; inputData = new Dictionary <string, object>(); }
/// <summary> /// Returns true if all branches have the same number of elements, and each element is /// equal/similar under epsilon tolerance. /// </summary> /// <param name="A"></param> /// <param name="B"></param> /// <param name="comp"></param> /// <param name="epsilon"></param> /// <returns></returns> internal static bool EqualDataTreeContent(GH_Structure <T> A, GH_Structure <T> B, GH_Component comp, double epsilon = 0) { // Compare number of items in each branch. var bA = A.Branches; var bB = B.Branches; for (int i = bA.Count - 1; i >= 0; i--) { if (bA[i].Count != bB[i].Count) { return(false); } } // Figure out data types and branch down to a different comparison method try { Type type = typeof(T); if (type == BOOL_TYPE) { return(EqualBoolData(A as GH_Structure <GH_Boolean>, B as GH_Structure <GH_Boolean>)); } else if (type == INT_TYPE) { return(EqualIntData(A as GH_Structure <GH_Integer>, B as GH_Structure <GH_Integer>)); } else if (type == NUMBER_TYPE) { return(EqualNumData(A as GH_Structure <GH_Number>, B as GH_Structure <GH_Number>, epsilon)); } else if (type == POINT_TYPE) { return(EqualPointData(A as GH_Structure <GH_Point>, B as GH_Structure <GH_Point>, epsilon)); } else if (type == VECTOR_TYPE) { return(EqualVectorData(A as GH_Structure <GH_Vector>, B as GH_Structure <GH_Vector>, epsilon)); } else if (type == PLANE_TYPE) { return(EqualPlaneData(A as GH_Structure <GH_Plane>, B as GH_Structure <GH_Plane>, epsilon)); } else if (type == LINE_TYPE) { return(EqualLineData(A as GH_Structure <GH_Line>, B as GH_Structure <GH_Line>, epsilon)); } else if (type == TEXT_TYPE) { return(EqualTextData(A as GH_Structure <GH_String>, B as GH_Structure <GH_String>)); } } catch { comp.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Something went wrong with the data here..."); } // If here, something went wring with comparison, so flag false for an update return(false); }
public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { for (int i = 0; i < dropdownlists.Count; i++) { System.Drawing.RectangleF rec = BorderBound[i]; GH_Component comp = Owner as GH_Component; if (rec.Contains(e.CanvasLocation)) { unfolded[i] = !unfolded[i]; comp.ExpireSolution(true); return(GH_ObjectResponse.Handled); } if (unfolded[i]) { System.Drawing.RectangleF rec2 = dropdownBound[i]; if (rec2.Contains(e.CanvasLocation)) { for (int j = 0; j < dropdownBounds[i].Count; j++) { System.Drawing.RectangleF rec3 = dropdownBounds[i][j]; if (rec3.Contains(e.CanvasLocation)) { if (displayTexts[i] != dropdownlists[i][j]) { // record an undo event so that user can ctrl + z comp.RecordUndoEvent("Selected " + dropdownlists[i][j]); // change the displayed text on canvas displayTexts[i] = dropdownlists[i][j]; // if initial texts exists then change all dropdowns below this one to the initial description if (initialTxts != null) { for (int k = i + 1; k < dropdownlists.Count; k++) { displayTexts[k] = initialTxts[k]; } } // send the selected item back to component (i = dropdownlist index, j = selected item in that list) action(i, j); // close the dropdown unfolded[i] = !unfolded[i]; // recalculate component comp.ExpireSolution(true); } else { unfolded[i] = !unfolded[i]; comp.ExpireSolution(true); } return(GH_ObjectResponse.Handled); } } } else { unfolded[i] = !unfolded[i]; comp.ExpireSolution(true); return(GH_ObjectResponse.Handled); } } } } return(base.RespondToMouseDown(sender, e)); }
internal CustomGUI(GH_Component owner) : base(owner) { }
public ExpandSpeckleObjectWorker(GH_Component _parent, ISpeckleConverter converter) : base(_parent) { Converter = converter; }
public Curve[] AfterOffset(Curve destination, double naN, Plane unset, int num2) { if (!RhinoMath.IsValidDouble(naN)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "不是有效的数字"); return(new Curve[] {}); } else if (!unset.IsValid) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "不是有效的平面"); return(new Curve[] { }); } else { double num3 = Math.Abs(naN); double tolerance = Math.Min(GH_Component.DocumentTolerance(), 0.1 * num3); GH_Component.DocumentAngleTolerance(); num2 = Math.Max(Math.Min(num2, 4), 0); if (naN == 0.0) { return(new Curve[] { destination }); } else { CurveOffsetCornerStyle none = CurveOffsetCornerStyle.None; switch (num2) { case 0: none = CurveOffsetCornerStyle.None; break; case 1: none = CurveOffsetCornerStyle.Sharp; break; case 2: none = CurveOffsetCornerStyle.Round; break; case 3: none = CurveOffsetCornerStyle.Smooth; break; case 4: none = CurveOffsetCornerStyle.Chamfer; break; } Curve[] inputCurves = null; inputCurves = destination.Offset(unset, naN, tolerance, none); if (inputCurves == null) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "不能偏移该曲线"); return(new Curve[] { }); } else { Curve[] data = Curve.JoinCurves(inputCurves); if (data == null) { return(inputCurves); } else { return(data); } } } } }
public GetObjectValueByKeyWorker(GH_Component _parent, ISpeckleConverter converter) : base(_parent) { Converter = converter; }
public ExtendSpeckleObjectByKeyValueWorker(GH_Component _parent, ISpeckleConverter converter) : base(_parent) { Converter = converter; keys = new List <string>(); values = new List <object>(); }