the data structure of the input.
I'll create a component that aims to write all the GH_Paths inside the input data structure into separate output parameters. I'll add a menu item to the component that allows users to synch the number of outputs with the current data.
Note that there are some bugs I found related to Undo here, but I'll attempt to fix those asap. The mechanisms employed in this example are correct.
Let's start with the Component class definition and the constructor:
Public Class GH_ExampleComponent_VarOutput
Inherits GH_Component
Public Sub New()
MyBase.New("Extract Paths", "ExPath", "Extract all the paths from a tree", "Sets", "Tree")
End Sub
End Class
Now, the RegisterXXXXParams methods:
Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_Component.GH_InputParamManager)
pManager.Register_GenericParam("Tree", "T", "Data tree to examine", GH_ParamAccess.tree)
End Sub
Protected Overrides Sub RegisterOutputParams(ByVal pManager As GH_Component.GH_OutputParamManager)
'We'll add one output parameter, just to not have a jagged output.
pManager.Register_PathParam("Path 1", "1", "1st path in tree")
End Sub
SolveInstance() is somewhat special, but not very complicated:
Protected Overrides Sub SolveInstance(ByVal DA As IGH_DataAccess)
'We have only one input parameter and it is set to Tree,
'so SolveInstance will only be called once for every solution.
'We don't actually need the data inside the input, we're only interested in the paths.
'So we don't actually need to call DA.GetDataTree, we can just go in and extract the
'paths directly:
Dim paths As IList(Of GH_Path) = Params.Input(0).VolatileData.Paths
'Abort if there is no tree.
If (paths.Count = 0) Then Return
'Post a warning if the number of output parameters does not
'equal the number of paths in the tree.
If (paths.Count < Params.Output.Count) Then
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "There are more outputs than paths in the tree.")
ElseIf (paths.Count > Params.Output.Count) Then
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "There are fewer outputs than paths in the tree.")
End If
'Iterate over all paths and assign to output parameters.
For i As Int32 = 0 To Math.Min(Params.Output.Count, paths.Count) - 1
DA.SetData(i, paths(i))
Next
End Sub
Adding a menu item to the component menu is relatively straightforward, however handling the menu command requires a fair bit of logic:
Protected Overrides Sub Menu_AppendCustomComponentItems(ByVal iMenu As System.Windows.Forms.ToolStripDropDown)
'Add a single item to the component menu.
Menu_AppendGenericMenuItem(iMenu, "Synch outputs", AddressOf Menu_SynchOutputClicked)
End Sub
Private Sub Menu_SynchOutputClicked(ByVal sender As Object, ByVal e As EventArgs)
'Here we have to synch the number of output parameters with the number
'of paths in the volatile data tree in the input parameter.
'This requires a few steps:
'1. Determine whether something needs to happen at all.
'2. Record an undo event.
'3. Remove excess outputs or add missing outputs.
Dim paths As IList(Of GH_Path) = Params.Input(0).VolatileData.Paths
If (paths.Count = Params.Output.Count) Then Return 'yay, nothing needs to be done.
'Something needs to be done, record an undo state.
RecordUndoEvent("Synch output")
'We either have too few or too many outputs, determine which is the case.
If (paths.Count > Params.Output.Count) Then
'Add the missing outputs
For i As Int32 = Params.Output.Count + 1 To paths.Count
Dim param As New Grasshopper.Kernel.Parameters.Param_GenericObject()
param.Name = "Path " & i.ToString()
param.NickName = i.ToString()
If (i.ToString.EndsWith("1")) Then
param.Description = i.ToString() & "st path in tree"
ElseIf (i.ToString.EndsWith("2")) Then
param.Description = i.ToString() & "nd path in tree"
ElseIf (i.ToString.EndsWith("3")) Then
param.Description = i.ToString() & "rd path in tree"
Else
param.Description = i.ToString() & "th path in tree"
End If
Params.RegisterOutputParam(param)
Next
Else
'Remove excessive outputs
Do
If (Params.Output.Count <= paths.Count) Then Exit Do
Dim param As IGH_Param = Params.Output(Params.Output.Count - 1)
Params.UnregisterOutputParameter(param)
Loop
End If
Params.OnParametersChanged()
ExpireSolution(True)
End Sub
Finally, we must make sure that the component properly (de)serializes. This means we have to override the Write and Read methods and add additional information to the GHX archive:
Public Overrides Function Write(ByVal writer As GH_IO.Serialization.GH_IWriter) As Boolean
'We must make sure that the number of output parameters is correctly stored.
'We'll use a special function on the GH_ComponentParamServer to accompish this
'without too much sweat.
Params.WriteParameterTypeData(writer)
Return MyBase.Write(writer)
End Function
Public Overrides Function Read(ByVal reader As GH_IO.Serialization.GH_IReader) As Boolean
'Very important, we must make sure all parameters exist before we
'start with the main deserialization.
Params.Clear()
Params.ReadParameterTypeData(reader)
Return MyBase.Read(reader)
End Function
I attached a VB file that contains the code outlined above.
--
David Rutten
david@mcneel.com
Seattle, WA…
Added by David Rutten at 11:43pm on October 27, 2010
e= -3
e = -4
Setting exposure values is a "post-processing" thing done to improve the display of the image on a device or photograph. So, your analysis will still be physically based. I think towards the end of his video Mostapha talks about how the exposure values can be set through Honeybee....
…
by anything else (like walls, ceiling etc.). So, specifying ambient parameters in the simulation does not serve any purpose.
2. Get rid of source subdivision by setting -ds to 0. This will make Radiance assume that your source is a point source ( which seems to be a valid assumption in your case).
3. Finally, you can cut down the time even more by magnifying the candela value of a single light fixture instead of using the 9 fixtures that you have right now. This is a hack, but will work because that way, even the deterministic part of the calculation will feature only 1 variable instead of 9. You can make this work by increasing the candelaMultiplier of that one source by 9.
I have attached a gh file (which shows the parameters options) as an example. The points I have made above will mostly work for electric lighting only. Daylighting needs different kind of optimization because we are dealing with parallel rays from the sun and not a source with directional distribution like electric lights.
The image below is base-case. Takes the maximum time, using default settings.
This one is with direct-only calculations.
This is the case where a single fixture was used and the candela multiplier was used to magnify it's brightness 9 times. Took the least amount of time....but as you can there is a perceptible difference between this one and the base-case.
…
he time to work with it.
the project is about facade strips which turns along height. the top angle is
parallel to the facade and the bottom is max. 90 degrees twisted, but the strips
should turn diffrently to achieve more dinamic look.
first i have tried to achieve this by calculating distance between the rotation angle from points of the grid and a single point.
then i have tried to ad some more effecting points and used the distance to the divided surface (the circles are just to control the area of effection):
i manually lofted it.
the result is a bit annoying becouse the points that effect the angle are always visible:
i have triend to solve this by drawing a line and divided it to recieve points along the bottom of the geometry. the result is not working properly:
Anyway,
there must be a better/smoother way to achieve this. i would like to effect the twist of the surfaces by distance to a spline, but im just lost. can you help me please?
the problems im encountering:
0- distance spline to grid to effect the angle
1- list of x/y coordinates and angle of rotation for each point of the grid
2- export points to excel
3- lofting lines in one direction only (x1, x2, x3...)
4- reduce the list data to 2 decimal (0,00)
5- maybe angle from radian to degrees
thx…
he process. The last one is there because fixing it would cause another problem, which we feel is more serious. Solutions may well be forthcoming in the future though.
1. Grasshopper curves and points are drawn more towards the camera than they really are. This is a conscious decision. Often Rhino geometry and Grasshopper geometry exist in the same place. If we would draw the Grasshopper preview in place, then there's no telling whether you'd see the Rhino curve or the Grasshopper curve. We feel it's important that you always see the Grasshopper curve on top. This is why we draw all curves and points slightly towards the camera. However we don't do this for meshes. This results in something akin to the image below. The eye represents the location of the viewport camera, the shaded box represents the actual location of the geometry and all the thick black lines represent the edges of the geometry moved towards the camera. As you can see, the red lines will be visible, even though they should be behind the shaded box. This effect can get very strong when the camera is close to some geometry relative to the size of the boundingbox of all geometry.
2. Wires behind the camera are sometimes visible. This is a bug I don't know how to solve. We'll get around to it eventually. When an object is behind the camera the display transform sometimes makes it visible in front of the camera in some weird inverted perspective mode.
3. Meshes are not z-sorted prior to display. This means that the order in which they are drawn is not back-to-front, but fairly arbitrary. This means that a transparent mesh may appear to punch a hole in the mesh behind it. If this is annoying you to no end, you can use Ctrl+F on the Grasshopper components that contain the meshes that are punching holes and then press F5 to recompute. The draw order should now be different. Of course sometimes it will only 'fix' it for a specific camera angle.
--
David Rutten
david@mcneel.com
Poprad, Slovakia…
try to optimise the form maybe will use Rhino Phyton... I will try to continue this script to pass trough potential method, which will modify the hull shape, and get the optimum shape. For now there is a problem with that Open Foam works only on linux and I am looking for other free alternative for CFD.. Just to investigate the resistance fast, so to deform and modify the shape... Later with the deformed shape will do 3 passes with deform, compare, deform with fast potential solver. And the last two shapes which I liked could pass trough viscous solver so I can compare the difference, cost, performance, production. Does somebody know such free potential code for windows I could try? After getting free CFD code. IDEA: The question will be how to connect them (the outputs of CFD with deformations in Rhino) so taking PressureXYZ vector fields from CFD, in table with coordinates for each point and amount of deformation in each direction putting them in Rhino (in scalar form in table with position of the control point amount of deformation and direction. So using Rhino nudge comands to deform the body. Deforming the hull using the control points, or control curves with soft body deformation. Maybe there will be a high dense cage where is the higesht point in the table and soft deforming proportionally the rest points. There sould be two limiting lines (which user will specify in top view) up to where the deformation can be done, for the cylindrical part. So the curvature should smooth with g2-g3 curvature up to this meeting points of optimised stern, bow with the cylindrical left alone part. At the end there will be optimised hull form for lowest Pressure = Resistance in some constrains (limiting lines for the untouched cylindrical part for example) for current LBD and displacement. With possibility to get linesplan.. Later time begining shape can be connected with Tables with emperical or statistical formulas from the rules for specific ship. If somebody wants to join this quest is more than welcome
Here is an example picutre which will show me where do dig, and where to put material for the deformation of the body: …
r ideal surface so they add up where lots of points or lines cluster and create rather unintuitive bulges form a 3D modeler's perspective, here done with Millipede's Geometry Wrapper:
I've learned to do marching tetrahedra or cubes in Python to create the surface as needed from a implicit ( f(x,y,z) = 0 ) mathematical equation based on raw trigonometry but am not yet sure how to define an equation for Rhino user created input items like this or find a way to make marching cubes accept such input let alone one that doesn't treat each geometry item as an electric charge with so little decay.
This would afford an old school "organic" modeling paradigm that T-Splines replaced, but the T-Spines pipe command can't do nearby lines right either, which just makes overlapping junk. Metaballs and lines are not as elegant in that there is a real "dumb clay" aspect to the result that affords little natural structure beyond just smoothing, but still, if it works at all that beats T-Splines, and then I can feed the crude mesh result into Kangaroo MeshMachine to afford surface tension relaxation that will add elegant form to it.
I need both quick hacks and some help on how to deeply approach the mathematics of the required isosurface, now that I can think in Python better than ever.
I got a hint the other day here, about using a different power of fall-off but am not sure how to do the overall task mathematically:
"and just as with point based potentials, one can use different power laws for the distance, function, resulting it different amounts of rounding at the junctions. Below is with a 1/d^3 law for comparision with the above 1/d" - Daniel Piker
http://www.grasshopper3d.com/forum/topics/meshes?commentId=2985220%3AComment%3A1324050
He also included this link about bulging:
http://paulbourke.net/geometry/implicitsurf/
Am I supposed to create an actual implicit equation for my assigned points and lines and use that with marching cubes to surface it? If so, how do I define that equation, at all, and then how to control bulging too?
…
t;Custom additional code> Bob[] b = new Bob[] {new Bob(1), new Bob(2), new Bob(3)};
class Bob{....
}
//But how to make something like this in a loop?
// <Custom additional code>
Bob[] b = new Bob[10];
for(int i = 0; Bob.Length; i++){
b[i] = new Bob(i);
}…
housing for an LED PCB. The object is a parametric series of discs with an opening inside made up of a mirrored curve [drawn in Rhino, mirrored in GH]
It is madde up of N number of discs which can be varied through the distance between the circular outline using a divided curve [straight line in GH]. The length of the object can be varied using a length parameter, and the shape using a graph mapper.
I've chosen to cap the end two discs by creating two sets of outlines. One set has the central aperture cutout for the PCB, whereas the other set is a trimmed circle [achieved using the "trim box" layer profile in Rhino]
I then cull the outer two curves from one array, and the inner N-2 curves from the inner array.
The final outcome I am after is to create the housing as both an STL and a 2d template for laser cutting. This is a learning exercise for me as well as a cool project.
I had it working OK, but then I adjusted the profile for the PCB and joined it and now it is giving me some grief. I am sure the answer is obvious. The problem is the PCB profile is made up of 3 polycurves, whereas the disc profile is one planar curve. I have no problem using the flatten option so there are only N sets of curves coming out of the "Join Curves" component. However when I cull the curves, the planar curves making up the exterior edge cull fine, but the interior curves [the joined, PCB profile] culls in a different [irrational?] order to what I would expect. If I connect the single planar curve to the culls section, it works fine, but the joined line section just won't play.
In the instance uploaded N = 10, based on spacings. And index white it appears that 0 and 9 are diagonal to what I'd expect, although if you fiddle with the values they go all over the place.
Can someone please help me and explain what I did wrong? Files are attached... I have screen grabbed the relevant section, but it is grouped in red and labelled as "problem child" :)
Many thanks for your help, sorry if this looks like a clusterf**k, first time for everything... any advice very much appreciated, not just relating to my problem.
All the best
Nick…