Untitled diff

建立於 差異永不過期
11 刪除
357 行
51 新增
386 行
/*
/*
T-Slot Joint
T-Slot Joint
This custom feature adds a bolted T-slot connection between two planar parts.
This custom feature adds a bolted T-slot connection between two planar parts.


Version 1.0 - July 6, 2016 - Arul Suresh - Initial development and validation.
Version 1.0 - July 6, 2016 - Arul Suresh - Initial development and validation.
Version 2.0 - July 20, 2016 - Arul Suresh - Added some utility functions, lookup tables.
Version 2.0 - July 20, 2016 - Arul Suresh - Added some utility functions, lookup tables.
Initial forum release.
Initial forum release.
Version 2.1 - Sept 18, 2016 - Arul Suresh - Update to newest FS, published release.
Version 2.1 - Sept 18, 2016 - Arul Suresh - Update to newest FS, published release.
Version 2.1.1 - Sept 18, 2016 - Arul Suresh - Document description.
Version 2.1.1 - Sept 18, 2016 - Arul Suresh - Document description.
Version 2.2 - April 7, 2017 - Eric Miller - Added single-hole centered spacing and multiple plane selection, and fixed handling of angled surfaces.
*/
*/


FeatureScript 422;
FeatureScript 422;
import(path : "onshape/std/geometry.fs", version : "422.0");
import(path : "onshape/std/geometry.fs", version : "422.0");
import(path : "4dfdd9c6856db10dd896e29b", version : "c92857bc5898d90ad6f21cc3");
import(path : "5695a84e0bdf321f1d91df84", version : "90245e5cbffb04b2d7c533ad");
import(path : "f4e7238da5afaf5a3f1498c0/962c2d4fc4ca0f12fa54d8f4/22d17eb94c85900576fbf53e", version : "130b19167f35ae1dc291873b");
import(path : "f4e7238da5afaf5a3f1498c0/962c2d4fc4ca0f12fa54d8f4/22d17eb94c85900576fbf53e", version : "130b19167f35ae1dc291873b");


