point and clickify flange assembly
This commit is contained in:
		@ -7,17 +7,13 @@
 | 
			
		||||
// Import parameters
 | 
			
		||||
import pipeInnerDiameter, pipeOuterDiameter, pipeLength from "parameters.kcl"
 | 
			
		||||
 | 
			
		||||
// Create a function to make the pipe. Export
 | 
			
		||||
export fn pipe() {
 | 
			
		||||
  // Create the pipe base
 | 
			
		||||
  pipeBase = startSketchOn(XZ)
 | 
			
		||||
    |> circle(%, center = [0, 0], radius = pipeOuterDiameter / 2)
 | 
			
		||||
    |> extrude(%, length = pipeLength)
 | 
			
		||||
// Create the pipe base
 | 
			
		||||
pipeBase = startSketchOn(XZ)
 | 
			
		||||
  |> circle(%, center = [0, 0], radius = pipeOuterDiameter / 2)
 | 
			
		||||
  |> extrude(%, length = pipeLength)
 | 
			
		||||
 | 
			
		||||
  // Extrude a hole through the length of the pipe
 | 
			
		||||
  pipe = startSketchOn(pipeBase, face = END)
 | 
			
		||||
    |> circle(center = [0, 0], radius = pipeInnerDiameter / 2)
 | 
			
		||||
    |> extrude(%, length = -pipeLength)
 | 
			
		||||
    |> appearance(color = "#a24ed0")
 | 
			
		||||
  return pipe
 | 
			
		||||
}
 | 
			
		||||
// Extrude a hole through the length of the pipe
 | 
			
		||||
startSketchOn(pipeBase, face = END)
 | 
			
		||||
  |> circle(center = [0, 0], radius = pipeInnerDiameter / 2)
 | 
			
		||||
  |> extrude(%, length = -pipeLength)
 | 
			
		||||
  |> appearance(color = "#a24ed0")
 | 
			
		||||
 | 
			
		||||
@ -7,38 +7,33 @@
 | 
			
		||||
// Import parameters
 | 
			
		||||
import pipeDiameter, mountingHoleDiameter, mountingHolePlacementDiameter, flangeDiameter, flangeTotalThickness, flangeBackHeight, flangeFrontHeight, flangeBaseThickness, flangeBackDiameter, flangeFrontDiameter from "parameters.kcl"
 | 
			
		||||
 | 
			
		||||
// Create a function to create the flange. We must create a function since we are using multiple flanges.
 | 
			
		||||
