tically give you back all the items of the list. However, if you give it a list of lists (as you are in this example) it doesn't know to extract the items in the internal lists. The script I suggest simply reinterprets each list as a single item, and relies on the component data processing to split out the items list by list. This also has the advantage (over 筑梦NARUTO's solution) of keeping each list in its own grasshopper data tree branch.
If you'd rather avoid the clunkiness of a second script component, you'll have to compose a datatree yourself. That will look something like this:
import math as m
import Rhino
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
pi = m.pi
angle =0
pts = DataTree[Rhino.Geometry.Point3d]()
c=0
for i in rs.frange(0,5,0.5):
angle +=(pi/30)
layer = []
for j in rs.frange(0,2*pi,pi/15):
x= 5*m.sin(j+angle)
y= 5*m.cos(j+angle)
layer.append( Rhino.Geometry.Point3d(x,y,i))
pts.AddRange(layer,GH_Path(c))
c = c+1
a = pts
…
to explain the ultimate goal in case it helps to clarify. I have all the elements i need now to pull this together thanks to your help, as you say most critical things are already implemented or not relevant to this particular thread. With your fret generator and equal spacing generator and my primitive convoluted solution for compound radius fretboard i have everything i need but need some time to cleanly implement and pull it together now.
as to your questions/coments:
1/ I don't care about Excel files in this context. The SIMPLE solution is to just copy/paste sets of string gauges into as many panels as you need and switch between them.
this was just to explain that ultimately there are a lot of different input patterns but all the data for them does already exist. for sure it is not necessary but in the end it's a feature i would like to implement since it will make the patch much more practical.
2/ What are "scale length low E string" and "scale length high e string"? Are they the actual string lengths of the bass and treble strings?
This is the initial decision taken by the luthier: which scale lengths to use for the multiscale build. While anything that makes sense goes here luthiers will probably want to choose some common values, say 24.75" (like most Gibson guitars) or 25.5" (like a Fender Stratocaster)
P.S. I did the rotations at the points where the treble string intersects the virtual bridge and nut (blue lines), so rotation has no effect on its length.
P.P.S. In case it isn't obvious, rotation has no effect on string spacing either.
This is the kind of things i don't know cause i'm zero in maths and i usually have to try out and measure to know for sure :-) as i said my initial instinct would have been to rotate around the 'zero frets' center point simply because everything is built aroun d the X axis. If you rotate around the treble string (the high e string) would the distance of the upper fretboard edge to the x-axis be the same than from the lower fretboard edge to the x-axis ?
for running data through panels, thanks for the tip, i do this mainly to visualize the values without having to hover over the outputs, good to know i shouldn't patch them onward from the panel.
PS: For the height of the strings above the fretboard (the 'action'), it's not as complicated as it sounds and most of the time an experienced luthier or guitar tech will have no problem achieving whatever low action desired if the neck is straight and built properly and the frets level and dressed properly. there's a german company who's built a machine to do the 'perfect setup': the PLEK machine
i'm sorry it takes me much longer to digest and implement all this, i will post back when i've merged everything together but i think i have evrything so far
…
hit Commit.
I'm wondering how hard it would be to have an edit box which shows the
number the user could click inside of then type in a new number, then
hit enter. :)
2) How would I go about using one line from a table and assign each
field to a variable? Then, move a slider or something and use the values
from the next row?
background: I'm recreating elbows, Tees, and other fittings using
paramatric scripts, then baking and exporting them. Here's one source
table, http://www.wardfittings.com/Assets/PDFs/0902CatalogColorOld.pdf
page 5, the uniform elbows.
Current Setup: the attached ghx file. Create a point at 0,5,0 in a blank
document with units set to inches, then assign that point to the top
left 'Center Pnt' in the ghx file.
Current workflow:
a) Modify variables A, B, H, and Nominal Dia to match one line from the
table in the linked PDF file, page 5, table of regular elbows.
b) Select the 'Nodes' and 'Surfaces' with a drag box
c) Click 'Bake'
d) Switch to Rhino window, do the 'sellast' command.
e) Drag baked objects along Y axis so the center point is at 0,0,0
f) Run 'Join'
g) Run 'Cap'
h) set the 'node' points to a layer called 'nodes'
i) set the surface to a layer called 'fit-3d'.
j) select the surfaces and nodes
k) export selected
This elbow that I'm doing only has 12 rows, so doing it the above method
doesn't take THAT long. I'm also going to be doing a couple with larger
tables like the Tee on page 8, and in other spec files. As you can
imagine, entering in EACH value into a slider is a bit tedious.
I'd love to take the pdf table, run it through an OCR program to convert
to excel, modify the headers so the ghx script knows what they are, then
paste it into grasshopper, or save it and have grasshopper read it, and
I be able to move a slider or something to to select one line at a time.
Has anyone done something similar? ie: assigned one row in a table to a
predefined set of variables, each variable coming from one field in the row?
Thanks for taking the time to read this message. :)
I'm making a rhino script to do steps d-k, so that part will be much faster.
-Suthern…
is a tour through the different workshops we have organized in theTPceu from September 2010 when we started with this initiative.I take this opportunity to thank you all for your participation directly or indirectly to make all of this possible.
La exposición consiste en un recorrido por los diferentes talleres que hemos organizado en el TPceu desde septiembre de 2010 que arrancamos con ésta iniciativa.
Aprovecho para agradeceros a todos vuestra participación dirécta o indirecta para conseguir que todo ésto se haya hecho posible.
Organization: Pablo Delgado, Andrés Velasco Muro, Jaime Díaz Álvarez
more info at TP ceu…
urve. In this Curve I have defined the points, I exploded the segments and have added a Perp Frame on the ends of each segment.
Oriented on each Perp Frame I have created a Rectangle from which I have drawn a Box Rectangle.
Each 'other' (odd or even, or each 'second' rectangle in the list) of these rectangles needs to get a negative length value so it doesn't point outward of the curve, but instead so that it has it's length perpendicular to the segment.
So, eventually I want to make it so that each segment has a Box Rectangle placed on it's outermost point, pointing inwards. Half of these Box Rectangles is already oriented in the right direction, but I don't know how to single out half of them, or construct two lists with the 1st, 3rd, 5th, 7th, etc. and the 2nd, 4th, 6th, 8th etc.
I have added screenshots, I am making this as a personal project for a school project on the Art Academy and am really eager to learn to master this Grasshopper a bit more.
Before trying to do it this way, I tried to do it with Sweep1 Rail, but could not get the orientation along the segment, and also I didn't manage to find out how to limit the Sweep1 Rail to a certain distance (like 30mm for example).
I had imagined this should be done by projecting a second line of 30mm from a segment outer end inwards from both sides and using this second 30mm long line to put the Sweep 1 Rail on. Then I could close the ends, do a Union, Merge all Faces and be done.
However, I couldn't figure it out and the method I'm trying to solve now has gotten me further down the line of the process.
The next step in my process will be to be able to generate a structure on a point of a curve where I can project a certain shape on. Then I want to export this collection of shapes as an STL and 3D-print them. (I have built 2 3D-printer all by myself).
The parts are connectors to connect cheap aluminium extrusions together with minimal effort so I can start prototyping a shape for a small carriage I am designing.
If my explanation is unclear, please tell me, I am new to this, and my mother-language is Dutch, so mathematical terms are a bit difficult for me to understand, but please do use diffcult terms in an explanation where needed. I can only learn :)
Hi from a very happy new user of Grasshopper!
…
the application of the forces ...
The structure is designed to be then realized by using bent wood panels.
To stabilize the whole stucture, two methods are avaiable: the first one is to create a double shell with spacers inbetween (and other covering elements) and the second one is to insert element between the various openings. (see photos below)
Method 1.
Method 2.
Problem: I have to build two models, one for each type of structure, by using 1mm plywood panels. (Dimension more or less 60x40 cm).
The only way to obtain the exactly shape of the all pieces of the model (for laser cutting techniques) ist to digitalize the structure, or rather to simulate the bending of the panel after the application of the forces.
I create the surface with Rhino and now my question is: is there a method to simulate the bending of the wood panel with its cuts or opening? …otherwise the pieces of the model will always be inaccurate and the whole model difficult to assemble…
Thank you!
…
Added by Sandra Camini at 7:29am on November 9, 2017
arametric Design, in the history of architecture, has defined many rules for current designers and for future practitioners to follow. One of the strongest aspects that are prominent from this style is ‘geometry’. Arguably, there is nothing new about geometry and aesthetics forming the most prominent aspect of any style or era. The language of any style, in the long history of architecture, is visually defined by geometry or shape, beyond the principles that define the core of the style. In the distinguishable style of parametric architecture, geometry has played and is continuing to play an integral role. And with this fairly young style, there are many strings of myths and false notions associated.
The workshop aims to provide a detailed insight to ‘parametric design’ and embedded logics behind it through a series of design explorations using Rhinoceros & Grasshopper platforms, along with understanding of data-driven fabrication strategies. An insight to Computational Design and its subsets of Parametric Design, Algorithmic Design, Generative Design and Evolutionary Design will be provided through presentations, technical sessions & studio work, with highlighting agenda of using data into Hands-on fabrication of a parametrically generated design. A strong focus will be made on ‘geometry’ and ‘matter’.
// Methodology
Workshop has been structured to teach participants the use of Grasshopper® (Generative modelling plug-in for Rhinoceros) as a generative tool, and ways to integrate it with Hands-on Fabrication process. A strong agenda on ‘geometry’ and ‘matter’ will form the focus of the studio with design experimentation through computational & parametric techniques, culminating into a manually fabricated wall panel using understanding of data-driven design during the course of workshop.
Day 1 Topics / Agenda
Rhinoceros 3D GUI and basic use
Installing Grasshopper & plug-ins
Grasshopper GUI
Basic logic, components, parameters, inputs, numbers, simple geometry, referenced geometry, locally defined geometry, baking, etc.
Lists & Data Tree: management, manipulation, visualization, etc.
Design Experimentations with Geometry & Data
Understanding Data for Manual Fabrication
Day 2 Topics / Agenda
Design Experimentations with Geometry, Form, Matter
Data for effective numbering and strategizing during Manual Fabrication
Collaborative effort for Hands-on ‘making’ process
Analysis & Evaluation of Fabricated Geometry
Documentation…
bsp;
-Vehicle elements (3D objects and a component for custom vehicles; models from Google Warehouse)
-Traffic Velocity Graphs, drawn on every trajectory curve (allow custom graphs drawn)
-Traffic regulation elements (such as Traffic Lights and Stop Signals) and traffic density
-Particle Systems on trajectory curves, just to manage the traffic regulations and avoid collisions based on security distances
-Traffic Vehicle Animation Modes (Dots, Bounding Boxes or complex Meshes with attributes for final rendering (Giulio Piacentino´s Render Animation)
-Vehicle Lights and Vehicle Sights, to make visual studies
Team:
-Sergio del Castillo Tello (Doctor No, lead programmer)
-Everyone that wants to be involved, support.. these tools
The development of Roadrunner is planned to take part within a Research Group Program at ETSAM (University of Architecture in Madrid); This forum group is created just to test the interest of the community, while we keep on developing (it is still being tested), probably we will share the whole thing in the future. Cheers!
Traffic Cluster Scheme
Traffic Elements
Traffic Urban Systems
Vehicle Elements
Roadrunner - overview
Roadrunner 0 Basics
Roadrunner 1 Modes
Roadrunner 2 Elements
Roadrunner 3 Urban Systems…
oftware connections built from the initial seed of the project. As always you can download the new release from Food4Rhino. Make sure to remove the older version of Ladybug and Honeybee and update your scripts.
This release is also special since today it is just about 3 years (3 years and 2 weeks) from the first release of Ladybug. As with any release, there have been a number of bug fixes and improvements but we also have some major news this time. In no specific order and to ensure that the biggest developments do not get lost in the extensive list of updates, here are the major ones:
Mostapha is re-writing Ladybug!
Ladybug for DynamoBIM is finally available.
Chris made bakeIt really useful by incorporating an export pathway to PDFs and vector-based programs.
Honeybee is now connected to THERM and the LBNL suite thanks to Chris Mackey.
Sarith has addressed a much-desired wish for Honeybee (Hi Theodore!) by adding components to model electric lighting with Radiance.
Djordje is on his way to making renewable energy deeply integrated with Ladybug by releasing components for modeling solar hot water.
There is new bug. Check the bottom of the post for Dragonfly!
Last but definitely not least (in case you’re not still convinced that this release is a major one) Miguel has started a new project that brings some of Ladybug’s features directly to Rhino. We mean Rhino Rhino - A Rhino plugin! Say hi to Icarus! #surprise
Before we forget! Ladybug and Honeybee now have official stickers. Yes! We know about T-Shirts and mugs and they will be next. For now, you can deck-out your laptops and powerhouse simulation machines with the symbology of our collaborative software ecosystem.
Now go grab a cup of tea/coffee and read the details below:
Rewriting Ladybug!
Perhaps the most far-reaching development of the last 4 months is an effort on the part of Mostapha to initiate a well structured, well documented, flexible, and extendable version of the Ladybug libraries. While such code is something that few community members will interact with directly, a well-documented library is critical for maintaining the project, adding new features, and for porting Ladybug to other software platforms.
The new Ladybug libraries are still under development across a number of new repositories and they separate a ladybug-core, which includes epw parsing and all non-geometric functions, from interface-specific geometry libraries. This allows us to easily extend Ladybug to other platforms with a different geometry library for each platform (ie. ladybug-grasshopper, ladybug-dynamo, ladybug-web, etc) all of which are developed on top of the ladybug-core.
Without getting too technical, here is an example of a useful outcome of this development. If you want to know the number of hours that relative humidity is more than 90% for a given epw, all that you have to code (in any python interface) is the following:
import ladybug as lb
_epwFile = r"C:\EnergyPlusV7-2-0\WeatherData\USA_CO_Golden-NREL.724666_TMY3.epw"
epwfile = lb.epw.EPW(_epwFile)
filteredData = epwfile.relativeHumidity.filterByConditionalStatement('x>90')
print "Number of hours with Humidity more than 90 is %d "%len(filteredData.timeStamps)
Compare that to the 500 + lines that you would have had to write previously for this operation, which were usually tied to a single interface! Now let’s see what will happen if you want to use the geometry-specific libraries. Let’s draw a sunpath in Grasshopper:
import ladybuggrasshopper.epw as epw
import ladybuggrasshopper.sunpath as sunpath
# get location data form epw file
location = epw.EPW(_epwFile).location
# initiate sunpath based on location
sp = sunpath.Sunpath.fromLocation(location, northAngle = 0, daylightSavingPeriod = None, basePoint =cenPt, scale = scale, sunScale = sunScale)
# draw sunpath geometry
sp.drawAnnualSunpath()
# assign geometries to outputs
...
Finally we ask, how would this code will look if we wanted to make a sunpath for dynamo? Well, it will be exactly the same! Just change ladybuggrasshopper in the second line to ladybugdynamo! Here is the code which is creating the sunpath below.
With this ease of scripting, we hope to involve more of our community members in our development and make it easy for others to use ladybug in their various preferred applications. By the next release, we will produce an API documentation (documentation of all the ladybug classes, methods and properties that you can script with) and begin making tutorials for those interested in getting deeper into Ladybug development.
LADYBUG
1 - Initial Release of Ladybug for Dynamo:
As is evident from the post above, we are happy to announce the first release of Ladybug for Dynamo! You can download the ladybug package from Dynamo package manager. Make sure to download version 0.0.6 which is actually 0.0.1! It took a number of trial and errors to get it up there. Once you have the file downloaded you can watch these videos to get started:
The source code can be find under ladybug-dynamo repository and (as you can already guess) it is using the new code base. It includes a very small toolkit of essential Ladybug components/nodes but it has enough to get you started. You can import weather files, draw sunpaths and run sunlighthours or radiation analyses.
There are two known issues in this release but neither of them is critical. You need to have Dynamo 0.9.1 or higher installed which you can download from here (http://dynamobuilds.com/). It is recommended that you run the scripts with ‘Manual’ run (as opposed to ‘Automatic’) since the more intense calculations can make Dynamo crash in automatic mode.
To put things in perspective, here is how we would map Ladybug for Dynamo vs Ladybug and Honeybee for Grasshopper on the classic ‘Hype graph’. The good news is that what we learned a lot from the last three years, making development of the Dynamo version easier and getting us to the plateau of productivity faster.
We should also note that the current development of the Dynamo interface is behind that of the Ladybug-Core, which means there are a number of features that are developed in the code but haven’t made their way to the nodes yet. They will be added gradually over the next month or two.
If you’re interested to get involved in the development process or have ideas for the development, follow ladybug on Facebook, Twitter and Github. We will only post major release news here. Facebook, github and twitter will be the main channels for posting the development process. There will also be a release of a new ladybug for Grasshopper soon that will use the came Ladybug-Core libraries as the Dynamo interface [Trying hard not to name it as Ladybug 2].
2 - New Project “Icarus” Provides Ladybug Capabilities Directly in Rhino
Speaking of expanded cross-platform capabilities, the talented Miguel Rus has produced a standalone Rhino Plugin off of the original Ladybug code that has been included in this release. After writing his own core C# libraries, Miguel’s plugin enables users to produce sunpath and run sunlight hours analyses in the Rhino scene without need of opening Grasshopper or engaging the (sometimes daunting) act of visual scripting.
This release includes his initial RHP plugin file. It is hoped that Miguel’s efforts will extend some of the capabilities of environmental design to individuals who are unfamiliar with visual scripting, casting the network of our community into new territory. We need your help spreading the word about Icarus since the people who will benefit the most from it have probably not read this far into the release notes. Also, as the project is in the early stages, your feedback can make a great difference. You can download the current release from this link.
Once you download the zip file. Right click and unblock it. Then extract the files under C:\Program Files\Rhinoceros 5 (64-bit)\Plug-ins\ folder. Drag and drop the RHP file into Rhino and you should be ready to go. You can either type Icarus in the command line or open it via the panels. Here is a short video that shows how to run a sunlighhours analysis study in Rhino.
3 - BakeIt Input Now Supports a Pathway to PDF +Vector Programs
As promised in the previous release, the BakeIt_ option available on Ladybug’s visual components has been enhanced to provide a full pathway to vector-based programs (like Illustrator and Inkscape) and eases the export to vector formats like PDFs.
This means that the BakeIt_ operation now places all text in the Rhino scene as actual editable text (not meshes) and any colored meshes are output as groups of colored hatches (so that they appear as color-filled polygons in vector-based programs). There is still an option to bake the colored geometries as light meshes (which requires smaller amounts of memory and computation time) but the new hatched capability should make it easier to incorporate Ladybug graphics in architectural drawings and documents like this vector psychrometric chart.
4 - Physiological Equivalent Temperature (PET) Now Available
Thanks to the efforts of Djordje Spasic, it is now possible to compute the common outdoor comfort metric ‘Physiological Equivalent Temperature’ (PET) with Ladybug. The capability has been included with this release of “Thermal Comfort Indices” component and is supported by a “Body Characteristics” component in the Extra tab. PET is particularly helpful for evaluating outdoor comfort at a high spatial resolution and so the next Honeybee release will include an option for PET with the microclimate map workflow.
5 - Solar Hot Water Components Available in WIP
Chengchu Yan and Djordje Spasic have built a set of components that perform detailed estimates of solar hot water. The components are currently undergoing final stages of testing and are available in the WIP tab of this release. You can read the full release notes for the components here.
6 - New Ladybug Graphic Standards
With the parallel efforts or so many developers, we have made an effort in this release to standardize the means by which you interact with the components. This includes warnings for missing inputs and the ability to make either icons or text appear on the components as you wish (Hi Andres!). A full list of all graphic standards can be found here. If you have any thoughts or comments on the new standards, feel free to voice them here.
7 - Wet Bulb Temperature Now Available
Thanks to Antonello Di Nunzio - the newest member of the Ladybug development team, it is now possible to calculate wet bulb temperature with Ladybug. Antonello’s component can be found under the WIP tab and takes inputs of dry bulb temperature, relative humidity, and barometric pressure.
8 - New View Analysis Types
The view analysis component now allows for several different view studies in addition to the previous ‘view to test points.’ These include, skyview (which is helpful for studies of outdoor micro-climate), as well as spherical view and ‘cone of vision’ view, which are helpful for indoor studies evaluating the overall visual connection to the outdoors.
HONEYBEE
1 - Connection to THERM and LBNL Programs
With this release, many of you will notice that a new tab has been added to Honeybee. The tab “11 | THERM” includes 7 new components that enable you to export ready-to-simulate Lawrence Berkeley National Lab (LBNL) THERM files from Rhino/Grasshopper. THERM is a 2D finite element heat flow engine that is used to evaluate the performance of wall/window construction details by simulating thermal bridging behavior. The new Honeybee tab represents the first ever CAD plugin interface for THERM, which has been in demand since the first release of LBNL THERM several years ago. The export workflow involves the drawing of window/wall construction details in Rhino and the assigning of materials and boundary conditions in Grasshopper to produce ready-to-simulate THERM files that allow you to bypass the limited drawing interface of THERM completely. Additional components in the “11 | THERM” tab allow you to import the results of THERM simulations back into Grasshopper and assist with incorporating THERM results into Honeybee EnergyPlus simulations. Finally, two components assist with a connection to LBNL WINDOW for advanced modeling of Glazing constructions. Example files illustrating many of the capabilities of the new components can be found in there links.
THERM_Export_Workflow, THERM_Comparison_of_Stud_Wall_Constructions
Analyze_THERM_Results, Thermal_Bridging_with_THERM_and_EnergyPlus
Import_Glazing_System_from_LBNL_WINDOW, Import_LBNL_WINDOW_Glazing_Assembly_for_EnergyPlus
It is recommended that those who are using these THERM components for the first time begin by exploring this example file.
Tutorial videos on how to use the components will be posted soon. A great deal of thanks is due to the LBNL team that was responsive to questions at the start of the development and special thanks goes to Payette Architects, which allowed Chris Mackey (the author of the components) a significant amount of paid time to develop them.
2 - Electrical Lighting Components with Enhanced Capabilities for Importing and Manipulating IES Files
Thanks to the efforts of Sarith Subramaniam, it is now much easier and more flexible to include electric lighting in Honeybee Radiance simulations. A series of very exciting images and videos can be found in his release post.
You can find the components under WIP tab. Sarith is looking for feedback and wishes. Please give them a try and let him know your thoughts. Several example files showing how to use the components can be found here. 1, 2, 3.
3- Expanded Dynamic Shade Capabilities
After great demand, it is now possible to assign several different types of control strategies for interior blinds and shades for EnergyPlus simulations. Control thresholds range from zone temperature, to zone cooling load, to radiation on windows, to many combinations of these variables. The new component also features the ability to run EnergyPlus simulations with electrochromic glazing. An example file showing many of the new capabilities can be found here.
Dragonfly Beta
In order to link the capabilities of Ladybug + Honeybee to a wider range of climatic data sets and analytical tools, a new insect has been initiated under the name of Dragonfly. While the Dragonfly components are not included with the download of this release, the most recent version can be downloaded here. An example file showing how to use Dragonfly to warp EPW data to account for urban heat island effect can also be found here. By the next release, the capabilities of Dragonfly should be robust enough for it to fly on its own. Additional features that will be implemented in the next few months include importing thermal satellite image data to Rhino/GH as well as the ability to warp EPW files to account for climate change projections. Anyone interested in testing out the new insect should feel free to contact Chris Mackey.
And finally, it is with great pleasure that we welcome Sarith and Antonello to the team. As mentioned in the above release notes, Sarith has added a robust implementation for electric light modeling with Honeybee and Antonello has added a component to calculate wet bulb temperature while providing stellar support to a number of people here on the GH forum.
As always let us know your comments and suggestions.
Enjoy!
Ladybug+Honeybee development team
PS: Special thanks to Chris for writing most of the release notes!…
shopper later uses but for the life of me cannot see the problem.
Component
using System;using System.Collections.Generic;using Grasshopper.Kernel;using Rhino.Geometry;namespace Load_Take_Down_Tool.Components{ // This componenet takes care of creating ordered lists to pass to the column component // Searches for points within tributary areas public class Column_Organiser : GH_Component { /// <summary> /// Initializes a new instance of the Column_Organiser class. /// </summary> public Column_Organiser() : base("Column Organiser", "CO", "Orders lists of points and areas", "Load Take Down Tool", "Pre-Processing") { } /// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddPointParameter("Column", "C", "Unsorted points at location of column (required)", GH_ParamAccess.list); pManager.AddBrepParameter("Tributary Area", "T", "Unsorted tributary areas for column (required)", GH_ParamAccess.list); } /// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddPointParameter("Column", "C", "Sorted points at location of column", GH_ParamAccess.list); pManager.AddBrepParameter("Tributary Area", "T", "Sorted tributary areas for column", GH_ParamAccess.list); pManager.AddPointParameter("Failing Points", "FP", "Points that are not within any tributary area", GH_ParamAccess.list); } /// <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) { //Declare lists to hold data //uo = un-ordered //o = ordered List<Point3d> uocolumnpoints = new List<Point3d>(); List<Brep> uotribareas = new List<Brep>(); List<Point3d> failpoints = new List<Point3d>(); //Get data from inputs if (!DA.GetDataList(0, uocolumnpoints)) return; if (!DA.GetDataList(1, uotribareas)) return; //Error if number of points and areas are not equal if (uocolumnpoints.Count != uotribareas.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Unequal number of columns and tributary areas"); return; } List<Point3d> ocolumnpoints = new List<Point3d>(); List<Curve> ocurves = new List<Curve>(); List<Brep> otribareas = new List<Brep>(); double m_tol = 0.001; string unitSystem = Rhino.RhinoDoc.ActiveDoc.GetUnitSystemName(true, true, true, true); if (unitSystem == "m") m_tol = 0.000001; if (unitSystem == "mm") m_tol = 0.011; PointsInsideCurves pic = new PointsInsideCurves(); try { pic = new PointsInsideCurves(uocolumnpoints, uotribareas, m_tol); } catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, ex.Message); } failpoints = pic.FailedPoints; ocurves = pic.OrganisedCurves; if (failpoints.Count > 0) AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Some point(s) did not lie within a tributary area, were on the boundary/tolerance limit of of a tributary area, or multiple points were within the same tributary area. See output FP for the points that have failed"); foreach (Curve c in ocurves) { Brep b = Brep.TryConvertBrep(c); otribareas.Add(b); } //Pass data to outputs DA.SetDataList(0, ocolumnpoints); DA.SetDataList(1, otribareas); DA.SetDataList(2, failpoints); } //Grasshopper icon for component protected override System.Drawing.Bitmap Icon { get { return Properties.Resources.ColumnOrganiser; } } /// <summary> /// Gets the unique ID for this component. Do not change this ID after release. /// </summary> public override Guid ComponentGuid { get { return new Guid("{3259e465-5400-48e3-907b-fcb7455b12aa}"); } } }}
Helper class
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Rhino.Geometry;namespace Load_Take_Down_Tool{ class PointsInsideCurves { private List<Point3d> Points { get; set; } private List<Curve> ClosedCurves { get; set; } private double Tolerance { get; set; } public List<Point3d> FailedPoints { get; set; } public List<Curve> OrganisedCurves { get; set; } public PointsInsideCurves() { } public PointsInsideCurves(List<Point3d> Points, List<Curve> ClosedCurves, double Tolerance) { this.Points = Points; this.ClosedCurves = ClosedCurves; this.Tolerance = Tolerance; Evaluate(); } public PointsInsideCurves(List<Point3d> Points, List<Brep> ClosedBreps, double Tolerance) { this.Points = Points; this.Tolerance = Tolerance; List<Curve> Curves = new List<Curve>(); foreach (Brep b in ClosedBreps) { Curve[] c = b.DuplicateEdgeCurves(); c = Curve.JoinCurves(c, Tolerance); Curves.Add(c[0]); } this.ClosedCurves = Curves; Evaluate(); } private void Evaluate() { //Sorts in order of points //Naive implementation //Can update to KD tree if necessary List<Curve> OrderedCurves = new List<Curve>(); List<Point3d> fPoints = new List<Point3d>(); //Have to duplicate the input list of curves to modify as we go List<Curve> CCDup = this.ClosedCurves; foreach (Point3d Point in this.Points) { //Backwards loop to allow removal bool assigned = false; for (int i = CCDup.Count - 1; i >= 0; i--) { if (CCDup[i].IsClosed == false) { throw new Exception("Curve is not closed"); } if (CCDup[i].Contains(Point) == PointContainment.Inside) { OrderedCurves.Add(CCDup[i]); CCDup.RemoveAt(i); assigned = true; break; } } //If point not within any of the given breps put null in the list if (assigned == false) { OrderedCurves.Add(null); fPoints.Add(Point); } } this.FailedPoints = fPoints; this.OrganisedCurves = OrderedCurves; } }}
…
Added by Hugh Groves at 3:43am on September 30, 2014