annotation { "Feature Type Name" : "T-Slot Joint", "Editing Logic Function" : "tsEditLogic" }
annotation { "Feature Type Name" : "T-Slot Joint", "Editing Logic Function" : "tsEditLogic" }
export const tSlotJoint = defineFeature(function(context is Context, id is Id, definition is map)
export const tSlotJoint = defineFeature(function(context is Context, id is Id, definition is map)
precondition
precondition
{
{
annotation { "Name" : "Choose edge face", "Filter" : EntityType.FACE && SketchObject.NO, "MaxNumberOfPicks" : 1 }
annotation { "Name" : "Choose edge face", "Filter" : EntityType.FACE && SketchObject.NO }
definition.base is Query;
definition.base is Query;


annotation { "Name" : "Standard", "Lookup Table" : tSlotTable, "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Standard", "Lookup Table" : tSlotTable, "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
definition.connectorStandard is LookupTablePath;
definition.connectorStandard is LookupTablePath;


annotation { "Name" : "Clearance diameter", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Clearance diameter", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
isLength(definition.holeD, TSLOT_DIAMETER_LENGTH_BOUNDS);
isLength(definition.holeD, TSLOT_DIAMETER_LENGTH_BOUNDS);


annotation { "Name" : "Nut width", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Nut width", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
isLength(definition.nutW, TSLOT_NUT_W_LENGTH_BOUNDS);
isLength(definition.nutW, TSLOT_NUT_W_LENGTH_BOUNDS);


annotation { "Name" : "Nut thickness", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Nut thickness", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
isLength(definition.nutT, TSLOT_NUT_T_LENGTH_BOUNDS);
isLength(definition.nutT, TSLOT_NUT_T_LENGTH_BOUNDS);


annotation { "Name" : "Show nut allowance", "UIHint" : "ALWAYS_HIDDEN" }
annotation { "Name" : "Show nut allowance", "UIHint" : "ALWAYS_HIDDEN" }
definition.showNutA is boolean;
definition.showNutA is boolean;


if (definition.showNutA)
if (definition.showNutA)
{
{
annotation { "Name" : "Nut allowance" }
annotation { "Name" : "Nut allowance" }
isLength(definition.nutA, LENGTH_BOUNDS);
isLength(definition.nutA, LENGTH_BOUNDS);
}
}


annotation { "Name" : "Screw length", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Screw length", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
isLength(definition.screwLen, TSLOT_SCREWLEN_LENGTH_BOUNDS);
isLength(definition.screwLen, TSLOT_SCREWLEN_LENGTH_BOUNDS);


annotation { "Name" : "Hole termination face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
annotation { "Name" : "Hole termination face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
definition.terminationFace is Query;
definition.terminationFace is Query;


annotation { "Name" : "Switch start side" }
annotation { "Name" : "Switch start side" }
definition.switchStart is boolean;
definition.switchStart is boolean;


annotation { "Name" : "Space from edge", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Space from edge", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
isLength(definition.edgeSpace, TSLOT_EDGE_LENGTH_BOUNDS);
isLength(definition.edgeSpace, TSLOT_EDGE_LENGTH_BOUNDS);


annotation { "Name" : "# of connectors" }
annotation { "Name" : "# of connectors" }
isInteger(definition.numConnectors, NUM_CONN_BOUNDS);
isInteger(definition.numConnectors, NUM_CONN_BOUNDS);


annotation { "Name" : "Equal spacing" }
annotation { "Name" : "Equal spacing", "Default": true }
definition.equalSpacing is boolean;
definition.equalSpacing is boolean;


if (!definition.equalSpacing)
if (!definition.equalSpacing)
{
{
annotation { "Name" : "Spacing", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
annotation { "Name" : "Spacing", "UIHint" : "REMEMBER_PREVIOUS_VALUE" }
isLength(definition.spacing, TSLOT_SPACING_LENGTH_BOUNDS);
isLength(definition.spacing, TSLOT_SPACING_LENGTH_BOUNDS);


annotation { "Name" : "Symmetric" }
annotation { "Name" : "Symmetric" }
definition.symmetric is boolean;
definition.symmetric is boolean;
}
}
}
}
{
{
var faceInfo = getFaceInfo(context, definition);
var bases = evaluateQuery(context, definition.base);
var faceInfo;
var i = 0;
for (var base in bases)
{
i += 1;
faceInfo = getFaceInfo(context, definition, base);


var connectionPoints is array = getConnectionPoints(context, definition, faceInfo);
var connectionPoints is array = getConnectionPoints(context, definition, faceInfo);


var connectionCount = 0;
var connectionCount = 0;
for (var connPoint in connectionPoints)
for (var connPoint in connectionPoints)
{
{
connectionCount += 1;
connectionCount += 1;
createTSlotJoint(context, id + ("tsj" ~ connectionCount), definition, connPoint);
createTSlotJoint(context, id + ("tsj" ~ i ~ connectionCount), definition, connPoint, base);
}

}
}
});
});


/*
/*
* Creates geometry for a single T-Slot at the provided coordinate frame.
* Creates geometry for a single T-Slot at the provided coordinate frame.
*/
*/
function createTSlotJoint(context is Context, id is Id, definition is map, csys is CoordSystem)

function createTSlotJoint(context is Context, id is Id, definition is map, csys is CoordSystem, base is Query)
{
{
var endClearance = 0.25 * definition.holeD;
var endClearance = 0.25 * definition.holeD;


// hole through continuous material
// hole through continuous material
var holeSketchPlane = plane(csys.origin, csys.zAxis, csys.xAxis);
var holeSketchPlane = plane(csys.origin, csys.zAxis, csys.xAxis);


var depth = undefined;
var depth = undefined;
if (evaluateQuery(context, definition.terminationFace) != [])
if (evaluateQuery(context, definition.terminationFace) != [])
{
{
var faceCoords = evPlane(context, {
var faceCoords = evPlane(context, {
"face" : definition.terminationFace
"face" : definition.terminationFace
}).origin;
}).origin;


depth = fromWorld(csys, faceCoords)[2];
depth = fromWorld(csys, faceCoords)[2];