-
Notifications
You must be signed in to change notification settings - Fork 2
/
formedUtils.fs
91 lines (76 loc) · 2.76 KB
/
formedUtils.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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.
import(path : "onshape/std/attributes.fs", version : "✨");
import(path : "onshape/std/containers.fs", version : "✨");
import(path : "onshape/std/context.fs", version : "✨");
import(path : "onshape/std/query.fs", version : "✨");
/** @internal */
const FORM_BODY_ATTRIBUTE_NAME = "formBodyAttribute";
/** @internal */
export const FORM_BODY_POSITIVE_PART = "positivePart";
/** @internal */
export const FORM_BODY_NEGATIVE_PART = "negativePart";
/** @internal */
export const FORM_BODY_SKETCH_FOR_FLAT_VIEW = "sketchForFlatView";
/** @internal */
export const FORM_BODY_CSYS_MATE_CONNECTOR = "cSysMateConnector";
// == FormAttribute ==
/**
* An attribute attached to the parts, sketch and mate connector in a form part studio
* which define the positive and negative volumes, sketch for the flat view and
* coordinate system associated with the form.
*/
type FormAttribute typecheck canBeFormAttribute;
predicate canBeFormAttribute(value)
{
value is string;
}
/**
* Construct a FormAttribute.
*/
function formAttribute(value is string) returns FormAttribute
{
return value as FormAttribute;
}
/**
* Attach the given FormAttribute to the `bodies`.
*/
export function setFormAttribute(context is Context, bodies is Query, attribute is string)
{
setAttribute(context, {
"entities" : bodies,
"name" : FORM_BODY_ATTRIBUTE_NAME,
"attribute" : formAttribute(attribute)
});
}
/**
* Query for all bodies marked with a FormAttribute and value exactly equal to `attribute`
* @seealso [setFormAttribute]
*/
export function qBodiesWithFormAttribute(attribute is string)
{
return qHasAttributeWithValue(FORM_BODY_ATTRIBUTE_NAME, formAttribute(attribute));
}
/**
* Query for all bodies in `queryToFilter` marked with a FormAttribute and value exactly equal to `attribute`
* @seealso [setFormAttribute]
*/
export function qBodiesWithFormAttribute(queryToFilter is Query, attribute is string) returns Query
{
return qHasAttributeWithValue(queryToFilter, FORM_BODY_ATTRIBUTE_NAME, formAttribute(attribute));
}
/**
* Query for all bodies in `queryToFilter` marked with a FormAttribute and value exactly equal to one of the `attributes`
* @seealso [setFormAttribute]
*/
export function qBodiesWithFormAttributes(queryToFilter is Query, attributes is array) returns Query
{
var subQueries = [];
for (var attribute in attributes)
{
subQueries = append(subQueries, qHasAttributeWithValue(queryToFilter, FORM_BODY_ATTRIBUTE_NAME, formAttribute(attribute)));
}
return qUnion(subQueries);
}