export fn flange() {
 | 
			
		||||
  // Sketch the mounting hole pattern
 | 
			
		||||
  mountingHoles = startSketchOn(XY)
 | 
			
		||||
    |> circle(%, center = [0, mountingHolePlacementDiameter / 2], radius = mountingHoleDiameter / 2)
 | 
			
		||||
    |> patternCircular2d(
 | 
			
		||||
         %,
 | 
			
		||||
         instances = 4,
 | 
			
		||||
         center = [0, 0],
 | 
			
		||||
         arcDegrees = 360,
 | 
			
		||||
         rotateDuplicates = false,
 | 
			
		||||
       )
 | 
			
		||||
// Sketch the mounting hole pattern
 | 
			
		||||
mountingHoles = startSketchOn(XY)
 | 
			
		||||
  |> circle(%, center = [0, mountingHolePlacementDiameter / 2], radius = mountingHoleDiameter / 2)
 | 
			
		||||
  |> patternCircular2d(
 | 
			
		||||
       %,
 | 
			
		||||
       instances = 4,
 | 
			
		||||
       center = [0, 0],
 | 
			
		||||
       arcDegrees = 360,
 | 
			
		||||
       rotateDuplicates = false,
 | 
			
		||||
     )
 | 
			
		||||
 | 
			
		||||
  // Create the flange base
 | 
			
		||||
  flangeBase = startSketchOn(XY)
 | 
			
		||||
    |> circle(%, center = [0, 0], radius = flangeDiameter / 2)
 | 
			
		||||
    |> subtract2d(tool = mountingHoles)
 | 
			
		||||
    |> extrude(%, length = flangeBaseThickness)
 | 
			
		||||
// Create the flange base
 | 
			
		||||
flangeBase = startSketchOn(XY)
 | 
			
		||||
  |> circle(%, center = [0, 0], radius = flangeDiameter / 2)
 | 
			
		||||
  |> subtract2d(tool = mountingHoles)
 | 
			
		||||
  |> extrude(%, length = flangeBaseThickness)
 | 
			
		||||
 | 
			
		||||
  // Create both the raised portions on the front and back of the flange base
 | 
			
		||||
  flangeBack = startSketchOn(flangeBase, face = START)
 | 
			
		||||
    |> circle(%, center = [0, 0], radius = flangeBackDiameter / 2)
 | 
			
		||||
    |> extrude(%, length = flangeBackHeight)
 | 
			
		||||
  flangeFront = startSketchOn(flangeBase, face = END)
 | 
			
		||||
    |> circle(%, center = [0, 0], radius = flangeFrontDiameter / 2)
 | 
			
		||||
    |> extrude(%, length = flangeFrontHeight)
 | 
			
		||||
// Create both the raised portions on the front and back of the flange base
 | 
			
		||||
flangeBack = startSketchOn(flangeBase, face = START)
 | 
			
		||||
  |> circle(%, center = [0, 0], radius = flangeBackDiameter / 2)
 | 
			
		||||
  |> extrude(%, length = flangeBackHeight)
 | 
			
		||||
flangeFront = startSketchOn(flangeBase, face = END)
 | 
			
		||||
  |> circle(%, center = [0, 0], radius = flangeFrontDiameter / 2)
 | 
			
		||||
  |> extrude(%, length = flangeFrontHeight)
 | 
			
		||||
 | 
			
		||||
  // Create the circular cut in the center for the pipe
 | 
			
		||||
  pipeCut = startSketchOn(flangeFront, face = END)
 | 
			
		||||
    |> circle(%, center = [0, 0], radius = pipeDiameter / 2)
 | 
			
		||||
    |> extrude(%, length = -flangeTotalThickness)
 | 
			
		||||
    |> appearance(%, color = "#bab0b0")
 | 
			
		||||
 | 
			
		||||
  return pipeCut
 | 
			
		||||
}
 | 
			
		||||
// Create the circular cut in the center for the pipe
 | 
			
		||||
startSketchOn(flangeFront, face = END)
 | 
			
		||||
  |> circle(%, center = [0, 0], radius = pipeDiameter / 2)
 | 
			
		||||
  |> extrude(%, length = -flangeTotalThickness)
 | 
			
		||||
  |> appearance(%, color = "#bab0b0")
 | 
			
		||||
 | 
			
		||||
@ -7,33 +7,28 @@
 | 
			
		||||
// Import parameters
 | 
			
		||||
import boltDiameter, boltLength, boltHeadLength, boltHeadDiameter, boltHexDrive, boltHexFlatLength, boltThreadLength from "parameters.kcl"
 | 
			
		||||
 | 
			
		||||
// Create a function to make a the bolt
 | 
			
		||||
