-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpoint.fs
76 lines (68 loc) · 2.97 KB
/
cpoint.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FeatureScript ✨; /* Automatically generated version */
// This module is part of the FeatureScript Standard Library and is distributed under the MIT License.
// See the LICENSE tab for the license text.
// Copyright (c) 2013-Present PTC Inc.
// Imports used in interface
export import(path : "onshape/std/query.fs", version : "✨");
// Imports used internally
import(path : "onshape/std/evaluate.fs", version : "✨");
import(path : "onshape/std/feature.fs", version : "✨");
import(path : "onshape/std/geomOperations.fs", version : "✨");
import(path : "onshape/std/valueBounds.fs", version : "✨");
import(path : "onshape/std/vector.fs", version : "✨");
/**
* @internal
* The type of construction point.
*/
export enum PointType
{
annotation {"Name": "Edge point"}
EDGE_POINT,
annotation {"Name": "Mesh point"}
MESH_POINT
}
/**
* @internal
* Creates a construction point, calling [opPoint]. Not exposed through the UI.
*/
annotation { "Feature Type Name" : "Point" }
export const cPoint = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Point type" }
definition.pointType is PointType;
if (definition.pointType == PointType.EDGE_POINT)
{
// Define the parameters of the feature type. Since the cpoint only takes a single edge I will call it edge
// for UI purposes but for future compatibility I will call the item map entry 'entities'
annotation { "Name" : "Edge", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
definition.entities is Query;
annotation { "Name" : "Parameter" }
isReal(definition.parameter, EDGE_PARAMETER_BOUNDS);
}
else if (definition.pointType == PointType.MESH_POINT)
{
// The owner mesh face of the point
annotation { "Name" : "Mesh", "Filter" : EntityType.FACE && AllowMeshGeometry.YES && GeometryType.MESH, "MaxNumberOfPicks" : 1 }
definition.mesh is Query;
annotation { "Name" : "X" }
isLength(definition.x, LENGTH_BOUNDS);
annotation { "Name" : "Y" }
isLength(definition.y, LENGTH_BOUNDS);
annotation { "Name" : "Z" }
isLength(definition.z, LENGTH_BOUNDS);
}
}
{
if (definition.pointType == PointType.EDGE_POINT)
{
definition.point = evEdgeTangentLine(context, { "edge" : definition.entities,
"parameter" : definition.parameter,
"arcLengthParameterization" : true }).origin;
}
else if (definition.pointType == PointType.MESH_POINT)
{
definition.point = vector(definition.x, definition.y, definition.z);
}
opPoint(context, id, definition);
}, { pointType: PointType.EDGE_POINT, parameter: 0.5, x: 0 * meter, y: 0 * meter, z: 0 * meter });