variable. It's a short enough script for normal users, along with Stackoverflow and Google English language searches to debug in the future. Just try isolating the problem in a copy of the script, paring it down to a few lines that still fail the same way, then ask around, since then you'll likely only have a basic Python issue to figure out.
import Rhinoimport subprocess# TO MAKE THIS WORK, RIGHT CLICK RHINO.EXE AND OPENFLIPPER.EXE TO ACCESS THE PROPERTIES>COMPATIBILITY TAB AND CHECK "RUN THIS PROGRAM AS ADMINISTRATOR."# ALSO MAKE SURE TO EDIT THE OPENFLIPPER CORRECT VERSION NUMBER AND INSTALLATION PATH THAT I HAVE HARD-WIRED TO VERSION 3.1, BELOW.# Write an ASCII format STL file for the input mesh, for OpenFlipper to operate on:stl_file = open("C:/NIKS_OPENFLIPPER_PARSER_TEMP.stl","w")stl_file.write("solid OBJECT\n")Input_Mesh = Mesh # Let's not use the Rhino term Mesh in the script itself.Input_Mesh.Normals.ComputeNormals() # NITM ("Not In The Manual") but this is needed first.verts = Input_Mesh.Vertices # Get all vertices of the mesh from Rhino.for i,face in enumerate (Input_Mesh.Faces): # Rhino gives faces by vertex index number.stl_file.write(" facet normal %s\n" % str(Input_Mesh.FaceNormals[i]).replace(",", " ")) # Rhino gives normals!stl_file.write(" outer loop\n")stl_file.write(" vertex %s\n" % str(verts[face.A]).replace(",", " ")) # Rhino has ABCD properties for face vertex index numbers.stl_file.write(" vertex %s\n" % str(verts[face.B]).replace(",", " "))stl_file.write(" vertex %s\n" % str(verts[face.C]).replace(",", " "))stl_file.write(" endloop\n")stl_file.write(" endfacet\n")stl_file.write("endsolid OBJECT\n")stl_file.close()# Generate an OpenFlipper script on the fly in order to alter settings not accepted on its command line:openflipper_script = open("C:/NIKS_OPENFLIPPER_PARSER_TEMP.ofs", "w")openflipper_script.write("core.loadObject(\"C:\\\\NIKS_OPENFLIPPER_PARSER_TEMP.stl\")\n")openflipper_script.write("id = core.getObjectId(\"NIKS_OPENFLIPPER_PARSER_TEMP.stl\")\n")openflipper_script.write("remesher.uniformRemeshing(id,%s,%s,%s,true)\n" % (TargetEdgeLength, Iterations, AreaInterations))openflipper_script.write("core.saveObject(core.getObjectId(\"NIKS_OPENFLIPPER_PARSER_TEMP.stl\"),\"C:\\\\Out.stl\")\n")openflipper_script.write("core.exitApplication()\n")openflipper_script.close()# Windows command line execution of OpenFlipper with argument to run our script:OFS = "C:/NIKS_OPENFLIPPER_PARSER_TEMP.ofs"subprocess.call(['C:\Program Files\OpenFlipper 3.1\OpenFlipper.exe',OFS]);# Read in the OpenFlipper output STL file back into Grasshopper:mesh = Rhino.Geometry.Mesh() # Initialize "mesh" variable as a blank mesh object to hold each face.MESH = Rhino.Geometry.Mesh() # Initialize "MESH" variable as a blank mesh object to accumulate faces.with open("C:/Out.stl") as f: for line in f: if "vertex" in line: q = line.replace("vertex ", "") q = q.replace("\n", "") q = [float(x) for x in q.split()] mesh.Vertices.Add(q[0],q[1],q[2]) # Fill mesh with three vertex lines in a row. if "endloop" in line: # File itself tells us we are done with three vertices for one face. mesh.Faces.AddFace(0,1,2) # Create a single face mesh. MESH.Append(mesh) # Magically build a real multi-face mesh while removing redundant vertices. mesh = Rhino.Geometry.Mesh() # Reinitialize empty mesh object for each mesh face.MESH.Normals.ComputeNormals() # Gives nice mesh and preview but makes the script take longer.…
Added by Nik Willmore at 4:32pm on October 9, 2017
use Kangaroo2 and Anemone together.
I've looked an example shared by Daniel Piker here:
http://www.grasshopper3d.com/forum/topics/differential-growth-in-curves?id=2985220%3ATopic%3A1313465&page=2
Please find the two Grasshopper files attached:
Differential Curve With Kangaroo2
The first draws a line on a rectangular surface and makes it curve more and more to fill the surface. This one only uses Kangaroo2: it has a X number of divisions and fills the space as you increase the line length multiplier. This results in very fine squiggles that get bigger and bigger, that can fill a given surface.
NB:
-It's best to reset after changing anything (except "Spring Length Multiplier")
-The "Spring Length Multiplier" should be set to 1.00 before every reset
-Increase "Spring Length Multiplier" slowly to avoid kinks.
-Kinks can be ironed out by moving the "Spring Length Multiplier"
Differential Curve With Anemony & Kangaroo2 (WIP)
In this case I'm trying to generate my curve's squiggliness in a slightly different way. I'm essentially trying to use the same script as above, but use Anemone to generate the curve.
This is drawing a line, and using Anemone to keep breaking it, and subsequent segments, in half based on a counter attached to the loop start.
I want to bake each iteration, so I need the squiggliness to increase smoothly. However when I increase the division count, the curve jumps around and folds on itself and I'm not sure why.
For this script, I imagine that I'll be increasing squiggliness with the division count on the loop start, and my spring length multiplier should have a relationship with division count, but I'm not sure what that relationship should be.
I'm also not sure which Kangaroo solver to use and why. Maybe StepSolver?
How can I edit this script so that my curve squiggles smoothly? Many Thanks, Nick…
ulting topography, I just wanted it to be reasonably close so it looked appropriate as context. That sort of drives the rest of it (OSM).
Even though the earth is not truly a sphere, I treat it as one for the purposes of calculating distances in Elk. So the first step for both the SRTM and OSM translations is to figure out the length of one degree and use that number against the coordinates to determine the position in the XY plane.
Latitude:
The circumference of a circle is 2πr. The circumference of the earth is about 6371000m so you get about 40 million meters for the circumference. Further convert that to a distance per degree and you get around 111,194m or 364,812'. (PI * EarthRadius) / 180 gives you the degree length in meters and multiplying it by Y was just scaling it to feet. Since circumference is 2πr, another way to write the formula would be (2 * PI * EarthRadius) / 360.
Longitude:
Longitudinal lines converge at the poles so their distance at the equator is the same as latitude (111,194m per degree), but converges to 0 as it gets closer to either pole. Technically this means that the farther away from the equator you go the points should be slightly closer together. I'm just getting an average distance for the points, so I get the median latitude degree in order to determine the radius of the earth sphere at that distance.
Then you subtract the lower end of the domains from the CSV's longitude and latitude, and then multiply the resulting decimal number by the calculated lengths for a degree in longitude and latitude and those numbers are combined to be the X and Y coordinates of the points.
Hope this helps.
-Tim…
it than just syntax. Specifically I would highlight two major differences:1) C# is statically typed, Python is dynamically typed. See this thread. "Generally" this means that Python will be more terse (easier to read, faster to write) which might increase productivity, at the expense of being slower to run than C# and potentially harder to debug on a large projects.2) C# is tied to Windows /.NET, Python is multiplatform. The Rhino/Grasshopper SDK's are highly .NET-based and thus play very well with C#. That said, the version of Python that is used in Rhino is called IronPython. This is the .NET implementation of Python which enables you to use the .NET framework.Ultimately it all depends on what you need to do and how your brain is wired. If you're building a larger project like Kangaroo I would probably recommend C#. If you're developing a design model in the context of an architecture project, where quick turnaround and responding to changes is key, I would probably recommend Python. Perhaps check out a few introductory tutorials (Youtube has loads), I bet one language will immediately seem more intuitive to you than the other. One shouldn't forget that it's also about enjoying coding. If your brain is getting in the way of this, perhaps consider another language in which to express yourself :)Edit, a few fairly objective opinion pieces on the subject:http://www.quora.com/How-does-Python-compare-to-C/answer/Alex-Yakun...http://www.codemag.com/Article/1407051http://onstartups.com/tabid/3339/bid/128/Python-vs-C-Business-and-T...…
s.
So do I, I found the flaw and it fails on a big scale XD.
I was aware that my sorting method will fail if the frames are in or parallel to the 'YZ' plane because all the 'X' values will be the same (warning!)
And it did.
I'm sure there's a better method that won't ever fail but I didn't find it in the limited time I had.
Yeah, I figure it out, so far all 9600 frames were baked properly.
You must have changed something somewhere?
Yeah, I must have tweaked it and saved it as it was. Sorry, my bad.
I believe the problem here is caused by the assumption implied by the sequence of four 'Orient' and 'Rot3D' components, each with a fixed angle input. Can't help wondering if there is a better way to do that?
Yeah, I wish there was a better and more parametric way of doing that, guess this is where some coding would be really helpful. So far I made it work flawlessly. Maybe I will try to improve the whole definition later on.
But hey, it works now so it's academic.
Totally, Peter helped me realise why such approach and methods I used may cause hypothetical clients spend gazillions on realizing it. The project was very interesting to work with and I've learned a lot. And thank you and this forum for incredible help. I'm going to keep my work on it, it is not finished yet, maybe you will hear from me soon XD
Method I used works like a clock (literally)). I build an arc from the rectangle's centroid and the first point it encompass becomes THE first point in the list, then second point becomes #2 etc, so it should work with any polygon. And all the points get rearranged sequentially.…
my script) and I want the entire waffle model to be held by a 4mm MDF. For that reason I decided to make voids for either the x-direction sections or the y-direction sections, that doesn't really matter to me. My idea is to offset the curve a bit inwards so that the 4mm MDF won't be cut all the way through. This is my aim. However, I did it here with Rhino and not with Grasshopper.
I've tried few approaches:
1) Deconstructing the brep which holds the y-sections and trying to extract only the bottom surface which I would then extrude 4mm in minus Z direction. Finally I'd use boolean difference between the 4mm MDF holder and the sections.
2) Move the surface a bit upwards in Z direction, so that it intersects properly the sections. Intersect sections with the given surface. Take the intersections, project them onto the 4mm MDF holder and somehow make voids.
Interestingly enough I couldn't cope with either of them. Hope someone would find a solution to my problem.
I try to keep my code tidy but please keep in mind that since I'm a newbie it might be slow and irrational.
P.S. I highlighted the MDF holder and the sections with light green in the Grasshopper file.
…
Tetrahedron: 24 Symmetries
Pyramid: 8 Symmetries
Design space = 24 X 8 = 192 permutations
So I decided to write a simple orientation script to iterate over all permutations. And this is the result. Below are some technical notes.
I used the vertices of the shapes for creating a 3 point plane, and used it for orientation.
I used compound transform to combine multiple steps of transformation.
The cross reference component is very handy, generating all the possible combinations without worrying too much about data tree.
The spatial relationship and the basic grammar A -> A + B and B -> A + B
The basic grammar and possible marker positions.
All results in 6 iteration steps
All results in 6 iteration steps (Top View)…
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?
…