export fn bolt() {
 | 
			
		||||
  // Create the head of the cap screw
 | 
			
		||||
  boltHead = startSketchOn(XZ)
 | 
			
		||||
    |> circle(center = [0, 0], radius = boltHeadDiameter / 2, tag = $topEdge)
 | 
			
		||||
    |> extrude(length = -boltHeadLength)
 | 
			
		||||
    |> fillet(radius = 0.020, tags = [topEdge, getOppositeEdge(topEdge)])
 | 
			
		||||
// Create the head of the cap screw
 | 
			
		||||
boltHead = startSketchOn(XZ)
 | 
			
		||||
  |> circle(center = [0, 0], radius = boltHeadDiameter / 2, tag = $topEdge)
 | 
			
		||||
  |> extrude(length = -boltHeadLength)
 | 
			
		||||
  |> fillet(radius = 0.020, tags = [topEdge, getOppositeEdge(topEdge)])
 | 
			
		||||
 | 
			
		||||
  // Define the sketch of the hex pattern on the screw head and extrude into the head
 | 
			
		||||
  hexPatternSketch = startSketchOn(boltHead, face = START)
 | 
			
		||||
    |> startProfile(at = [
 | 
			
		||||
         boltHexDrive / 2,
 | 
			
		||||
         boltHexFlatLength / 2
 | 
			
		||||
       ])
 | 
			
		||||
    |> angledLine(angle = 270, length = boltHexFlatLength)
 | 
			
		||||
    |> angledLine(angle = 210, length = boltHexFlatLength)
 | 
			
		||||
    |> angledLine(angle = 150, length = boltHexFlatLength)
 | 
			
		||||
    |> angledLine(angle = 90, length = boltHexFlatLength)
 | 
			
		||||
    |> angledLine(angle = 30, length = boltHexFlatLength)
 | 
			
		||||
    |> close()
 | 
			
		||||
    |> extrude(length = -boltHeadLength * 0.75)
 | 
			
		||||
// Define the sketch of the hex pattern on the screw head and extrude into the head
 | 
			
		||||
hexPatternSketch = startSketchOn(boltHead, face = START)
 | 
			
		||||
  |> startProfile(at = [
 | 
			
		||||
       boltHexDrive / 2,
 | 
			
		||||
       boltHexFlatLength / 2
 | 
			
		||||
     ])
 | 
			
		||||
  |> angledLine(angle = 270, length = boltHexFlatLength)
 | 
			
		||||
  |> angledLine(angle = 210, length = boltHexFlatLength)
 | 
			
		||||
  |> angledLine(angle = 150, length = boltHexFlatLength)
 | 
			
		||||
  |> angledLine(angle = 90, length = boltHexFlatLength)
 | 
			
		||||
  |> angledLine(angle = 30, length = boltHexFlatLength)
 | 
			
		||||
  |> close()
 | 
			
		||||
  |> extrude(length = -boltHeadLength * 0.75)
 | 
			
		||||
 | 
			
		||||
  // create the body of the bolt
 | 
			
		||||
  boltBody = startSketchOn(boltHead, face = END)
 | 
			
		||||
    |> circle(center = [0, 0], radius = boltDiameter / 2, tag = $filletEdge)
 | 
			
		||||
    |> extrude(length = boltLength)
 | 
			
		||||
    |> appearance(color = "#4dd043", metalness = 90, roughness = 90)
 | 
			
		||||
 | 
			
		||||
  return boltBody
 | 
			
		||||
}
 | 
			
		||||
// create the body of the bolt
 | 
			
		||||
startSketchOn(boltHead, face = END)
 | 
			
		||||
  |> circle(center = [0, 0], radius = boltDiameter / 2, tag = $filletEdge)
 | 
			
		||||
  |> extrude(length = boltLength)
 | 
			
		||||
  |> appearance(color = "#4dd043", metalness = 90, roughness = 90)
 | 
			
		||||
 | 
			
		||||
@ -7,27 +7,22 @@
 | 
			
		||||
// Import parameters
 | 
			
		||||
import hexNutDiameter, hexNutFlatToFlat, hexNutThickness, hexNutFlatLength from "parameters.kcl"
 | 
			
		||||
 | 
			
		||||
// Create a function to make the hex nut. Must be a function since multiple hex nuts are used
 | 
			
		||||
