-
Notifications
You must be signed in to change notification settings - Fork 2
/
geomOperations.fs
1767 lines (1677 loc) · 95.9 KB
/
geomOperations.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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.
/**
* Operations are the basic modeling primitives of FeatureScript. Operations can do extrusion, filleting, transforms,
* etc. An operation takes a context, an id, and a definition and modifies the context in accordance with the
* definition. The modifications can be referenced by the passed-in id. Operations return `undefined` but can fail by
* throwing an error or they can report warnings or infos. The status can be read with the getFeature... functions in
* error.fs.
*
* When an operation parameter that requires one entity receives a query that resolves to multiple entities, it takes
* the first resolved entity.
*
* The geomOperations.fs module contains wrappers around built-in Onshape operations and no actual logic.
*/
import(path : "onshape/std/containers.fs", version : "✨");
import(path : "onshape/std/context.fs", version : "✨");
import(path : "onshape/std/curveGeometry.fs", version : "✨");
import(path : "onshape/std/surfaceGeometry.fs", version : "✨");
import(path : "onshape/std/query.fs", version : "✨");
import(path : "onshape/std/valueBounds.fs", version : "✨");
import(path : "onshape/std/vector.fs", version : "✨");
/* enumerations used by opBodyDraft */
export import(path : "onshape/std/bodydraftconcaverepairtype.gen.fs", version : "✨");
export import(path : "onshape/std/bodydraftcornertype.gen.fs", version : "✨");
export import(path : "onshape/std/bodydraftmatchfacetype.gen.fs", version : "✨");
export import(path : "onshape/std/bodydraftselectiontype.gen.fs", version : "✨");
/* opBoolean uses enumerations from TopologyMatchType */
export import(path : "onshape/std/topologymatchtype.gen.fs", version : "✨");
/* opCreateCurvesOnFace uses enumerations from FaceCurveCreationType */
export import(path : "onshape/std/facecurvecreationtype.gen.fs", version : "✨");
/* opDraft uses enumerations from DraftType */
export import(path : "onshape/std/drafttype.gen.fs", version : "✨");
/* opExtendSheet uses enumerations from ExtendSheetBoundingType */
export import(path : "onshape/std/extendsheetboundingtype.gen.fs", version : "✨");
/* opExtractSurface uses enumerations from ExtractSurfaceRedundancyType */
export import(path : "onshape/std/extractsurfaceredundancytype.gen.fs", version : "✨");
/* opExtrude uses enumerations from BoundingType */
export import(path : "onshape/std/boundingtype.gen.fs", version : "✨");
/* opFillet uses enumerations from FilletCrossSection */
export import(path : "onshape/std/filletcrosssection.gen.fs", version : "✨");
/* opFillSurface uses enumerations from GeometricContinuity */
export import(path : "onshape/std/geometriccontinuity.gen.fs", version : "✨");
/* opHole uses objects from holeUtils, as well as enums `export import`ed in that file */
export import(path : "onshape/std/holeUtils.fs", version : "✨");
/* opSplitPart uses enumerations from SplitOperationKeepType */
export import(path : "onshape/std/splitoperationkeeptype.gen.fs", version : "✨");
/* opWrap uses enumerations from WrapType */
export import(path : "onshape/std/wraptype.gen.fs", version : "✨");
/**
* Trims or extends a wire body to an entity or by a distance.
* @param id : @autocomplete `id + "moveCurveBoundary1"`
* @param definition {{
* @field wires {Query} : The wire bodies to modify.
* @field moveBoundaryType {MoveCurveBoundaryType} : @optional Whether to trim or extend. Default is `TRIM`.
* @field trimTo {Query} : @requiredif {`moveBoundaryType` is `TRIM`.} Single entity to trim `wires` to.
* @field endCondition {CurveExtensionEndCondition} : @optional If `moveBoundaryType` is `EXTEND` defines
* whether to extend `wires` by a distance of to an entity. Default is `BLIND`.
* @field extensionDistance {ValueWithUnits} : @requiredIf {`endCondition` is `BLIND`} Distance to extend `wires`.
* @field extendTo {Query}: @requiredIf {`endCondition` is `BLIND`} Single entity to extend `wires` to.
* @field extensionShape {CurveExtensionShape} : @optional Specifies how to transition into the curve extensions. Default is `SOFT`.
* @field helpPoint {Query} : @requiredIf {`endCondition` is `BLIND`} Specifies vertex used to choose a solution.
* If this is not provided, the closest vertex to the bounding entity will be used.
* @field flipHeuristics {boolean} : @optional If `true`, will trim or extend from the opposite end of `wires`.
* Default is `false`.
* }}
*/
export const opMoveCurveBoundary = function(context is Context, id is Id, definition is map)
{
return @opMoveCurveBoundary(context, id, definition);
};
/**
* Apply draft to a part by adding material. The material is added between reference edges and
* a parting object. These reference edges can be supplied directly, or they can be inferred
* from face or part queries.
* @param id : @autocomplete `id + "bodyDraft1"`
* @param definition {{
* @field selectionType {BodyDraftSelectionType} : @optional Topology class for input.
* Default is `EDGES`
* @field topEdges {Query} : Edges to draft above parting entity. @requiredif {`selectionType` is `EDGES`}
* @field bottomEdges {Query} : Edges to draft with `angleBelow`.
* @requiredif {`selectionType` is `EDGES` and `bothSides` is `true`}
* @field faces {Query} : Faces to draft. This will split the face with isoclines those for the draft.
* Additionally, any existing edges bounding `faces` will be used if they mark a transition from steep faces to
* non-steep faces for the given pull direction and draft angle. @requiredif {`selectionType` is `FACES`}
* @field bodies {Query} : Parts to draft. This is equivalent to supplying all faces of the part in `faces`.
* @requiredif {`selectionType` is `PARTS`}
* @field excludeFaces {Query} : @optional Faces of `bodies` to exclude from drafting.
* @field angle {ValueWithUnits} : The draft angle above the parting object.
* @field bothSides {boolean} : @optional If `true`, draft on both sides of the parting object.
* Default is `false`.
* @field pullDirection {ValueWithUnits} : The pull direction.
* @field draftOnSelf {boolean} : @optional If true, then using the drafted part as the
* parting object. Default is `false`.
* @field partingObject : A surface from surfaceGeometry.fs or a query to a face or sheet body.
* @requiredif {`draftOnSelf` is `false`}
* @field matchFacesAtParting {boolean} : @optional If true, then additional material will
* be added to make the top and bottom of the draft align. Default is `false`.
* @field matchFaceType {BodyDraftMatchFaceType} : @optional How to add material for `matchFacesAtParting`
* Default is `REFERENCE_EDGE`.
* @field cornerType {BodyDraftCornerType} : @optional The corner treatment to apply. Default is `EXTEND`.
* @field concaveRepair {BodyDraftConcaveRepairType} : @optional How to resolve intersecting draft
* faces. Default is `NONE`.
* @field concaveRepairRadius {ValueWithUnits} : The radius for intersection repair.
* @requiredif {`concaveRepair` is `RADIUS` or `MIX`.}
* @field keepMaterial {boolean} : @optional If true, an attempt will be made to keep the regions of the part
* protruding from the tapered faces. Default is false.
* @field showRefs {boolean} : @optional If true, then debug data will be generated to
* show the parting surface and draft edges.
* }}
*/
export const opBodyDraft = function(context is Context, id is Id, definition is map)
{
return @opBodyDraft(context, id, definition);
};
/**
* Performs a boolean operation on multiple solid and surface bodies.
* @seealso [processNewBodyIfNeeded] for merging new solids.
* @seealso [joinSurfaceBodiesWithAutoMatching] for merging new surfaces.
* @param id : @autocomplete `id + "boolean1"`
* @param definition {{
* @field tools {Query} : The tool bodies.
* @field targets {Query} : @requiredif {`OperationType` is `SUBTRACTION` or `SUBTRACT_COMPLEMENT`, or
* if `targetsAndToolsNeedGrouping` is true.} The target bodies.
* @field operationType {BooleanOperationType} : The boolean operation to perform.
* @eg `BooleanOperationType.UNION` will merge any tool bodies that intersect or abut. All tool bodies have to be of
* the same type (solid or surface). When operating on surfaces, surfaces must have coincident or overlapping edges.
* When several bodies merge, the identity of the tool that appears earliest in the query is preserved
* (in particular, body color and body name are taken from it).
* @eg `BooleanOperationType.SUBTRACTION` will remove the union of all tools bodies from every target body.
* All tool bodies must be solid bodies. Target bodies could be either solids or surfaces.
* @eg `BooleanOperationType.INTERSECTION` will create the intersection of all tool bodies. All bodies must be solid bodies.
* @eg `BooleanOperationType.SUBTRACT_COMPLEMENT` will remove the complement of the union of all tool bodies from every target body.
* All tool bodies must be solid bodies. Target bodies could be either solids or surfaces.
* @field targetsAndToolsNeedGrouping {boolean} : @optional
* This option is for adjusting the behavior to be more suitable for doing the boolean
* as part of a body-creating feature (such as extrude). Default is `false`.
*
* @field keepTools {boolean} : If true, the tools do not get consumed by the operation. Default is false. @optional
* @field makeSolid {boolean}: In case of surface union try to join surfaces into a solid. Default is false. @optional
* }}
*/
/* TODO: describe `targetsAndToolsNeedGrouping` in fuller detail */
export const opBoolean = function(context is Context, id is Id, definition is map)
{
return @opBoolean(context, id, definition);
};
/**
* Creates a boundary surface fitting two ordered sets of profiles.
* @param id : @autocomplete `id + "bsurf1"`
* @param definition {{
* @field uProfileSubqueries {array} : An ordered array of two or fewer queries for the profiles in the u direction.
* These can be edges or wire bodies.
* @eg `[ profileQuery1, profileQuery2 ]`
* @field vProfileSubqueries {array} : @optional An ordered array of two or fewer queries for the profiles in the v direction.
* These can be edges or wire bodies.
* @eg `[ profileQuery1, profileQuery2 ]`
* @field uDerivativeInfo {array} : @optional An array of maps that contain shape constraints at start and end profiles. Each map entry
* is required to have a profileIndex that refers to the affected profile. Optional fields include a vector to match surface tangent to,
* a magnitude, and booleans for matching tangents or curvature derived from faces adjacent to affected profile.
* @ex `[ { "profileIndex" : 0, "vector" : vector(1, 0, 0), "magnitude" : 2., "tangentToPlane" : true}, { "profileIndex" : 1, "adjacentFaces" : qFaces } ]`
* The first map would constrain the resulting boundary surface at the first u profile to be tangent to plane with normal vector(1,0,0) and magnitude 2.
* The second map constrains the boundary surface at the second u profile to match tangents of faces defined by the query qFaces.
* @field vDerivativeInfo {array} : @optional An array of maps analogous to uDerivativeInfo, but for v profiles.
* @field showIsocurves {boolean} : Show graphical representation of a subset of isoparameteric curves on each face of the created boundary surface. Default `false`. @optional
* @field curveCount {number} : When `showIsocurves` is `true`, the number of curves to draw in each direction of each face's grid. Default `10`. @optional
* }}
*/
export const opBoundarySurface = function(context is Context, id is Id, definition is map)
{
return @opBoundarySurface(context, id, definition);
};
/**
* Generates a wire body given a [BSplineCurve] definition.
* The spline must have dimension of 3 and be G1-continuous.
* @param id : @autocomplete `id + "bSplineCurve1"`
* @param definition {{
* @field bSplineCurve {BSplineCurve} : The definition of the spline.
* }}
*/
export const opCreateBSplineCurve = function(context is Context, id is Id, definition is map)
{
return @opCreateBSplineCurve(context, id, definition);
};
/**
* Generates a sheet body given a [BSplineSurface] definition.
* The spline must have dimension of 3 and be G1-continuous.
* @param id : @autocomplete `id + "bSplineSurface1"`
* @param definition {{
* @field bSplineSurface {BSplineSurface} : The definition of the spline surface.
* @field boundaryBSplineCurves {array} : @optional An array of [BSplineCurve]s defined in the parameter space of
* `bSplineSurface` to use as the boundary of the created sheet body. The boundary must form a single
* closed loop on the surface. The `dimension` of each curve must be `2`, as the boundaries are being
* defined in UV space of the created surface. If no boundary is supplied, the created sheet body will
* cover the full parameter range of `bSplineSurface`.
* @field makeSolid {boolean} : @optional When set to `true`, the operation will produce a solid instead of a sheet
* if the surface encloses a region. Default is `false`.
* }}
*/
export const opCreateBSplineSurface = function(context is Context, id is Id, definition is map)
{
return @opCreateBSplineSurface(context, id, definition);
};
/**
* @internal
* Generates surfaces representing the outlines of parts or surfaces projected onto a surface
* @param id : @autocomplete `id + "createOutline1"`
* @param definition {{
* @field tools {Query} : The tool parts or surfaces
* @field target {Query} : The face whose surface will be used to create outline.
* Currently only planes, cylinders or extruded surfaces are supported.
* @field offsetFaces {Query} : @optional Faces in tools which are offsets of target face. If `offsetFaces` are
* provided, the operation will fail if `target` is non-planar and there are not exactly two offset faces per tool.
* }}
*/
export const opCreateOutline = function(context is Context, id is Id, definition is map)
{
return @opCreateOutline(context, id, definition);
};
/**
* Create a composite part.
* @param id : @autocomplete `id + "compositePart1"`
* @param definition {{
* @field bodies {Query} : Bodies from which to create the composite part.
*. @field closed {boolean} : @optional
* A `closed` composite part consumes its constituent bodies, so that they are not available interactively for individual selection. Default is `false`.
* }}
*/
export const opCreateCompositePart = function(context is Context, id is Id, definition is map)
{
return @opCreateCompositePart(context, id, definition);
};
/**
* Modifies a composite part.
* @param id : @autocomplete `id + "modifyCompositePart1"`
* @param definition {{
* @field composite {Query} : Existing composite part to modify.
* @field toAdd {Query} : Bodies to add to the composite part.
* @field toRemove {Query} : Bodies to remove from the composite part.
* }}
*/
export const opModifyCompositePart = function(context is Context, id is Id, definition is map)
{
@opModifyCompositePart(context, id, definition);
};
/**
* Adds a chamfer to given edges and faces.
* @param id : @autocomplete `id + "chamfer1"`
* @param definition {{
* @field entities {Query} : Edges and faces to chamfer.
* @field chamferType {ChamferType} : Determines where the new edges of the chamfer are positioned.
* @eg `ChamferType.EQUAL_OFFSETS` places both new edges `width` away from each original edge.
* @eg `ChamferType.TWO_OFFSETS` places edges `width1` and `width2` away.
* @eg `ChamferType.OFFSET_ANGLE` places one edge `width` away, and chamfers at an angle from that edge.
* @field width {ValueWithUnits} : @requiredif {`chamferType` is `EQUAL_OFFSETS` or `OFFSET_ANGLE`.}
* @eg `0.2 * inch`
* @field width1 {ValueWithUnits} : @requiredIf {`chamferType` is `TWO_OFFSETS`.}
* @field width2 {ValueWithUnits} : @requiredIf {`chamferType` is `TWO_OFFSETS`.}
* @field angle {ValueWithUnits} : @requiredIf {`chamferType` is `OFFSET_ANGLE`.}
* @field oppositeDirection {boolean} : @requiredIf {`chamferType` is `OFFSET_ANGLE` or `TWO_OFFSETS`.}
* `true` to reverse the two edges.
* @field tangentPropagation {boolean} : @optional
* `true` to propagate the chamfer along edges tangent to those passed in. Defaults to `false`.
* }}
*/
/* TODO: make this interface more like an operation and less like a feature. */
export const opChamfer = function(context is Context, id is Id, definition is map)
{
return @opChamfer(context, id, definition);
};
/**
* Describes a set of isoparametric curves on a face.
* @type {{
* @field face {Query} : Face the curves are meant to lie on.
* @field creationType {FaceCurveCreationType} : Determines the type of curves. Currently supports isoparameter curves only
* in primary or secondary directions, either equally spaced or defined by a parameter array.
* @field names {array} : An array of distinct non-empty strings to identify the curves created.
* @field nCurves {number} : @requiredif {`creationType` is `DIR1_AUTO_SPACED_ISO` or `DIR2_AUTO_SPACED_ISO`} Number of curves.
* @field parameters {array} : @requiredif {`creationType` is `DIR1_ISO` or `DIR2_ISO`} Parameters to create curves at.
* }}
*/
export type CurveOnFaceDefinition typecheck canBeCurveOnFaceDefinition;
/** Typecheck for [CurveOnFaceDefinition] */
export predicate canBeCurveOnFaceDefinition(value)
{
value is map;
value.face is Query;
value.creationType is FaceCurveCreationType;
value.names is array;
for (var name in value.names)
{
name is string;
}
value.nCurves is number || value.nCurves is undefined;
if (value.nCurves is number)
{
value.nCurves == size(value.names);
}
value.parameters is array || value.parameters is undefined;
if (value.parameters is array)
{
size(value.parameters) == size(value.names);
for (var parameter in value.parameters)
{
parameter is number;
}
}
}
function curveOnFaceDefinitionPrivate(face is Query, creationType is FaceCurveCreationType, names is array, nCurves, parameters)
precondition
{
nCurves is number || nCurves is undefined;
parameters is array || parameters is undefined;
if (parameters is array)
{
for (var parameter in parameters)
{
parameter is number;
}
}
}
{
return {
"face" : face,
"creationType" : creationType,
"names" : names,
"nCurves" : nCurves,
"parameters" : parameters
} as CurveOnFaceDefinition;
}
/**
* Returns a new [CurveOnFaceDefinition].
*/
export function curveOnFaceDefinition(face is Query, creationType is FaceCurveCreationType, names is array, nCurves is number) returns CurveOnFaceDefinition
{
return curveOnFaceDefinitionPrivate(face, creationType, names, nCurves, undefined);
}
export function curveOnFaceDefinition(face is Query, creationType is FaceCurveCreationType, names is array, parameters is array) returns CurveOnFaceDefinition
{
return curveOnFaceDefinitionPrivate(face, creationType, names, undefined, parameters);
}
/**
* Generates isoparametric curves of faces. That is, for each specified surface parameter value, creates a new wire body
* following the curve which keeps the surface parameter at that constant value.
* @param id : @autocomplete `id + "curvesOnFace"`
* @param definition {{
* @field curveDefinition {array} : An array of [CurveOnFaceDefinition]s that describe group of curves per face.
@field showCurves {boolean} : Whether to display isoparameteric curves in color in the preview. @optional
@field useFaceParameter {boolean} : For Onshape internal use. @optional
* }}
*/
export const opCreateCurvesOnFace = function(context is Context, id is Id, definition is map)
{
return @opCreateCurvesOnFace(context, id, definition);
};
/**
* Deletes bodies from the context.
* @param id : @autocomplete `id + "deleteBodies1"`
* @param definition {{
* @field entities {Query} : Entities to delete. Passing in entities other than bodies deletes their owning bodies.
* }}
*/
export const opDeleteBodies = function(context is Context, id is Id, definition is map)
{
return @opDeleteBodies(context, id, definition);
};
/**
* This is a direct editing operation that attempts to delete faces of a solid body and extend other faces to fill the hole.
* @param id : @autocomplete `id + "deleteFace1"`
* @param definition {{
* @field deleteFaces {Query} : Faces to delete.
* @field includeFillet {boolean} : `true` to also delete fillets adjacent to the input faces.
* @autocomplete `false`
* @field capVoid {boolean} : If `capVoid` is `true` and the deleted face
* cannot be filled by extending the surrounding faces, will
* attempt to replace the face with a planar face.
* @autocomplete `false`
* @field leaveOpen {boolean} : @optional
* If `leaveOpen` is `true` the void from deleting faces is left open, potentially creating a surface out
* of a solid body. Default is `false`.
* @autocomplete `false`
* }}
*/
export const opDeleteFace = function(context is Context, id is Id, definition is map)
{
return @opDeleteFace(context, id, definition);
};
/**
* @internal
* Takes in a set of bodies and faces and creates solid bodies for the enclosed regions.
* @param id : @autocomplete `id + "enclose"`
* @param definition {{
* @field entities {Query} : Bodies and faces for enclosure.
* }}
*/
export const opEnclose = function(context is Context, id is Id, definition is map)
{
return @opEnclose(context, id, definition);
};
/**
* Applies a given draft angle to faces.
* @param id : @autocomplete `id + "draft1"`
* @param definition {{
* @field draftType {DraftType} :
* Specifies a reference surface (e.g. a neutral plane) or reference entity draft.
* @eg `DraftType.REFERENCE_SURFACE` for a reference surface draft
* @field draftFaces {Query} : @requiredif { `draftType` is `REFERENCE_SURFACE` }
* The faces to draft for a `REFERENCE_SURFACE` draft.
* @autocomplete `draftFaces`
* @field referenceSurface : @requiredif { `draftType` is `REFERENCE_SURFACE` }
* A face or plane that defines the neutral surface for a `REFERENCE_SURFACE` draft. `draftFaces` will remain unchanged
* where they intersect `referenceSurface`. Can be either a [Query] or a [Plane].
* @field referenceEntityDraftOptions {array} : @requiredif { `draftType` is `REFERENCE_ENTITY` }
* An array of maps of the form ("face", "references", "angle"). "face" should be a [Query] for exactly one
* face. "references" should be a [Query] for at least one edge attached to the face. The "face" will
* be drafted while the geometry of the "references" remains unchanged. "angle" is an optional [ValueWithUnits]
* parameter between -89.9 and 89.9 degrees which overrides the default `angle` parameter.
* @field pullVec {Vector} : The 3d direction relative to which the draft is applied.
* @eg `vector(0, 0, 1)`.
* @field angle {ValueWithUnits} : The draft angle, must be between 0 and 89.9 degrees.
* @eg `3 * degree`
* @field tangentPropagation {boolean} : @optional
* For a `REFERENCE_SURFACE` draft, `true` to propagate draft across tangent faces.
* Default is `false`.
* @field referenceEntityPropagation {boolean} : @optional
* For a `REFERENCE_ENTITY` draft, `true` to collect new reference entities and faces by pulling in edges
* connected to the specified reference edges. Connected edges on the same face or on tangent connected
* faces will be pulled in.
* Default is `false`.
* @field reFillet {boolean} : @optional
* `true` to attempt to defillet draft faces before the draft and reapply the fillets
* after. Default is `false`.
* }}
*/
export const opDraft = function(context is Context, id is Id, definition is map)
{
return @opDraft(context, id, definition);
};
/**
* @internal
* @param id : @autocomplete `id + "changeEdge1"`
* @param definition {{
* @field edgeChangeOptions {array} : An array of maps of the form ("edge", "face", "offset", "transformList", "replaceFace").
* Edge and face are required and are the edge and face being modified.
* The other parameters are optional. If offset is a length parameter, the edge will
* be offset. If transform list is an array of transforms, they will be applied to the edge.
* If replaceFace is a face, the edge will be moved to that face.
* }}
*/
export const opEdgeChange = function(context is Context, id is Id, definition is map)
{
return @opEdgeChange(context, id, definition);
};
/**
* @internal
* @param id : @autocomplete `id + "editCurve1"`
* @param definition {{
* @field wire {Query} : The wire body to change.
* @field edge {Query} : The edge whose curve the wire body should match.
* }}
*/
export const opEditCurve = function(context is Context, id is Id, definition is map)
{
return @opEditCurve(context, id, definition);
};
/**
* @internal
* Extends or trims the perimeter of a sheet body by moving sheet edges by distance or up to a target sheet body
* @param id : @autocomplete `id + "extendBody1"`
* @param definition {{
* @field endCondition {ExtendEndType} : @autocomplete `ExtendEndType.EXTEND_BLIND`. Condition that terminates the extension. May be blind or up to target.
* @field entities {Query} : Bodies or edges to extend.
*. @field tangentPropagation {boolean} : Whether additional edges should be added to the selection by tangent propagation. Default `true`. @optional
* @field extendDistance {ValueWithUnits} : @requiredif{'endCondition' is 'ExtendEndType.EXTEND_BLIND'} The distance to extend by. Negative values may be used to trim.
* @autocomplete `0.1 * inch`
* @field target : @requiredif{'endCondition' is 'ExtendSheetBoundingType.EXTEND_TO_TARGET'} Target part to extend up to.
* @field extensionShape {ExtendSheetShapeType} : @autocomplete `ExtendSheetShapeType.LINEAR`. Shape characteristic of extension, whether curvature continuity is maintained or not.
* }}
*/
export const opExtendSheetBody = function(context is Context, id is Id, definition is map)
{
return @opExtendSheetBody(context, id, definition);
};
/**
* @internal
* This function takes a list of faces and creates one or more surfaces from those faces.
* The source faces and body are not affected.
* @param id : @autocomplete `id + "extractSurface1"`
* @param definition {{
* @field faces {Query} : List of faces to be converted. If `tangentPropagation` is `true`, these are the seed faces.
* @field tangentPropagation {boolean} : Whether additional faces should be added to the selection by tangent propagation @optional
* @field offset {ValueWithUnits} : Offset extracted surface faces by this distance along normal @optional
* @field useFacesAroundToTrimOffset {boolean} : Use surrounding faces extensions to trim offset. Default `true`. @optional
* @field redundancyType {ExtractSurfaceRedundancyType} : @optional
* Controls the culling of redundant geometry on the result body, such as tangent edges and vertices.
* `ALLOW_REDUNDANCY` does not delete any redundant geometry. `REMOVE_ADDED_REDUNDANCY` removes redundancy
* created by this operation. `REMOVE_ALL_REDUNDANCY` removes all redundant edges and vertices.
* `REMOVE_ADDED_REDUNDANCY` is the default.
* }}
*/
export const opExtractSurface = function(context is Context, id is Id, definition is map)
{
@opExtractSurface(context, id, definition);
};
/**
* Generates wire bodies from the supplied edges.
* If the edges are disjoint multiple wires will be returned.
* If the edges overlap or cross, or more than two meet at a point, the function will fail.
* @param id : @autocomplete `id + "opExtractWires1"`
* @param definition {{
* @field edges {Query} : The edges to be extracted.
* }}
*/
export const opExtractWires = function(context is Context, id is Id, definition is map)
{
return @opExtractWires(context, id, definition);
};
/**
* Extrudes one or more edges or faces in a given direction with one or two end conditions.
* Faces get extruded into solid bodies and edges get extruded into sheet bodies.
* @param id : @autocomplete `id + "extrude1"`
* @param definition {{
* @field entities {Query} : Edges and faces to extrude.
* @field direction {Vector} : The 3d direction in which to extrude.
* @eg `evOwnerSketchPlane(context, {"entity" : entities}).normal` to extrude perpendicular to the owner sketch
* @eg `evPlane(context, {"face" : entities}).normal` to extrude perpendicular to the first planar entity
* @field endBound {BoundingType} : The type of bound at the end of the extrusion. Cannot be `SYMMETRIC` or `UP_TO_VERTEX`.
* @eg `BoundingType.BLIND`
* @field endDepth {ValueWithUnits} : @requiredif {`endBound` is `BLIND`.}
* How far from the `entities` to extrude.
* @eg `1 * inch`
* @field endBoundEntity {Query} : @requiredif {`endBound` is `UP_TO_SURFACE` or `UP_TO_BODY`.}
* The face or body that provides the bound.
* @field endTranslationalOffset {ValueWithUnits} : @optional
* The translational offset between the extrude end cap and the end bound entity. The direction vector for
* this is the same as `direction`: negative values pull the end cap away from the bound entity when
* `endDepth` is positive. `endOffset` will only have an effect if `endBound` is `UP_TO_SURFACE`,
* `UP_TO_BODY`, or `UP_TO_NEXT`.
* @field startBound {BoundingType} : @optional
* The type of start bound. Default is for the extrude to start at `entities`. Cannot be `SYMMETRIC` or `UP_TO_VERTEX`.
* @field isStartBoundOpposite : @requiredif {is `UP_TO_SURFACE`, `UP_TO_BODY`, or `UP_TO_NEXT`.}
* Whether the `startBound` extends in the opposite direction from the profile as the `endBound`. Defaults
* to `true` if not supplied.
* @field startDepth {ValueWithUnits} : @requiredif {`startBound` is `BLIND`.}
* How far from the `entities` to start the extrude. The direction vector for this is the negative of `direction`:
* positive values make the extrusion longer when `endDepth` is positive.
* @field startBoundEntity {Query} : @requiredif {`startBound` is `UP_TO_SURFACE` or `UP_TO_BODY`.}
* The face or body that provides the bound.
* @field startTranslationalOffset {ValueWithUnits} : @optional
* The translational offset between the extrude start cap and the start bound entity. The direction vector for
* this is the negative of `direction`: negative values pull the end cap away from the bound entity when
* `startDepth` is positive. `startOffset` will only have an effect if `startBound` is `UP_TO_SURFACE`,
* `UP_TO_BODY`, or `UP_TO_NEXT`.
* }}
*/
export const opExtrude = function(context is Context, id is Id, definition is map)
{
return @opExtrude(context, id, definition);
};
/**
* Performs a face blend between two walls of faces.
* @param id : @autocomplete `id + "faceBlend1"`
* @param definition {{
* @field side1 {Query} : First set of faces, must belong to the same body.
* @field side2 {Query} : Second set of faces, must belong to the same body.
* @field flipSide1Normal {boolean} : Wether to flip side 1's normal.
* @field flipSide2Normal {boolean} : Wether to flip side 2's normal.
* @field propagation {boolean} : @optional Whether to propagate the blend.
* @field propagationType {FaceBlendPropagation} : @optional How to propagate the blend.
* FaceBlendPropagation.TANGENT will propagate over tangent faces.
* FaceBlendPropagation.ADJACENT will propagate over all adjacent faces.
* FaceBlendPropagation.CUSTOM allows specification of a maximum angle between faces for propagation.
* Defaults is FaceBlendPropagation.TANGENT.
* @field propagationAngle {ValueWithUnits} : @optional Maximum angle between faces for propagation.
* Used if propagationType is FaceBlendPropagation.CUSTOM. Default is 0 * radian.
* @field crossSection {FaceBlendCrossSection} : The cross section type of the blend.
* @field spine {Query} : @requiredif {`crossSection` is `DISC`.}
* The spine of the blend. The blend's cross section will be orthogonal to the spine.
* @field blendControlType {BlendControlType} : Whether the blend is controled by a constant radius or a constant width.
* @field crossSectionShape {FaceBlendCrossSectionShape} : What shape the cross section of the blend will be.
* @field radius {ValueWithUnits} : @requiredif {`blendControlType` is `RADIUS`.} The radius of the cross section.
* @field width {ValueWithUnits} : @requiredif {`blendControlType` is `WIDTH`.} The width of the blend.
* @field asymmetric {boolean} : @optional Wether the radius or width is the same on each wall.
* @field secondRadius {ValueWithUnits} : @requiredif {`blendControlType` is `RADIUS` and `asymmetric` is `true`.}
* The radius of the cross section from side 2.
* @field widthRatio {number} : @requiredif {`blendControlType` is `WIDTH` and `asymmetric` is `true`.}
* How the blend will be divided between the walls. If widthRatio < 1, it will be wider towards side 1.
* If widthRatio > 1, it will be wider towards side 2.
* @field rho {number} : @requiredif {`crossSectionShape` is `CONIC`}
* Parameter of the conic cross section shape.
* @field magnitude {number} : @requiredif {`crossSectionShape` is `CURVATURE`}
* Parameter of the curvature cross section shape.
* @field tangentHoldLines {boolean} : @optional Whether to use the content of `tangentEdges` and `inverseTangentEdges`.
* @field tangentEdges {Query} : @optional Edges to use as tangent hold lines.
* @field inverseTangentEdges {Query} : @optional Edges to use as inverse tangent hold lines.
* @field conicHoldLines {boolean} : @optional Whether to use the content of `conicEdges` and `inverseConicEdges`.
* @field conicEdges {Query} : @optional Edges to use as conic hold lines.
* @field inverseConicEdges {Query} : @optional Edges to use as inverse conic hold lines.
* @field hasCliffEdges {boolean} : @optional Whether to use the content of `cliffEdges`.
* @field cliffEdges {Query} : @optional Edges to use as cliff edges.
* @field hasCaps {boolean} : @optional Whether to use the content of `caps`.
* @field caps {array} : @optional
* Entities and flip flags to use as caps. Each map should contain an `entity` Query element and a `flip` boolean element.
* @field hasLimits {boolean} : @optional Whether to use the content of `limitPlane1`, `limitPlane2`, `faceLimits` and `edgeLimit`.
* @field limitPlane1 {Query} : @optional First plane to limit the blend.
* @field limitPlane1Flip {boolean} : Whether to flip the first plane normal. Defines which side of the plane the blend will be.
* @field limitPlane2 {Query} : @optional Second plane to limit the blend.
* @field limitPlane2Flip {boolean} : Whether to flip the first plane normal. Defines which side of the plane the blend will be.
* @field faceLimits {Query} : @optional Faces to use as limits to the blend.
* @field edgeLimit {array} : @optional
* Edges and adjacent faces to use as limits. Each map should contain an `edge` Query element and an `edgeLimitSide` query element.
* @field hasHelpPoint {boolean} : @optional Whether to use the content of `helpPoint`.
* @field helpPoint {Query} : @optional Vertex or mate connector to use as help point. In case the blend parameters create several blends,
* only the blend closest to the help point will be kept.
* @field trim {FaceBlendTrimType} : @optional How to trim the blend.
* @field detach {boolean} : @optional Whether not to attach the blend(s) to the sides, creating new sheet bodies.
* @field showIsocurves {boolean} : Show graphical representation of a subset of isoparameteric curves of the created surface. Default `false`. @optional
* @field curveCount {number} : When `showIsocurves` is `true`, the number of curves to draw in each direction of the grid. Default `10`. @optional
* }}
*/
export const opFaceBlend = function(context is Context, id is Id, definition is map)
{
return @opFaceBlend(context, id, definition);
};
/**
* For edges, performs a fillet on the edge. For faces, performs a fillet on all edges adjacent to the face.
* @param id : @autocomplete `id + "fillet1"`
* @param definition {{
* @field entities {Query} : Edges and faces to fillet.
* @field radius {ValueWithUnits} : The fillet radius.
* @eg `1 * inch`
* @field tangentPropagation {boolean} : @optional
* `true` to propagate the fillet along edges tangent to those passed in. Default is `false`.
* @field crossSection {FilletCrossSection} : @optional
* Fillet cross section. One of `CIRCULAR`, `CONIC`, `CURVATURE`. Default is `CIRCULAR`.
* @field rho {number} : @requiredif {`crossSection` is `CONIC`.}
* A number between 0 and 1, specifying the Rho value of a conic fillet
* @ex `0.01` creates a flat, nearly-chamfered shape.
* @ex `0.99` creates a pointed, nearly-unchanged shape.
* @field magnitude {number} : @requiredif {`crossSection` is `CURVATURE`.}
* A number between 0 and 1, specifying the magnitude of curvature match.
* @field partialFilletBounds {array} : @optional An array of maps representing the boundaries of a partial fillet. Each map should
* contain a `boundaryEdge` query, a `boundaryParameter` value, a `isFlipped` boolean
* @ex `[{ "boundaryEdge" : edgeQuery0, "boundaryParameter" : 0.3, "isFlipped" : false }, { "boundaryEdge" : edgeQuery1, "boundaryParameter" : 0.6, "isFlipped" : true }]`
* @field isVariable {boolean} : @optional Fillet controls can be varied at vertices via `vertexSettings`. Default is `false`.
* @field vertexSettings {array} : @optional An array of maps representing fillet settings at specified vertices. Each map should
* contain a `vertex` query, a `vertexRadius` value, a `variableMagnitude` if the `crossSection` is
* `FilletCrossSection.CURVATURE`, and a `variableRho` if the `crossSection` is `FilletCrossSection.CONIC`.
* @ex `[{ "vertex" : vertexQuery0, "vertexRadius" : 1 * inch, "variableRho" : 0.2 }, { "vertex" : vertexQuery1, "vertexRadius" : 2 * inch, "variableRho" : 0.8 }]`
* @field pointOnEdgeSettings {array} : @optional An array of maps representing fillet settings at specified points on edges. Each map should
* contain an `edge` query, an `edgeParameter` value, a `pointOnEdgeRadius` value, a `pointOnEdgeVariablMagnitude` if the `crossSection` is
* `FilletCrossSection.CURVATURE`, and a `pointOnEdgeVariableRho` if the `crossSection` is `FilletCrossSection.CONIC`.
* @ex `[{ "edge" : edgeQuery0, "edgeParameter" : 0.3, "pointOnEdgeRadius" : 1 * inch }, { "edge" : edgeQuery1, "edgeParameter" : 0.6, "pointOnEdgeRadius" : 2 * inch }]`
* @field smoothTransition {boolean} : @requiredif { `isVariable` is `true` } Whether to create a smoother transition
* between each vertex.
* @field allowEdgeOverflow {boolean} : @optional Allow `opFillet` to modify nearby edges to maintain the fillet profile. Default is `true`.
* @field keepEdges {Query} : @optional Edges you do not want `opFillet` to modify if `allowEdgeOverflow` is `true`.
* @field smoothCorners {boolean} : @optional Allow `opFillet` to smooth all suitable corners and prevent creation of sharp edges. Default is `false`.
* @field smoothCornerExceptions {Query} : @optional Vertices you do not want `opFillet` to smooth if `smoothCorners` is `true`.
* @field createDetachedSurface {boolean} : @optional
* Operation does not modify the body of the selected edges, but results in surface geometry of fillet. Default is `false`.
* }}
*/
export const opFillet = function(context is Context, id is Id, definition is map)
{
return @opFillet(context, id, definition);
};
/**
* Generates a surface body from supplied boundary and internal constraints. The boundaries are defined as
* edge queries for each continuity constraint. The internal constraints may be defined as a set of support vertices.
* @param id : @autocomplete `id + "opFillSurface1"`
* @param definition {{
* @field edgesG0 {Query} : The edges with position constraints.
* @field edgesG1 {Query} : The edges with tangency constraints.
* @field edgesG2 {Query} : The edges with curvature constraints.
* @field guideVertices {Query} : The vertices the resulting surface is expected to interpolate.
* @field showIsocurves {boolean} : Show graphical representation of a subset of isoparameteric curves of the created surface. Default `false`. @optional
* @field curveCount {number} : When `showIsocurves` is `true`, the number of curves to draw in each direction of the grid. Default `10`. @optional
* }}
*/
export const opFillSurface = function(context is Context, id is Id, definition is map)
{
return @opFillSurface(context, id, definition);
};
/**
* Creates a 3D cubic spline curve through an array of 3D points.
* @param id : @autocomplete `id + "fitSpline1"`
* @param definition {{
* @field points {array} : An array of `Vector`s with length units for the spline to interpolate. If the first
* point is the same as the last point, the spline is closed.
* @eg
* ```
* [
* vector( 1, 1, 1) * inch,
* vector(-1, 1, -1) * inch,
* vector( 1, -1, -1) * inch,
* vector(-1, -1, 1) * inch,
* vector( 1, 1, 1) * inch
* ]
* ```
* @field parameters {array} : An array of doubles, parameters corresponding to the points. @optional
* @field startDerivative {Vector} : A `Vector` with length units that specifies the derivative at the start of
* the resulting spline (according to the `arcLengthParameterization` set to `false`). @optional
* @field endDerivative {Vector} : A `Vector` with length units that specifies the derivative at the end of
* the resulting spline. Ignored if spline is closed. @optional
* @field start2ndDerivative {Vector} : A `Vector` with length units that specifies the second derivative at the start of
* the resulting spline. Ignored if spline is closed, or if `startDerivative` is not defined @optional
* @field end2ndDerivative {Vector} : A `Vector` with length units that specifies the second derivative at the end of
* the resulting spline. Ignored if spline is closed, or if `endDerivative` is not defined @optional
* @field derivatives {map} : A map of derivatives at non-end points.
* Entries should be `index : derivative`, where `index` is an integer between 1 and `size(points) - 2`
* and `derivative` is a `Vector` that specifies the derivative at `points[index]`. @optional
* }}
*/
export const opFitSpline = function(context is Context, id is Id, definition is map)
{
return @opFitSpline(context, id, definition);
};
/**
* Reverses the orientation of sheet bodies.
* @param id : @autocomplete `id + "flipOrientation"`
* @param definition {{
* @field bodies {Query} : Sheet bodies whose orientation should be flipped.
* }}
*/
export const opFlipOrientation = function(context is Context, id is Id, definition is map)
{
return @opFlipOrientation(context, id, definition);
};
/**
* Creates a full round fillet, replacing the center face(s) with circular profile face(s) of varying radius, joining the selected side faces.
* @param id : @autocomplete `id + "fullRoundFillet1"`
* @param definition {{
* @field side1Face {Query} : A face on one side of the blend.
* @field side2Face {Query} : A face on another side of the blend.
* @field centerFaces {Query} : The face(s) to be replaced.
* @field tangentPropagation {boolean} : @optional
* `true` to propagate the fillet across side face tangencies. Default is `true`.
* }}
*/
export const opFullRoundFillet = function(context is Context, id is Id, definition is map)
{
return @opFullRoundFillet(context, id, definition);
};
/**
* Creates a helical and possibly spiral curve.
* @param id : @autocomplete `id + "helix1"`
* @param definition {{
* @field direction {Vector} : The direction of the helix axis.
* @eg `vector(0, 0, 1)`
* @field axisStart {Vector} : A point on the helix axis.
* @eg `vector(0, 0, 0) * inch`
* @field startPoint {Vector} : The start point of the infinite helix. Must be off the axis. This is the point at
* which the created curve would actually start if the first number of `interval` is 0.
* @eg `vector(1, 0, 0) * inch`
* @field interval {Vector} : An array of two numbers denoting the interval of the helix in terms of revolution counts.
* @eg `[0, 10]` will create a curve with 10 revolutions.
* @field clockwise {boolean} :
* @eg `true` if this is a clockwise helix when viewed along `direction`.
* @field helicalPitch {ValueWithUnits} : Distance along the axis between successive revolutions.
* @eg `0.1 * inch` will create a helix with 10 revolutions per inch.
* @eg `0 * inch` produces a planar Archimedean spiral.
* @field spiralPitch {ValueWithUnits} : Change in radius between successive revolutions.
* @eg `0 * inch` produces a helix that lies on a cylinder.
* }}
*/
export const opHelix = function(context is Context, id is Id, definition is map)
{
return @opHelix(context, id, definition);
};
/**
* Creates hole tools referencing a set of targets, optionally subtracting the tools from the targets. If some tools
* cannot be built, the operation will still succeed and indicate in its return value which holes failed to build. If no
* tools can be built, the operation will fail.
*
* @param id : @autocomplete `id + "hole1"`
* @param definition {{
* @field holeDefinition {HoleDefinition} : The definition of the shape of the desired holes.
* @eg `holeDefinition([holeProfile(HolePositionReference.AXIS_POINT, 0 * inch, 0.1 * inch), holeProfile(HolePositionReference.AXIS_POINT, 1 * inch, 0 * inch)])`
* @field axes {array} : An array of [Line]s each of whose `origin` represents the start position of a hole, and whose
* `direction` represents the drill direction of the hole.
* @eg `[line(vector(-1, -1, 0) * inch, vector(0, 0, -1)), line(vector(1, 1, 0) * inch, vector(0, 0, -1))]`
* @field identities {array} : @optional An array of queries, one per axis in `axes`, used to disambiguate each of
* the created holes. Each query should resolve to exactly one entity. Providing this information does not change
* the geometric outcome, but stabilizes references to the holes with respect to upstream changes to the model.
* @field targets {Query} : @requiredif { `holeDefinition` contains any `profiles` that do not reference
* `HolePositionReference.AXIS_POINT`, or if `subtractFromTargets` is `true` } A set of bodies to target. The
* shape of the produced holes is dependent on the shape of these targets (as specified in the supplied
* [HoleDefinition]), so the full set of targeted bodies should always be supplied, even if
* `subtractFromTargets` is `false`.
* @autocomplete `qAllModifiableSolidBodies()`
* @field subtractFromTargets {boolean} : @optional `true` if the hole geometry should be subtracted from the targets.
* `false` if the targets should not be modified, and the hole tools should be outputted as new solid bodies. Default
* is `true`. To subtract from a subset of targets, set this to `true` and supply a set of excluded targets as
* `targetsToExcludeFromSubtraction`. Removing the set of excluded targets from `targets` instead of using
* `targetsToExcludeFromSubtraction` is not the correct way to call this interface, and may result in the shape
* of the hole changing.
* @field targetsToExcludeFromSubtraction {Query} : @optional If supplied and `subtractFromTargets` is `true`,
* the given targets are excluded from the subtraction. Ignored if `subtractFromTargets` is `false`
* @field keepTools {boolean} : @optional If `subtractFromTargets` is `true`, controls whether the hole tools should
* be outputted as new solid bodies. Default is `false`. Ignored if `subtractFromTargets` is `false`; in that
* case hole tools are always outputted as new solid bodies.
* }}
*
* @return {array}: An array representing target intersection information for each hole. The array is aligned with the
* `axes` input. Each item in the array is a map containing a `boolean` field `success`, which
* indicates whether the tool was successfully built. If `success` is `true` the map will contain
* three additional entries: `targetToDepthExtremes`, `positionReferenceInfo` and `holeDepth`.
*
* The value of `targetToDepthExtremes` is a `map` mapping the `targets` that the given hole intersects
* to a map of intersection information for those targets. Only targets that are intersected by the
* hole will be present in the map. Each map key is a [Query] for one of the targets, and the
* corresponding value is itself a map of the form
* `{ "firstEntrance" : firstEntranceDistance, "fullEntrance" : fullEntranceDistance, "firstExit" : firstExitDistance, "fullExit" : fullExitDistance }`
*
* `firstEntranceDistance`, `fullEntranceDistance`, `firstExitDistance`, and `fullExitDistance` are
* [ValueWithUnits] representing distances, along the axis, from the origin point of the axis to
* various important markers on the infinite hole cylinder. `firstEntranceDistance` and
* `fullEntranceDistance` represent the range over which the infinite hole cylinder enters the part,
* with `firstEntranceDistance` representing where the infinite hole cylinder first enters the part,
* and `fullEntranceDistance` representing where the infinite hole cylinder fully enters the part.
* These values are distinct when the entrance face into the part is slanted (or otherwise irregular).
* `firstExitDistance` and `fullExitDistance` similarly represent the range over which the infinite
* hole cylinder exits the part.
*
* The value of `positionReferenceInfo` is a `map` whose keys are the [HolePositionReference]s found in
* the `holeDefinition` and whose value is a map of the form
* `{ "referenceRootStart" : referenceRootStartDistance, "referenceRootEnd" : referenceRootEndDistance, "target" : targetQuery }`.
*
* `referenceRootStartDistance` is a [ValueWithUnits] representing the distance, along the axis, from
* the origin point of the axis to the first coincidence between the infinite hole cylinder and the
* reference in question. `referenceRootEndDistance` is a similar measurement to the last coincidence
* between the infinite hole cylinder and the reference in question. For flat references, such as a
* `TARGET_START` referencing the top face of a cube, these two values will be the same. The values
* will differ for slanted (or otherwise irregular) references where the infinite hole cylinder
* interacts with the reference over a range, rather than at a single distance.
*
* `targetQuery` is a [Query] for the `target` that defines that position reference.
*
* `holeDepth` is a [ValueWithUnits] representing the distance, along the axis from the first entrance of
* the intersected targets to the termination entity. Used for references such as UP_TO_ENTITY and UP_TO_NEXT
* to get a calculated depth of a hole.
*
* @example
* ```
* // For an opHole operation creating two holes, both going into two stacked
* // parts, the first of which being 1 inch thick with a slightly slanted top
* // and flat bottom and the second being 3 inches thick with a flat top and
* // bottom, and the holeDefinition referencing both TARGET_START and
* // LAST_TARGET_START the return value may look like:
* [
* { // First hole (successful)
* "success" : true,
* "targetToDepthExtremes" : {
* (firstTargetQuery) : {
* "firstEntrance" : 0.1 * inch,
* "fullEntrance" : 0.3 * inch,
* "firstExit" : 1 * inch,
* "fullExit" : 1 * inch
* },
* (secondTargetQuery) : {
* "firstEntrance" : 1 * inch,
* "fullEntrance" : 1 * inch,
* "firstExit" : 4 * inch,
* "fullExit" : 4 * inch
* }
* },
* "positionReferenceInfo" : {
* HolePositionReference.TARGET_START : {
* "referenceRootStart" : 0.1 * inch,
* "referenceRootEnd" : 0.3 * inch,
* "target" : firstTargetQuery
* },
* HolePositionReference.LAST_TARGET_START : {
* "referenceRootStart" : 1 * inch,
* "referenceRootEnd" : 1 * inch,
* "target" : secondTargetQuery
* },
* }
* },
* { // Second hole (successful)
* "success" : true,
* "targetToDepthExtremes" : {
* (firstTargetQuery) : {
* "firstEntrance" : 0.4 * inch,
* "fullEntrance" : 0.6 * inch,
* "firstExit" : 1 * inch,
* "fullExit" : 1 * inch
* },
* (secondTargetQuery) : {
* "firstEntrance" : 1 * inch,
* "fullEntrance" : 1 * inch,
* "firstExit" : 4 * inch,
* "fullExit" : 4 * inch
* }
* },
* "positionReferenceInfo" : {
* HolePositionReference.TARGET_START : {
* "referenceRootStart" : 0.4 * inch,
* "referenceRootEnd" : 0.6 * inch,
* "target" : firstTargetQuery
* },
* HolePositionReference.LAST_TARGET_START : {
* "referenceRootStart" : 1 * inch,
* "referenceRootEnd" : 1 * inch,
* "target" : secondTargetQuery
* },
* }
* },
* { // Third hole (unsuccessful)
* "success" : false
* }
* ]
* ```
*/
export const opHole = function(context is Context, id is Id, definition is map) returns array
{
const result = @opHole(context, id, definition);
var out = [];
for (var rawMap in result)
{
const success = rawMap.success;
var processedMap = { "success" : success };
if (success)
{
// The rest of the fields are only returned if the hole tool was successfully built
const holeDepth = rawMap.holeDepth;
processedMap.holeDepth = holeDepth * meter;
var transientQueryToDepthExtremes = {};
for (var transientId, rawDepthExtremes in rawMap.targetToDepthExtremes)
{
const depthExtremes = {
"firstEntrance" : rawDepthExtremes.firstEntrance * meter,
"fullEntrance" : rawDepthExtremes.fullEntrance * meter,
"firstExit" : rawDepthExtremes.firstExit * meter,
"fullExit" : rawDepthExtremes.fullExit * meter
};
transientQueryToDepthExtremes[qTransient(transientId)] = depthExtremes;
}
processedMap.targetToDepthExtremes = transientQueryToDepthExtremes;
var referenceEnumToInfo = {};
for (var referenceString, rawInfo in rawMap.positionReferenceInfo)
{
referenceEnumToInfo[referenceString as HolePositionReference] = {
"referenceRootStart" : rawInfo.referenceRootStart * meter,
"referenceRootEnd" : rawInfo.referenceRootEnd * meter,
"target" : rawInfo.target == undefined ? undefined : qTransient(rawInfo.target)
};
}
processedMap.positionReferenceInfo = referenceEnumToInfo;
}
out = append(out, processedMap);
}
return out;
};
/* TODO: Example of importing from a blob tab */
/**