Orienting Objects to Polyline Corners

Hello,

I’m very new to grasshopper. I’m trying to write a basic piping script for myself now but I’m struggling a lot. I’ll try to explain how I constructed it in my mind as best as I can. Any help/advice etc. will be much appreciated.

My goal is to write a script so by only making a polyline and choosing the right diameter, pipes and fittings will be automatically baked. All fittings are seperate 3dm files which will be imported from the library I made.

-First problem is 3dm files are saved as blocks but when I import and bake them, they get exploded. How can I import them with block their block attributes?

-I guess the most compelling thing for me so far is to orient the object at the corners of the polyline at the correct angle. I added circles to the both ends of the fittings and orient them to the end of the pipes I think I’m getting closer but it still doesn’t work as intended.

-And I don’t know how to combine multiple statements to bring the correct object to the correct place. I tried adding an if statement and it works when I use it only based on diameter. But what I’m also trying to add fittings for different angles as well and this complicates things for me. For example, If it’s 90 degrees turn at DN32, it should bring DN32-90° block. If it’s 45 degrees turn at DN40, it should bring DN40-45° block etc.

So far only thing that’s working as I intended is the pipes themselves although I’m sure there are easier and more practical ways than what I did. I’m attaching the script I created and the fitting files I have some everyone’s welcome to check it.

Thank you,

Pipe.gh (17.0 KB)



cunim25el45.3dm (544.6 KB)
cunim25el90.3dm (596.0 KB)
cunim32el45.3dm (580.0 KB)
cunim32el90.3dm (207.8 KB)

Well … for a start see the attached: is Part1 of a 5 phase tutorial for my people in the practice related with the 1B question: why to use instance definitions and how to make/place/manage them. NOTE: no values combatibility check is included (that’s in Part 2).

Brep_TubesAndConnectors_EntryLevel_V1.gh (122.2 KB)

Part 1 is used solely for understanding the problem (hideous delays if you skip the instance definition approach). For intance 8000 mseconds (mama mia) just for a 100 axis test:

Part 1 Is using a random demo routing (but it could use an existed routing as well).

So the pro solution is either to use existed instance definitions OR be far more flexible and create them on-the-fly (and/or store them in some sort of “library” files) and then place them with classic Plane to Plane transformations.

This means that: (a) the plane where the instance definition is defined MUST be a standard one (Plane.WorldXY is used in most of similar cases), (b) the target plane MUST match the instance plane.

Tip: given a routing let’s call prev the previous segment and curr the current. These yield a fillet Arc (if possible). Let’s call prevDir the -prev.Direction and currDir the curr.Direction.

If vY is the CrossProduct(prevDir, currDir) and orig is the fillet.StartPoint then your target plane for the angle tube placement (Plane to Plane trans) is: new Plane(orig, ProjectVectorToPlane(currDir,tmp), vY) - where tmp = new Plane(filletStartPoint, prevDir).

Then this “seed” object (at Plane.WorldXY):

Is placed (a copy of this in fact) around using planes defined as above.


BTW: With regard placement of angled tubes, the attached does the target planes for a given List of polylines. Random examples are used (useless in real life) but … the gist of the approach is rather clear: each target plane has the XAxis coplanar with the next segment direction. Meaning that the base object MUST have the arc in the Plane.WorldXZ (the from plane for the plane to plane trans is the Plane.WorldXY).

Brep_TubesAndConnectors_TargetPlanes_V1.gh (124.7 KB)

4 Likes

Hi,

Thank you so much for your explanation. Although I have to say I have zero knowledge about coding. But I think I understood the idea behind your script and by using the second attachment I managed to place the objects correctly when I saved them aligned in XZ Plane.

But my other question remains. How can I arrange it so it will orient object 1 to the target plane if the fillet angle is 90 and orient object 2 if the fillet angle is 45? I’ve tried using stream filter by feeding it values from FilletAngleTree output but I guess this only work with single input so nothing happened.

Also you mentioned a 5 phase tutorial. Can you elaborate on that please? Can I access these tutorials in more detail?

Again thank you so much.

Edit: Never mind I found a solution right after I posted this.


How do I get all 5 tutorials?

I have closed the practice due to the China thingy (and I’m in extended vacations far and away from base). Is rather unclear at present time when it could be functional again.

But … you said that you have zero C# knowledge … so what could the remaining 4 serve for? Anyway see my answer above (no practice, no honey).

BTW: given the opportunity … in an ideal world (where everyone speaks C#) the solution has as follows: create an “evolving” combo of C#‘’'s where:

  1. if your data point to an existed - standard or custom - angled tube (or any pipe work related part like special 2-part Foamglas fire insulation stuff etc etc) then load it and place it (as instance definition).

  2. if not define on the fly the new part (and/or use transformations on some similar) store it and then place it.

So after a couple of days (if you do that type of pipe work day in day out) you’ll have a rather big “library” of real-life parts … blah, blah,

But if you are after pro level pipe work … you date the wrong girl (R/GH are NOT the apps to use by any means):


I just work on pipings of small boats and I’m in no way after pro level piping atm. These have very simple schematics so I was just looking for a way to reduce the man-hour I’m putting on 3D modelling of the pipes which takes longer time than it should. And it’s kinda fun to work on grasshopper :slight_smile:

I guess right now, the best approach for me would be to create my own library since I’m not using that many different parts already.

Thank you for taking your time.

Well … this type of fun is not my type of fun (at least for similar works) but anyway.

Get V1A with a “minor” bug fix: I forgot this %#$#% simple question marked below (case polylines with only 2 segments). That was VERY stupid from my part - blame vacations and the likes.

Brep_TubesAndConnectors_TargetPlanes_V1A.gh (127.1 KB)

1 Like