export fn hexNut() {
 | 
			
		||||
  // Create the base of the hex nut
 | 
			
		||||
  hexNutBase = startSketchOn(XY)
 | 
			
		||||
    |> startProfile(at = [
 | 
			
		||||
         hexNutFlatToFlat / 2,
 | 
			
		||||
         hexNutFlatLength / 2
 | 
			
		||||
       ])
 | 
			
		||||
    |> angledLine(angle = 270, length = hexNutFlatLength)
 | 
			
		||||
    |> angledLine(angle = 210, length = hexNutFlatLength)
 | 
			
		||||
    |> angledLine(angle = 150, length = hexNutFlatLength)
 | 
			
		||||
    |> angledLine(angle = 90, length = hexNutFlatLength)
 | 
			
		||||
    |> angledLine(angle = 30, length = hexNutFlatLength)
 | 
			
		||||
    |> close()
 | 
			
		||||
    |> extrude(length = hexNutThickness)
 | 
			
		||||
// Create the base of the hex nut
 | 
			
		||||
hexNutBase = startSketchOn(XY)
 | 
			
		||||
  |> startProfile(at = [
 | 
			
		||||
       hexNutFlatToFlat / 2,
 | 
			
		||||
       hexNutFlatLength / 2
 | 
			
		||||
     ])
 | 
			
		||||
  |> angledLine(angle = 270, length = hexNutFlatLength)
 | 
			
		||||
  |> angledLine(angle = 210, length = hexNutFlatLength)
 | 
			
		||||
  |> angledLine(angle = 150, length = hexNutFlatLength)
 | 
			
		||||
  |> angledLine(angle = 90, length = hexNutFlatLength)
 | 
			
		||||
  |> angledLine(angle = 30, length = hexNutFlatLength)
 | 
			
		||||
  |> close()
 | 
			
		||||
  |> extrude(length = hexNutThickness)
 | 
			
		||||
 | 
			
		||||
  // Create the hole in the center of the hex nut
 | 
			
		||||
  hexNut = startSketchOn(hexNutBase, face = END)
 | 
			
		||||
    |> circle(center = [0, 0], radius = hexNutDiameter / 2)
 | 
			
		||||
    |> extrude(%, length = -hexNutThickness)
 | 
			
		||||
    |> appearance(%, color = "#4edfd5")
 | 
			
		||||
 | 
			
		||||
  return hexNut
 | 
			
		||||
}
 | 
			
		||||
// Create the hole in the center of the hex nut
 | 
			
		||||
startSketchOn(hexNutBase, face = END)
 | 
			
		||||
  |> circle(center = [0, 0], radius = hexNutDiameter / 2)
 | 
			
		||||
  |> extrude(%, length = -hexNutThickness)
 | 
			
		||||
  |> appearance(%, color = "#4edfd5")
 | 
			
		||||
 | 
			
		||||
@ -7,8 +7,6 @@
 | 
			
		||||
// Import parameters
 | 
			
		||||
import washerInnerDia, washerOuterDia, washerThickness from "parameters.kcl"
 | 
			
		||||
 | 
			
		||||
// Create a function to make the washer. Must be a function since multiple washers are used.
 | 
			
		||||
