Simple Pipe Network using Primitive Shapes

311
0
02-18-2021 03:02 PM
BrianWamsley
Occasional Contributor II
0 0 311

Just wanted to share a CGA rule that creates a simple pipe network from the street network using primitive shapes.  Think pipe and ball-joint style.  I didn't see anything on this, but I hope I'm not duplicating effort.  Only attribute is the diameter in meters. The pipes are colored yellow and untextured. The joints/junctions are used to insert a primitiveSphere to make it look more connected.  The pipe network (street network) must be curveless, any curves will disorient the shape creation method (maybe a insertAlongUV method could be in the future that would adjust for curve).  However, curves can still be replicated by smaller straight edges.

Having the correct shape parameters is important to making this rule work:

BrianWamsley_0-1613686793311.png

The street width gives an initial shape from which to launch a primitiveQuad from which to base the cylinder scope.  The street width needs to be smaller than the diameter of the pipe or you will the shape stick out from the inside, and the street width does not effect the maximum scope size but it does bring the minimum scope size up.  The min arc radius needs to be "0" to bring the pipes as close to joint as possible.

The initial start shapes are "Lines" for the pipes, and "Joint" for the intersections.  Hopefully it works from initial application to the street network but if not, create a line with these settings, set it to a new graph default setup and go from there extending the network.  

 

 

version "2020.1"

attr diameter = .4

@StartRule
Line-->		color("#ffae42")
			primitiveQuad	
			Plane	

Plane-->	extrude(diameter)	
			Pipes	

Pipes-->	alignScopeToGeometry(yUp,0,longest)
			center(xyz)	
			rotateScope(0,0,90)	
			primitiveCylinder(32,diameter,scope.sy)		
			//t(diameter,0,0)
			
########################################################	

Joint-->    color("#ffae42")
			comp(fe){1:BallMaker}

BallMaker-->
			center(xyz)
			primitiveQuad()
			Plane2

Plane2-->	extrude(diameter)	
			Ball	

Ball-->		center(xyz)	
			primitiveSphere(16,16,diameter)
			t(0,-diameter/2,0)#To lower sphere
			//t(0,0,-.05) #To bring sphere in from outer edge
			s('1.05,'1.05,'1.05) #For small adjustments to scope for preference
	
#################
# Redirects
		
Street-->Line
Roundabout-->Joint
Junction --> Joint	

 

 

The Ball shape may look off depending on chosen diameter.  Playing with the "Ball" rules translation and scope in the final rule can help make it look better or adjust to preference.    Furthermore, the ball uses the outer edge of the curve creation triangle, so translation is used to bring it towards node center.  Also, I had the cylinder centered on the line but I did something that changed that, and I wasn't bothered to fix it yet. 

If you want to extend the pipe network more easily, hit F12 <Models>, to hide the scene's models for a moment to draw the network.

Let me know if any questions or suggestions.

Thanks!   BW

 

Tags (2)