[Grasshopper Tutorial] Pipe Generator

 This time, we will create a pipe based on an arbitrary polyline and acquire the length, quantity, number of elbows, etc. of the pipe. 

It may be confusing for beginners, but you need to have a solid understanding of data trees. Also, this time I implemented it without using plugins, Python, C#, etc., but there are places where it would be easier if I wrote a script. 

I think there are many more efficient ways, so please try to modify it yourself.

Overview

[Grasshopper Tutorial] Pipe Generator

The above image is the overall image of the program. I will explain each block separately.

Generate base polyline

  1. First, generate a Polyline with RhinocerosThis time, I'm going to implement a 75Φ pipe, so I feel that each side should be 400mm or more. Please be careful not to make the scale too small. The program will be put together so that it can be handled.
  2. Go to Grasshopper and set it to the Curve component.

get corner position

  1. Since the corner material (elbow) will come to the corner part, we will acquire its position.
  2. Explode the polyline into straight lines with the Explode component.
  3. Get the length of the line with the Length component.
  4. This time, we want to join at points that are 100mm from the corner position, so we will get two values: 100mm ÷ (straight line length) and (straight line length - 100mm) ÷ straight line length. These two values ​​are the positions 100mm back from the start and end points when the start and end points of the straight line are 0 to 1.
  5. Prepare two Evaluate Curve components and connect the polylines split by ReparametrizingConnect the position 100mm from the start point of the straight line obtained earlier and the position 100mm from the endpoint to obtain the actual point.
  6. The points obtained by the Weave component will be made into one list. For Pattern, right-click Set Multiple Integer and enter "0,1,2". Connect the start point from the explode component to 0, the position 100mm from the start point to 1, and the position 100mm from the endpoint to 2.

Get Piping Centerline

  1. Generate the pipe centerline from the list of points created earlier. Return to the initial state again with the Polyline component.
  2. Bend the corners with the Fillet component. The radius is 100mm because we got the position 100mm from the corner.
  3. Here comes the problem. If the first curve you set is a straight line, the Fillet component will not work and will throw an error. So, I'll use the Stream Filter component to devise it.
  4. If the first curve you set is a straight line, of course, you will get a Linear Curve from the Polyline component instead of a PolylineCurve. For now, let's replace the output terminal of the Polyline component with the Replace Text component with "Linear Curve" ⇒ "This is Linear Curve".
  5. Get how many "This is Linear Curve" texts are in the List with the Member Index component. If this value is Polyline, it will be 0, and if it is a straight line, it will be 1. We will use this value.
  6. Connect N of the Member Index component to the Gate of the Stream Filter component. If 0, filleted polylines will be output. In the next section, we will generate a straight line that is output at 1.

if it was a straight line

  1. If the first curve you set was a straight line, you might think that you could simply connect the first Curves component to the Stream Filter component, but that's not the case this time. As you will understand later, this time I will write a program that will install joints when the length of the pipe exceeds a certain length. If the vertices of the set straight line are not only the start and end points, but also have vertices in the middle, it will be inconvenient. I'm going to write.
  2. Get the start and end points with the End Points component and initialize the straight line with the Line component. Connect this to the 1 terminal of the Stream Filter component.
  3. Now, if the first curve is straight, the centerline of the pipe will be returned as a straight line, otherwise, a filleted curve will be returned.

Acquire points longer than a certain length

  1. Even pipes have a standard length. In this case, we want to add a joint when the length is longer than a certain amount, so we will acquire a straight line longer than the specified length.
  2. Split into straight lines and arcs with the Explode component.
  3. Gets the length of the straight line/arc divided by the Length component.
  4. Gets whether the length obtained by the Larger Than component is greater than 1000mm as a Boolean value. For this 1000mm, try inserting the standard length of the target material.
  5. Gets the Index number when True in the Member Index componentCreate a Path with the index number obtained by the Construct Path component. Let's Graft the input value and Simplify the output value.
  6. Connect the Entwine component to the Explode componentThe Entwine component is used in Graft to generate a Graft - simplified divided curve at {0;x} and the Panel component at {1;x} to generate dummy data as appropriate. I'll explain later why I do this.
  7. Flatten the output value and Graft it again with the Graft componentThe reason for doing this is to clean up branch numbering.
  8. Gets the branch that stores a straight line of a certain length or longer from the data tree connected by the Split Tree component. From the output terminal P, you can get branches that store straight lines longer than a certain length, and from N you can get straight lines and arcs that are not.
  9. The reason why I provided dummy data earlier is that the Split Tree component will not work if the first set is a straight line. If it is a straight line, even if it explodes, it is still a straight line, so the value is 1. Even if you search for it with the Split Tree component, it will not be searched. Therefore, I dare to set dummy data so that there are at least two branches.