export fn washer() {
 | 
			
		||||
  // Create the base of the washer
 | 
			
		||||
  washerBase = startSketchOn(XY)
 | 
			
		||||
    |> circle(center = [0, 0], radius = washerOuterDia / 2)
 | 
			
		||||
@ -20,5 +18,3 @@ export fn washer() {
 | 
			
		||||
    |> extrude(%, length = -washerThickness)
 | 
			
		||||
    |> appearance(%, color = "#ee4f4f")
 | 
			
		||||
 | 
			
		||||
  return washer
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -9,16 +9,19 @@ import * from "parameters.kcl"
 | 
			
		||||
 | 
			
		||||
// Import parts
 | 
			
		||||
import "9472k188-gasket.kcl" as gasket
 | 
			
		||||
import flange from "68095k348-flange.kcl"
 | 
			
		||||
import washer from "98017a257-washer.kcl"
 | 
			
		||||
import bolt from "91251a404-bolt.kcl"
 | 
			
		||||
import hexNut from "95479a127-hex-nut.kcl"
 | 
			
		||||
import pipe from "1120t74-pipe.kcl"
 | 
			
		||||
import "68095k348-flange.kcl" as flange
 | 
			
		||||
import "98017a257-washer.kcl" as washer
 | 
			
		||||
import "91251a404-bolt.kcl" as bolt
 | 
			
		||||
import "95479a127-hex-nut.kcl" as hexNut
 | 
			
		||||
import "1120t74-pipe.kcl" as pipe
 | 
			
		||||
 | 
			
		||||
// Place flanges
 | 
			
		||||
flange()
 | 
			
		||||
flange()
 | 
			
		||||
  |> rotate(axis = [0, 1, 0], angle = 180)
 | 
			
		||||
// Place flange clone
 | 
			
		||||
rotate(
 | 
			
		||||
       clone(flange),
 | 
			
		||||
       roll = 180,
 | 
			
		||||
       pitch = 0,
 | 
			
		||||
       yaw = 0,
 | 
			
		||||
     )
 | 
			
		||||
  |> translate(x = 0, y = 0, z = flangeBackHeight * 2 + gasketThickness)
 | 
			
		||||
 | 
			
		||||
// Place gasket between the flanges
 | 
			
		||||
@ -26,7 +29,7 @@ gasket
 | 
			
		||||
  |> translate(x = 0, y = 0, z = -flangeBackHeight - gasketThickness)
 | 
			
		||||
 | 
			
		||||
// Place eight washers (four front, four back)
 | 
			
		||||
washer()
 | 
			
		||||
washer
 | 
			
		||||
  |> translate(x = mountingHolePlacementDiameter / 2, y = 0, z = flangeBaseThickness)
 | 
			
		||||
  |> patternCircular3d(
 | 
			
		||||
       %,
 | 
			
		||||
@ -44,7 +47,8 @@ washer()
 | 
			
		||||
     )
 | 
			
		||||
 | 
			
		||||
// Place four bolts
 | 
			
		||||
bolt()
 | 
			
		||||
 | 
			
		||||
bolt
 | 
			
		||||
  |> translate(x = mountingHolePlacementDiameter / 2, y = 0, z = flangeBaseThickness + washerThickness)
 | 
			
		||||
  |> rotate(roll = 90, pitch = 0, yaw = 0)
 | 
			
		||||
  |> patternCircular3d(
 | 
			
		||||
@ -57,7 +61,7 @@ bolt()
 | 
			
		||||
     )
 | 
			
		||||
 | 
			
		||||
// Place four hex nuts
 | 
			
		||||
hexNut()
 | 
			
		||||
hexNut
 | 
			
		||||
  |> translate(x = mountingHolePlacementDiameter / 2, y = 0, z = -(flangeBackHeight * 2 + gasketThickness + flangeBaseThickness + washerThickness + hexNutThickness))
 | 
			
		||||
  |> patternCircular3d(
 | 
			
		||||
       %,
 | 
			
		||||
@ -69,9 +73,8 @@ hexNut()
 | 
			
		||||
     )
 | 
			
		||||
 | 
			
		||||
// Place both pieces of pipe
 | 
			
		||||
pipe()
 | 
			
		||||
  |> rotate(
 | 
			
		||||
       %,
 | 
			
		||||
rotate(
 | 
			
		||||
       pipe,
 | 
			
		||||
       roll = -90,
 | 
			
		||||
       pitch = 0,
 | 
			
		||||
       yaw = 0,
 | 
			
		||||
@ -83,16 +86,13 @@ pipe()
 | 
			
		||||
       z = flangeBaseThickness + flangeFrontHeight - 0.5,
 | 
			
		||||
       global = true,
 | 
			
		||||
     )
 | 
			
		||||
 | 
			
		||||
pipe()
 | 
			
		||||
  |> rotate(
 | 
			
		||||
       %,
 | 
			
		||||
       roll = 90,
 | 
			
		||||
rotate(
 | 
			
		||||
       clone(pipe),
 | 
			
		||||
       roll = 180,
 | 
			
		||||
       pitch = 0,
 | 
			
		||||
       yaw = 0,
 | 
			
		||||
     )
 | 
			
		||||
  |> translate(
 | 
			
		||||
       %,
 | 
			
		||||
       x = 0,
 | 
			
		||||
       y = 0,
 | 
			
		||||
       z = -(flangeBackHeight * 2 + gasketThickness + flangeBaseThickness + flangeFrontHeight - 0.5),
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user