Skip to content

Commit

Permalink
JButtWeld (#51)
Browse files Browse the repository at this point in the history
* JButtWeld

* oppositeDirection

* Update weld.fs.js

Co-Authored-By: emagdalenaC2i <emagdalena@c2i.es>

* Update weld.fs.js

Co-Authored-By: emagdalenaC2i <emagdalena@c2i.es>

* Update weld.fs.js

Co-Authored-By: emagdalenaC2i <emagdalena@c2i.es>

* Update weld.fs.js

Co-Authored-By: emagdalenaC2i <emagdalena@c2i.es>

* Update weld.fs.js

Co-Authored-By: emagdalenaC2i <emagdalena@c2i.es>

* Update weld.fs.js

Co-Authored-By: emagdalenaC2i <emagdalena@c2i.es>
  • Loading branch information
emagdalenaC2i committed Dec 10, 2018
1 parent 793935d commit 6ad1c80
Showing 1 changed file with 66 additions and 29 deletions.
95 changes: 66 additions & 29 deletions weld.fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1362,70 +1362,107 @@ function sketchUButtWeld(context is Context, definition is map, thickness is Val
}

// /**
// * TODO: J-Butt Weld Sketch
// * J-Butt Weld Sketch
// */
function sketchJButtWeld(context is Context, definition is map, thickness is ValueWithUnits, profileSketch is Sketch, side2 is boolean)
{
// Obtiene la forma a aplicar a la soldadura en V
var shape = definition.buttShape;

// Obtiene el angulo y los valores del talon de raiz a aplicar a la soldadura en V
var offset = definition.buttOffset;
var radius = definition.buttRadius;
var angle = definition.buttAngle;
var rootGap = definition.buttRootGap;
var rootGapWidth = definition.buttRootGapWidth;
var rootGapHeight = definition.buttRootGapHeight;

// Obtiene el ancho de la parte superior de la soldadura
var distOut = rootGap ? tan(angle / 2) * (thickness - rootGapHeight) + rootGapWidth / 2 : tan(angle / 2) * thickness;
if (side2)
{
shape = definition.buttShape2;
offset = definition.buttOffset2;
radius = definition.buttRadius2;
angle = definition.buttAngle2;
rootGap = definition.buttRootGap2;
rootGapWidth = definition.buttRootGapWidth2;
rootGapHeight = definition.buttRootGapHeight2;
}

var ang1 = -angle/2 - 45 * degree;
var distBase = thickness - radius - (radius * sin(-angle));
var distOut = (radius * cos(-angle)) + (distBase * tan(angle));
if (rootGap)
{
distOut = (radius * cos(-angle)) + (distBase - rootGapHeight) * tan(angle) + rootGapWidth;
}

var oppDir = 1;
if (side2 && definition.oppositeDirection2 || !side2 && definition.oppositeDirection)
{
oppDir *= -1;
distOut = -distOut;
}

// Si la forma de la soldadura es plana crea una linea
if (shape == WeldShape.FLAT)
{
skLineSegment(profileSketch, "topLine", {
"start" : vector(-distOut, 0 * meter),
"start" : vector(0, 0) * meter,
"end" : vector(distOut, 0 * meter)
});
// Si la forma de la soldadura No es plana, es convexa, crea un arco
}
else if (shape == WeldShape.CONVEX)
{
skArc(profileSketch, "topLine", {
"start" : vector(0 * meter, 0 * meter),
"mid" : vector(distOut / 2, offset),
"end" : vector(distOut, 0 * meter)
});
}
else
{
skArc(profileSketch, "topLine", {
"start" : vector(-distOut, 0 * meter),
"mid" : vector(0 * meter, distOut / 5),
"start" : vector(0 * meter, 0 * meter),
"mid" : vector(distOut / 2, -offset),
"end" : vector(distOut, 0 * meter)
});
}

// Si está activada la Soldadura con talon de raiz, crea la soldadura en V con talon de raiz
if (rootGap)
{
skLineSegment(profileSketch, "sideLine1", {
"start" : vector(0 * meter, 0 * meter),
"end" : vector(0 * meter, -thickness)
});
skLineSegment(profileSketch, "bottomLine", {
"start" : vector(-rootGapWidth / 2, -thickness),
"end" : vector(rootGapWidth / 2, -thickness)
"start" : vector(0 * meter, -thickness),
"end" : vector(oppDir * rootGapWidth, -thickness)
});
skLineSegment(profileSketch, "sideLineVertical1", {
"start" : vector(-rootGapWidth / 2, -thickness),
"end" : vector(-rootGapWidth / 2, -thickness + rootGapHeight)
"start" : vector(oppDir * rootGapWidth, -thickness),
"end" : vector(oppDir * rootGapWidth, -thickness + rootGapHeight)
});
skLineSegment(profileSketch, "sideLineVertical2", {
"start" : vector(rootGapWidth / 2, -thickness),
"end" : vector(rootGapWidth / 2, -thickness + rootGapHeight)
});
skLineSegment(profileSketch, "sideLine1", {
"start" : vector(-distOut, 0 * meter),
"end" : vector(-rootGapWidth / 2, -thickness + rootGapHeight)
skArc(profileSketch, "bottomArc1", {
"start" : vector(oppDir * rootGapWidth, -thickness + rootGapHeight),
"mid" : vector((oppDir * rootGapWidth) + (oppDir * radius * cos(ang1)), -thickness + radius + (radius * sin(ang1)) + rootGapHeight),
"end" : vector((oppDir * rootGapWidth) + (oppDir * radius * cos(-angle)), -thickness + radius + (radius * sin(-angle)) + rootGapHeight)
});
skLineSegment(profileSketch, "sideLine2", {
"start" : vector(distOut, 0 * meter),
"end" : vector(rootGapWidth / 2, -thickness + rootGapHeight)
"start" : vector(oppDir * (rootGapWidth + radius * cos(-angle)), -thickness + radius + (radius * sin(-angle)) + rootGapHeight),
"end" : vector(distOut, 0 * meter)
});
}
// Si No está activada la Soldadura con talon de raiz, crea solo la soldadura en V
else
{
skLineSegment(profileSketch, "sideLine1", {
"start" : vector(-distOut, 0 * meter),
"start" : vector(0 * meter, 0 * meter),
"end" : vector(0 * meter, -thickness)
});
skArc(profileSketch, "bottomArc1", {
"start" : vector(0 * meter, -thickness),
"mid" : vector(oppDir * radius * cos(ang1), -thickness + radius + (radius * sin(ang1))),
"end" : vector(oppDir * radius * cos(-angle), -distBase)
});

skLineSegment(profileSketch, "sideLine2", {
"start" : vector(distOut, 0 * meter),
"end" : vector(0 * meter, -thickness)
"start" : vector(oppDir * radius * cos(-angle), -distBase),
"end" : vector(distOut, 0 * meter)
});
}
}
Expand Down

0 comments on commit 6ad1c80

Please sign in to comment.