Get joint position

  1. Divide the straight line of 1000mm or more obtained earlier with the Divide Curve component.
  2. Get the length with the Length component.
  3. Divide the length obtained by the Division component by 1000mm (value such as the standard length of the material specified earlier) and divide it by the rounded-up value with the Round component.
  4. The Shatter component cuts a straight line of a certain length or longer with the dividing point position parameter obtained by the Divide Curve component. Simplify the output port.
  5. Use the Merge component to merge curves that are not longer than a certain length and straight lines that are divided by a certain length, and flatten them.
  6. The dummy data created in the previous section is in the way, so delete the -1 position with the Cull Index component to erase the dummy data.
  7. Join curves with the Join Curves component.

Generate Piping

  1. For the curve in the split state before joining with the Join Curves component, use the Perp Frames component and specify 1 for Count to get the plane perpendicular to the curve at the start and end points.
  2. Generate a circle on the plane obtained with the Circle component. I want the radius to be the radius of the pipe, so I set it to 37.5mm, which is half of 75Φ. Flatten and simplify the output terminal.
  3. Get the 0th value in the List Item component to get the circle at the starting point of the entire curve.
  4. Extrude a circle using the piping centerline output from the Join Curves component in the Sweep1 component as a rail. For the time being, the piping part is completed.

Creating joints and joints

  1. Offset the circle generated earlier with the Offset Curve component. 7.5mm offset to the outside.
  2. The Entwine component stores the before and after offset circles in separate branches.
  3. By flipping the matrix with the Flip Matrix component, each corresponding circle is stored in a branch.
  4. The Boundary Surface component spans the surface between before and after the offset.
  5. Now offset the surface generated by the Offset Surface component in the direction of the pipe. This time, offset appropriately by 5mm.
  6. Get the edges of each surface before and after the offset with the Brep Edges component.
  7. The Ruled Surface component spans the surface between edges.
  8. Combine the surfaces of joints and fittings with the Merge component.
  9. Finally, the piping section and fittings/connections are combined with the Merge component to complete the process.

Piping data acquisition ① (diameter)

  1. Now let's get the data. First, get the diameter of the pipe. This is easy, isn't it?
  2. Since you're using the radius of the pipe, just double that.
  3. For the convenience of creating thumbnails, I wanted to bake the information to Rhinoceros, so I converted it to text and used the Concatenate component as ""Pipe_Size=>" + "75" + "Φ" as a string "Pipe_Size=>75Φ" is getting

Piping data acquisition ② (length, number of corners)

  1. Bring the centerline of the pipe before joining with the Data componentLeave it flattened.
  2. Use the Replace Text component to replace the corner (Arc-Like Curve) of the Data List with the text "This is Pipe corner".
  3. Get the Index number of the list that replaced "This is Pipe corner" in the Member Index component.
  4. If you delete the index number data obtained with the Cull Index component, only the straight part will remain. By getting the length with the Length component, you can get the length of each pipe.
  5. For thumbnail reasons, I chose "Pipe_Length: ○○ mm"
  6. If you get the Arc part with the List Item component, it will be a list with only the corner part. Get the quantity in the List Length component.
  7. For the convenience of the thumbnail, I get it with the character string "Num_of_Pipe_Corner => ○○".

Complete

Finally, the character string obtained by the Text Tag 3D component is converted to a text object and pasted on Rhinoceros. The mess in the middle is simply writing where to paste, so I will omit it.

Next Post Previous Post
No Comment
Add Comment
comment url