@snaptrude/plugin-core 0.9.16-networks-20261012.1 → 0.9.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/api-manifest.json +9711 -0
  3. package/dist/api/analysis/daylight.d.ts +5 -5
  4. package/dist/api/analysis/solar.d.ts +2 -2
  5. package/dist/api/core/camera/index.d.ts +0 -29
  6. package/dist/api/core/camera/index.d.ts.map +1 -1
  7. package/dist/api/core/zoom/index.d.ts +0 -13
  8. package/dist/api/core/zoom/index.d.ts.map +1 -1
  9. package/dist/api/design/create/bulk-items.d.ts +21 -40
  10. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  11. package/dist/api/design/create/index.d.ts +97 -120
  12. package/dist/api/design/create/index.d.ts.map +1 -1
  13. package/dist/api/design/create/opening-fields.d.ts +12 -13
  14. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  15. package/dist/api/design/doors/index.d.ts +24 -18
  16. package/dist/api/design/doors/index.d.ts.map +1 -1
  17. package/dist/api/design/family.d.ts +27 -797
  18. package/dist/api/design/family.d.ts.map +1 -1
  19. package/dist/api/design/index.d.ts +0 -16
  20. package/dist/api/design/index.d.ts.map +1 -1
  21. package/dist/api/design/query/index.d.ts +30 -30
  22. package/dist/api/design/selection/index.d.ts +10 -10
  23. package/dist/api/design/types/index.d.ts +24 -40
  24. package/dist/api/design/types/index.d.ts.map +1 -1
  25. package/dist/api/design/update/index.d.ts +3 -40
  26. package/dist/api/design/update/index.d.ts.map +1 -1
  27. package/dist/api/design/windows/index.d.ts +8 -8
  28. package/dist/api/design/windows/index.d.ts.map +1 -1
  29. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  30. package/dist/api/presentation/annotate.d.ts +22 -38
  31. package/dist/api/presentation/annotate.d.ts.map +1 -1
  32. package/dist/api/presentation/export.d.ts +5 -23
  33. package/dist/api/presentation/export.d.ts.map +1 -1
  34. package/dist/api/presentation/index.d.ts +21 -32
  35. package/dist/api/presentation/index.d.ts.map +1 -1
  36. package/dist/api/presentation/placedViews.d.ts +6 -106
  37. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  38. package/dist/api/presentation/sections.d.ts +461 -0
  39. package/dist/api/presentation/sections.d.ts.map +1 -0
  40. package/dist/api/presentation/shapes.d.ts +2 -2
  41. package/dist/api/presentation/sheets.d.ts +19 -175
  42. package/dist/api/presentation/sheets.d.ts.map +1 -1
  43. package/dist/api/presentation/views.d.ts +5 -103
  44. package/dist/api/presentation/views.d.ts.map +1 -1
  45. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  46. package/dist/index.cjs +2434 -3619
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.js +2421 -3501
  49. package/dist/index.js.map +1 -1
  50. package/package.json +1 -1
  51. package/scripts/generate-manifest.mjs +0 -5
  52. package/src/api/core/camera/index.ts +0 -29
  53. package/src/api/core/zoom/index.ts +0 -13
  54. package/src/api/design/create/bulk-items.ts +16 -23
  55. package/src/api/design/create/index.ts +119 -129
  56. package/src/api/design/create/opening-fields.ts +12 -15
  57. package/src/api/design/doors/index.ts +42 -58
  58. package/src/api/design/family.ts +32 -662
  59. package/src/api/design/index.ts +4 -34
  60. package/src/api/design/types/index.ts +24 -31
  61. package/src/api/design/update/index.ts +3 -41
  62. package/src/api/design/windows/index.ts +22 -40
  63. package/src/api/presentation/annotate.ts +58 -90
  64. package/src/api/presentation/export.ts +6 -32
  65. package/src/api/presentation/index.ts +23 -39
  66. package/src/api/presentation/placedViews.ts +28 -119
  67. package/src/api/presentation/sections.ts +420 -0
  68. package/src/api/presentation/sheets.ts +20 -181
  69. package/src/api/presentation/views.ts +6 -46
  70. package/dist/api/design/bim.d.ts +0 -209
  71. package/dist/api/design/bim.d.ts.map +0 -1
  72. package/dist/api/design/catalog.d.ts +0 -320
  73. package/dist/api/design/catalog.d.ts.map +0 -1
  74. package/dist/api/design/networks.d.ts +0 -1703
  75. package/dist/api/design/networks.d.ts.map +0 -1
  76. package/dist/api/presentation/drawingContract.d.ts +0 -32
  77. package/dist/api/presentation/drawingContract.d.ts.map +0 -1
  78. package/dist/api/presentation/drawings.d.ts +0 -3523
  79. package/dist/api/presentation/drawings.d.ts.map +0 -1
  80. package/dist/api/presentation/viewPresets.d.ts +0 -222
  81. package/dist/api/presentation/viewPresets.d.ts.map +0 -1
  82. package/src/api/design/bim.ts +0 -121
  83. package/src/api/design/catalog.ts +0 -203
  84. package/src/api/design/networks.ts +0 -607
  85. package/src/api/presentation/drawingContract.ts +0 -70
  86. package/src/api/presentation/drawings.ts +0 -1179
  87. package/src/api/presentation/viewPresets.ts +0 -241
  88. package/test/drawingContract.test.mjs +0 -288
@@ -1,7 +1,6 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../types"
3
3
  import { PluginSheetPosition } from "./sheets"
4
- import { PluginStandardDrawingScale } from "./drawingContract"
5
4
 
6
5
  /**
7
6
  * Placed views — the view shapes already laid out on the Present canvas.
@@ -142,21 +141,14 @@ export abstract class PluginPresentationPlacedViewsApi {
142
141
 
143
142
  /**
144
143
  * Set a placed view's architectural scale.
145
- * `scale` must be a standard architectural scale denominator (100 means 1:100)
146
- * in the project's unit system; any other value is rejected. Metric: 10, 20, 50,
147
- * 100, 150, 200, 250, 500, 1000. Imperial detail: 12, 16, 24, 32, 48, 64, 96, 128,
148
- * 192, 384, 768, 1536 (1" = 1' to 1/128" = 1'; 48 is 1/4" = 1', 96 is 1/8" = 1').
149
- * Imperial site: 120, 240, 360, 480, 600, 1200, 2400, 3600, 4800 (1" = 10' to
150
- * 1" = 400'). Pick the LARGEST standard scale (smallest denominator) at which the
151
- * view still fits its frame or sheet and its room labels stay readable: for a
152
- * building floor plan that is usually 1:50 to 1:200 (1/4" = 1' to 1/16" = 1').
153
- * Never use a site-sized scale (1:500 and up, 1/64" = 1' (768) and smaller,
154
- * 1" = 20' (240) and up) for a single building plan unless the user asked for it.
155
144
  *
156
145
  * Applies a standard architectural scale — the same write the placed view's
157
146
  * Scale dropdown performs. The view (and its labels) is resized about its
158
- * top-left corner so it prints at the given scale (the same validation as
159
- * `sheets.place`). 3D views have no architectural scale — calling this on
147
+ * top-left corner so it prints at the given scale. `scale` must be one of
148
+ * the standard values for the project's unit system (metric `10, 20, 50,
149
+ * 100, 150, 200, 250, 500, 1000`; imperial e.g. `48` for 1/4″ = 1′, `96`
150
+ * for 1/8″ = 1′, `120` for 1″ = 10′) — the same validation as
151
+ * `sheets.place`. 3D views have no architectural scale — calling this on
160
152
  * one throws. Requires Present mode to be open.
161
153
  *
162
154
  * @param shapeId - The placed view shape to set the scale of.
@@ -749,7 +741,7 @@ export type PluginPresentationPlacedViewsScaleArgs = z.infer<
749
741
  */
750
742
  export const PluginPresentationPlacedViewsSetScaleArgs = z.object({
751
743
  shapeId: z.string(),
752
- scale: PluginStandardDrawingScale,
744
+ scale: z.number().positive(),
753
745
  })
754
746
  export type PluginPresentationPlacedViewsSetScaleArgs = z.infer<
755
747
  typeof PluginPresentationPlacedViewsSetScaleArgs
@@ -802,28 +794,11 @@ export const PluginViewSettingCategory = z.enum([
802
794
  "Envelope",
803
795
  "Facade/Mass",
804
796
  "Dimension",
805
- "Grid",
806
- "Walls",
807
- "Columns",
808
- "Beams",
809
- "Doors",
810
- "Windows",
811
- "Floors",
812
- "Slabs",
813
- "Roofs",
814
- "Ceilings",
815
- "Staircase",
816
- "Furniture",
817
- "Families",
818
- "Underlay",
819
- "Overlay",
820
797
  "Reference Line",
821
798
  "Adjacency Line",
822
799
  "Landscape elements",
823
800
  ])
824
- export type PluginViewSettingCategory = z.infer<
825
- typeof PluginViewSettingCategory
826
- >
801
+ export type PluginViewSettingCategory = z.infer<typeof PluginViewSettingCategory>
827
802
 
828
803
  /** The 7 line dash styles (mirrors the host's LINE_STYLES). */
829
804
  export const PluginViewLineStyle = z.enum([
@@ -849,7 +824,7 @@ export type PluginViewLineStyle = z.infer<typeof PluginViewLineStyle>
849
824
  * | `lineStyle` | {@linkcode PluginViewLineStyle}? | Dash pattern |
850
825
  * | `lineColor` | `string`? | Line color, 6-digit hex (`#` optional) |
851
826
  * | `dashLength` | `number`? | Dash-length multiplier (> 0; `1` = default) |
852
- * | `lineWidth` | `number`? | Single line weight in mm (Dimension: 0.05–0.7; otherwise non-negative) |
827
+ * | `lineWidth` | `number`? | Single line weight in mm (categories without cut/projection) |
853
828
  * | `cutWidth` | `number`? | Cut-line weight in mm |
854
829
  * | `projectionWidth` | `number`? | Projection-line weight in mm |
855
830
  * | `treeLineWidth` | `number`? | Tree line weight in mm (Landscape) |
@@ -882,13 +857,8 @@ export const PluginPlacedViewStylePatch = z
882
857
  colorMode: z
883
858
  .string()
884
859
  .refine(
885
- (v) =>
886
- ["department", "texture", "monochrome"].includes(v) ||
887
- v.startsWith("tag:"),
888
- {
889
- message:
890
- "colorMode must be department, texture, monochrome, or tag:<tagCategoryId>",
891
- },
860
+ (v) => ["department", "texture", "monochrome"].includes(v) || v.startsWith("tag:"),
861
+ { message: "colorMode must be department, texture, monochrome, or tag:<tagCategoryId>" },
892
862
  )
893
863
  .optional(),
894
864
  opacity: z.number().finite().min(0).max(100).optional(),
@@ -900,42 +870,13 @@ export const PluginPlacedViewStylePatch = z
900
870
  viewStyle: z.enum(["NONE", "FILLET", "BUBBLE"]).optional(),
901
871
  radius: z.number().finite().min(0).optional(),
902
872
  inset: z.number().finite().min(0).optional(),
903
- // Dimension lengths are plotted paper millimetres, independent of drawing scale.
904
- markerKind: z
905
- .enum(["architecturalTick", "openArrow", "closedArrow"])
906
- .optional(),
907
- markerSize: z.number().finite().min(0.5).max(6).optional(),
908
- extensionLineVisible: z.boolean().optional(),
909
- extensionLineStyle: PluginViewLineStyle.optional(),
910
- extensionGap: z.number().finite().min(0).max(10).optional(),
911
- extensionOvershoot: z.number().finite().min(0).max(10).optional(),
912
- textColor: z
913
- .string()
914
- .regex(/^(inherit|#[0-9a-fA-F]{6})$/)
915
- .optional(),
916
- textGap: z.number().finite().min(0).max(10).optional(),
917
- textPlacement: z.literal("above").optional(),
918
- textMask: z.boolean().optional(),
919
- textMaskColor: z
920
- .string()
921
- .regex(/^#[0-9a-fA-F]{6}$/)
922
- .optional(),
923
- textMaskPadding: z.number().finite().min(0).max(5).optional(),
924
873
  })
925
874
  .strict()
926
- .refine((p) => Object.keys(p).length > 0, {
927
- message: "patch must set at least one setting",
928
- })
929
- export type PluginPlacedViewStylePatch = z.infer<
930
- typeof PluginPlacedViewStylePatch
931
- >
875
+ .refine((p) => Object.keys(p).length > 0, { message: "patch must set at least one setting" })
876
+ export type PluginPlacedViewStylePatch = z.infer<typeof PluginPlacedViewStylePatch>
932
877
 
933
878
  /** Label types that carry typography in a category's Text tab. */
934
- export const PluginViewLabelType = z.enum([
935
- "objectLabels",
936
- "department",
937
- "areas",
938
- ])
879
+ export const PluginViewLabelType = z.enum(["objectLabels", "department", "areas"])
939
880
  export type PluginViewLabelType = z.infer<typeof PluginViewLabelType>
940
881
 
941
882
  /** Typography patch for one label type. `fontSize` is in px. */
@@ -944,10 +885,7 @@ const PluginViewFontVariantPatch = z
944
885
  fontFamily: z.string().min(1).optional(),
945
886
  fontWeight: z
946
887
  .string()
947
- .regex(
948
- /^\d{3}$/,
949
- 'fontWeight must be a numeric string like "400" or "700"',
950
- )
888
+ .regex(/^\d{3}$/, 'fontWeight must be a numeric string like "400" or "700"')
951
889
  .optional(),
952
890
  fontStyle: z.enum(["normal", "italic"]).optional(),
953
891
  fontSize: z.number().finite().positive().max(200).optional(),
@@ -972,12 +910,8 @@ export const PluginPlacedViewFontStylesPatch = z
972
910
  areas: PluginViewFontVariantPatch.optional(),
973
911
  })
974
912
  .strict()
975
- .refine((p) => Object.keys(p).length > 0, {
976
- message: "patch must set at least one field",
977
- })
978
- export type PluginPlacedViewFontStylesPatch = z.infer<
979
- typeof PluginPlacedViewFontStylesPatch
980
- >
913
+ .refine((p) => Object.keys(p).length > 0, { message: "patch must set at least one field" })
914
+ export type PluginPlacedViewFontStylesPatch = z.infer<typeof PluginPlacedViewFontStylesPatch>
981
915
 
982
916
  /** Resolved font styles for one label type (fontSize in px). */
983
917
  export type PluginViewFontVariant = {
@@ -1027,25 +961,12 @@ export type PluginPlacedViewStylesResult = {
1027
961
  }
1028
962
 
1029
963
  /** Arguments for {@link PluginPresentationPlacedViewsApi.updateStyles}. */
1030
- export const PluginPlacedViewsUpdateStylesArgs = z
1031
- .object({
1032
- shapeId: z.string().min(1),
1033
- category: PluginViewSettingCategory,
1034
- patch: PluginPlacedViewStylePatch,
1035
- })
1036
- .refine(
1037
- ({ category, patch }) =>
1038
- category !== "Dimension" ||
1039
- patch.lineWidth === undefined ||
1040
- (patch.lineWidth >= 0.05 && patch.lineWidth <= 0.7),
1041
- {
1042
- message: "Dimension lineWidth must be between 0.05 and 0.7 paper mm",
1043
- path: ["patch", "lineWidth"],
1044
- },
1045
- )
1046
- export type PluginPlacedViewsUpdateStylesArgs = z.infer<
1047
- typeof PluginPlacedViewsUpdateStylesArgs
1048
- >
964
+ export const PluginPlacedViewsUpdateStylesArgs = z.object({
965
+ shapeId: z.string().min(1),
966
+ category: PluginViewSettingCategory,
967
+ patch: PluginPlacedViewStylePatch,
968
+ })
969
+ export type PluginPlacedViewsUpdateStylesArgs = z.infer<typeof PluginPlacedViewsUpdateStylesArgs>
1049
970
 
1050
971
  /** Arguments for {@link PluginPresentationPlacedViewsApi.updateFontStyles}. */
1051
972
  export const PluginPlacedViewsUpdateFontStylesArgs = z.object({
@@ -1090,9 +1011,7 @@ export const PluginPlacedViewsMoveLabelArgs = z.object({
1090
1011
  labelId: z.string().min(1),
1091
1012
  position: PluginSheetPosition,
1092
1013
  })
1093
- export type PluginPlacedViewsMoveLabelArgs = z.infer<
1094
- typeof PluginPlacedViewsMoveLabelArgs
1095
- >
1014
+ export type PluginPlacedViewsMoveLabelArgs = z.infer<typeof PluginPlacedViewsMoveLabelArgs>
1096
1015
 
1097
1016
  /** Arguments for {@link PluginPresentationPlacedViewsApi.setLabelHidden}. */
1098
1017
  export const PluginPlacedViewsSetLabelHiddenArgs = z.object({
@@ -1162,18 +1081,14 @@ export const PluginPlacedViewsMoveShapeArgs = z.object({
1162
1081
  position: PluginSheetPosition,
1163
1082
  sheetId: z.string().optional(),
1164
1083
  })
1165
- export type PluginPlacedViewsMoveShapeArgs = z.infer<
1166
- typeof PluginPlacedViewsMoveShapeArgs
1167
- >
1084
+ export type PluginPlacedViewsMoveShapeArgs = z.infer<typeof PluginPlacedViewsMoveShapeArgs>
1168
1085
 
1169
1086
  /** Arguments for {@link PluginPresentationPlacedViewsApi.resizeShape}. */
1170
1087
  export const PluginPlacedViewsResizeShapeArgs = z.object({
1171
1088
  shapeId: z.string().min(1),
1172
1089
  factor: z.number().finite().min(0.01).max(100),
1173
1090
  })
1174
- export type PluginPlacedViewsResizeShapeArgs = z.infer<
1175
- typeof PluginPlacedViewsResizeShapeArgs
1176
- >
1091
+ export type PluginPlacedViewsResizeShapeArgs = z.infer<typeof PluginPlacedViewsResizeShapeArgs>
1177
1092
 
1178
1093
  /** Arguments for {@link PluginPresentationPlacedViewsApi.rotateShape}. */
1179
1094
  export const PluginPresentationPlacedViewsRotateShapeArgs = z.object({
@@ -1188,24 +1103,18 @@ export type PluginPresentationPlacedViewsRotateShapeArgs = z.infer<
1188
1103
  export const PluginPlacedViewsDeleteShapesArgs = z.object({
1189
1104
  shapeIds: z.array(z.string().min(1)).min(1).max(500),
1190
1105
  })
1191
- export type PluginPlacedViewsDeleteShapesArgs = z.infer<
1192
- typeof PluginPlacedViewsDeleteShapesArgs
1193
- >
1106
+ export type PluginPlacedViewsDeleteShapesArgs = z.infer<typeof PluginPlacedViewsDeleteShapesArgs>
1194
1107
 
1195
1108
  /** Arguments for {@link PluginPresentationPlacedViewsApi.setOpacity}. */
1196
1109
  export const PluginPlacedViewsSetOpacityArgs = z.object({
1197
1110
  shapeId: z.string().min(1),
1198
1111
  opacity: z.number().finite().min(0).max(1),
1199
1112
  })
1200
- export type PluginPlacedViewsSetOpacityArgs = z.infer<
1201
- typeof PluginPlacedViewsSetOpacityArgs
1202
- >
1113
+ export type PluginPlacedViewsSetOpacityArgs = z.infer<typeof PluginPlacedViewsSetOpacityArgs>
1203
1114
 
1204
1115
  /** Arguments for {@link PluginPresentationPlacedViewsApi.setMask}. */
1205
1116
  export const PluginPlacedViewsSetMaskArgs = z.object({
1206
1117
  shapeId: z.string().min(1),
1207
1118
  enabled: z.boolean(),
1208
1119
  })
1209
- export type PluginPlacedViewsSetMaskArgs = z.infer<
1210
- typeof PluginPlacedViewsSetMaskArgs
1211
- >
1120
+ export type PluginPlacedViewsSetMaskArgs = z.infer<typeof PluginPlacedViewsSetMaskArgs>
@@ -0,0 +1,420 @@
1
+ import * as z from "zod"
2
+ import type { PluginApiReturn } from "../../types"
3
+ import { Vec3Components } from "../../handles"
4
+
5
+ /** A point on the plan: world `x` and `z` in babylon units. */
6
+ export const PluginSectionPoint = z
7
+ .object({ x: z.number().finite(), z: z.number().finite() })
8
+ .strict()
9
+ export type PluginSectionPoint = z.infer<typeof PluginSectionPoint>
10
+
11
+ /**
12
+ * A section: a line drawn on the plan that cuts the model and looks one way
13
+ * along it.
14
+ *
15
+ * | Property | Type | Description |
16
+ * |---|---|---|
17
+ * | `sectionId` | `string` | The section's id |
18
+ * | `name` | `string` | Its name in the Views panel ("Section 1") |
19
+ * | `tagLabel` | `string` | What its heads are marked with on the plan ("A") |
20
+ * | `buildingId` | `string` | The building it belongs to |
21
+ * | `start` | {@linkcode PluginSectionPoint} | First head on the plan |
22
+ * | `end` | {@linkcode PluginSectionPoint} | Second head on the plan |
23
+ * | `isFlipped` | `boolean` | Looks the other way along the line |
24
+ * | `depth` | `number` | How far behind the line the view keeps, babylon units |
25
+ * | `base` | `number` | Bottom of the slice, world Y |
26
+ * | `top` | `number` | Top of the slice, world Y |
27
+ * | `isHidden` | `boolean` | The line is hidden on the plan |
28
+ * | `isLocked` | `boolean` | Geometry edits are refused |
29
+ * | `isActive` | `boolean` | It is the section view open now |
30
+ */
31
+ export const PluginSection = z.object({
32
+ sectionId: z.string(),
33
+ name: z.string(),
34
+ tagLabel: z.string(),
35
+ buildingId: z.string(),
36
+ start: PluginSectionPoint,
37
+ end: PluginSectionPoint,
38
+ isFlipped: z.boolean(),
39
+ depth: z.number(),
40
+ base: z.number(),
41
+ top: z.number(),
42
+ isHidden: z.boolean(),
43
+ isLocked: z.boolean(),
44
+ isActive: z.boolean(),
45
+ })
46
+ export type PluginSection = z.infer<typeof PluginSection>
47
+
48
+ export const PluginSectionIdArgs = z
49
+ .object({ sectionId: z.string().min(1) })
50
+ .strict()
51
+ export type PluginSectionIdArgs = z.infer<typeof PluginSectionIdArgs>
52
+
53
+ /**
54
+ * Options for {@linkcode PluginPresentationSectionsApi.create}.
55
+ *
56
+ * | Property | Type | Description |
57
+ * |---|---|---|
58
+ * | `name` | `string \| undefined` | Name in the Views panel (default: the next "Section N") |
59
+ * | `tagLabel` | `string \| undefined` | Head mark on the plan (default: the next free mark) |
60
+ * | `depth` | `number \| undefined` | How far behind the line the view keeps (default: to the far side of the model) |
61
+ * | `base` | `number \| undefined` | Bottom of the slice, world Y (default: the building's base) |
62
+ * | `top` | `number \| undefined` | Top of the slice, world Y (default: the building's top) |
63
+ * | `buildingId` | `string \| undefined` | Building it belongs to (default: the active one) |
64
+ * | `isActive` | `boolean \| undefined` | Open the section view once created (default `false`) |
65
+ */
66
+ export const PluginSectionCreateOptions = z
67
+ .object({
68
+ name: z.string().trim().min(1).optional(),
69
+ tagLabel: z.string().trim().min(1).optional(),
70
+ depth: z.number().finite().positive().optional(),
71
+ base: z.number().finite().optional(),
72
+ top: z.number().finite().optional(),
73
+ buildingId: z.string().min(1).optional(),
74
+ isActive: z.boolean().optional(),
75
+ })
76
+ .strict()
77
+ export type PluginSectionCreateOptions = z.infer<
78
+ typeof PluginSectionCreateOptions
79
+ >
80
+
81
+ export const PluginSectionCreateArgs = z
82
+ .object({
83
+ start: PluginSectionPoint,
84
+ end: PluginSectionPoint,
85
+ options: PluginSectionCreateOptions.optional(),
86
+ })
87
+ .strict()
88
+ export type PluginSectionCreateArgs = z.infer<typeof PluginSectionCreateArgs>
89
+
90
+ /**
91
+ * The fields to change in {@linkcode PluginPresentationSectionsApi.update};
92
+ * omitted fields keep their value.
93
+ *
94
+ * | Property | Type | Description |
95
+ * |---|---|---|
96
+ * | `name` | `string \| undefined` | Name in the Views panel |
97
+ * | `tagLabel` | `string \| undefined` | Head mark on the plan |
98
+ * | `start` | {@linkcode PluginSectionPoint} `\| undefined` | First head |
99
+ * | `end` | {@linkcode PluginSectionPoint} `\| undefined` | Second head |
100
+ * | `isFlipped` | `boolean \| undefined` | Look the other way; without `depth`, the depth re-spans the model the new way |
101
+ * | `depth` | `number \| undefined` | View depth behind the line, > 0 |
102
+ * | `base` | `number \| undefined` | Bottom of the slice, world Y |
103
+ * | `top` | `number \| undefined` | Top of the slice, world Y; above `base` |
104
+ * | `isHidden` | `boolean \| undefined` | Hide the line on the plan |
105
+ */
106
+ export const PluginSectionPatch = z
107
+ .object({
108
+ name: z.string().trim().min(1).optional(),
109
+ tagLabel: z.string().trim().min(1).optional(),
110
+ start: PluginSectionPoint.optional(),
111
+ end: PluginSectionPoint.optional(),
112
+ isFlipped: z.boolean().optional(),
113
+ depth: z.number().finite().positive().optional(),
114
+ base: z.number().finite().optional(),
115
+ top: z.number().finite().optional(),
116
+ isHidden: z.boolean().optional(),
117
+ })
118
+ .strict()
119
+ export type PluginSectionPatch = z.infer<typeof PluginSectionPatch>
120
+
121
+ export const PluginSectionUpdateArgs = PluginSectionIdArgs.extend({
122
+ patch: PluginSectionPatch,
123
+ })
124
+ export type PluginSectionUpdateArgs = z.infer<typeof PluginSectionUpdateArgs>
125
+
126
+ /**
127
+ * Options for {@linkcode PluginPresentationSectionsApi.getCut}.
128
+ *
129
+ * | Property | Type | Description |
130
+ * |---|---|---|
131
+ * | `maxSegmentsPerElement` | `number \| undefined` | Outline segments to return per element, 0 to 2000 (default 0: none) |
132
+ */
133
+ export const PluginSectionCutOptions = z
134
+ .object({
135
+ maxSegmentsPerElement: z.number().int().min(0).max(2000).optional(),
136
+ })
137
+ .strict()
138
+ export type PluginSectionCutOptions = z.infer<typeof PluginSectionCutOptions>
139
+
140
+ export const PluginSectionCutArgs = PluginSectionIdArgs.extend({
141
+ options: PluginSectionCutOptions.optional(),
142
+ })
143
+ export type PluginSectionCutArgs = z.infer<typeof PluginSectionCutArgs>
144
+
145
+ /**
146
+ * A rect on the cutting plane. `u` runs along the line from the first head
147
+ * (0) to the second (the line's length); `v` is world Y.
148
+ */
149
+ export const PluginSectionExtent = z.object({
150
+ uMin: z.number(),
151
+ uMax: z.number(),
152
+ vMin: z.number(),
153
+ vMax: z.number(),
154
+ })
155
+ export type PluginSectionExtent = z.infer<typeof PluginSectionExtent>
156
+
157
+ /**
158
+ * One element a section cuts.
159
+ *
160
+ * | Property | Type | Description |
161
+ * |---|---|---|
162
+ * | `entityId` | `string` | The element's component id (a `ComponentHandle`) |
163
+ * | `type` | `string` | Its component type ("wall", "slab", "mass", …) |
164
+ * | `area` | `number` | Cut area inside the section's extents, square babylon units |
165
+ * | `perimeter` | `number` | Length of the cut outline inside the extents, babylon units |
166
+ * | `extent` | {@linkcode PluginSectionExtent} | Where the cut lies on the plane |
167
+ * | `isHatched` | `boolean` | `false` for masses and voids, which the drawing leaves unfilled |
168
+ * | `isOpening` | `boolean` | Doors and windows, which the drawing fills white |
169
+ * | `segments` | `[u0, v0, u1, v1][]` | Cut outline segments, when asked for |
170
+ * | `droppedSegmentCount` | `number` | Segments not returned because of `maxSegmentsPerElement` |
171
+ */
172
+ export const PluginSectionCutElement = z.object({
173
+ entityId: z.string(),
174
+ type: z.string(),
175
+ area: z.number(),
176
+ perimeter: z.number(),
177
+ extent: PluginSectionExtent,
178
+ isHatched: z.boolean(),
179
+ isOpening: z.boolean(),
180
+ segments: z.array(z.tuple([z.number(), z.number(), z.number(), z.number()])),
181
+ droppedSegmentCount: z.number().int(),
182
+ })
183
+ export type PluginSectionCutElement = z.infer<typeof PluginSectionCutElement>
184
+
185
+ /**
186
+ * What a section cuts, from {@linkcode PluginPresentationSectionsApi.getCut}.
187
+ *
188
+ * | Property | Type | Description |
189
+ * |---|---|---|
190
+ * | `sectionId` | `string` | The section |
191
+ * | `origin` | `{ x, y, z }` | World point at `u = 0, v = 0`: the first head, at Y 0 |
192
+ * | `uAxis` | `{ x, y, z }` | Unit direction of `u`: from the first head to the second |
193
+ * | `normal` | `{ x, y, z }` | Unit direction the section looks |
194
+ * | `extent` | {@linkcode PluginSectionExtent} | The cut rect: `u` 0 to the line's length, `v` base to top |
195
+ * | `elements` | {@linkcode PluginSectionCutElement}`[]` | What it cuts, largest area first |
196
+ * | `candidateCount` | `number` | Meshes near the plane that were tested |
197
+ * | `durationInMs` | `number` | Time the query took |
198
+ */
199
+ export const PluginSectionCut = z.object({
200
+ sectionId: z.string(),
201
+ origin: Vec3Components,
202
+ uAxis: Vec3Components,
203
+ normal: Vec3Components,
204
+ extent: PluginSectionExtent,
205
+ elements: z.array(PluginSectionCutElement),
206
+ candidateCount: z.number().int(),
207
+ durationInMs: z.number(),
208
+ })
209
+ export type PluginSectionCut = z.infer<typeof PluginSectionCut>
210
+
211
+ /**
212
+ * Sections: lines on the plan that cut the model, each with its own section
213
+ * view.
214
+ *
215
+ * A section is a cutting plane through its line, vertical, looking one way
216
+ * along it; its view keeps `depth` behind the line, between `base` and `top`.
217
+ * Create, read, edit and delete sections (`create`, `list`, `get`, `update`,
218
+ * `delete`), open one's view (`setActive`, `getActive`), and ask what it cuts
219
+ * (`getCut`): which elements the plane passes through, with the area, outline
220
+ * and extent of each cut. `getCut` is computed from the model, needs no open
221
+ * view and changes nothing.
222
+ *
223
+ * Writes are write-gated and each call is one undo step. Geometry edits
224
+ * (`start`, `end`, `isFlipped`, `depth`, `base`, `top`) are refused on a locked
225
+ * section; names, marks and hiding are not, and repeating a locked section's
226
+ * geometry unchanged is not a geometry edit. View-only collaborators cannot
227
+ * write.
228
+ *
229
+ * Positions are world coordinates in internal `babylon` units (1 unit =
230
+ * 0.254 m, Y up); a section's heads are plan points `{ x, z }`. Accessed via
231
+ * `snaptrude.presentation.sections`.
232
+ */
233
+ export abstract class PluginPresentationSectionsApi {
234
+ constructor() {}
235
+
236
+ /**
237
+ * List the project's sections, in Views panel order.
238
+ *
239
+ * @returns Every {@linkcode PluginSection} (`[]` when there are none).
240
+ *
241
+ * @examplePrompt Which sections are there?
242
+ * @examplePrompt List the section lines in this project
243
+ * @examplePrompt Is there a section through the stair?
244
+ *
245
+ * # Example
246
+ * ```ts
247
+ * const sections = await snaptrude.presentation.sections.list()
248
+ * ```
249
+ */
250
+ public abstract list(): PluginApiReturn<PluginSection[]>
251
+
252
+ /**
253
+ * Get one section by id.
254
+ *
255
+ * @param sectionId - The section's id
256
+ * @returns The {@linkcode PluginSection}, or `null` when there is none with that id.
257
+ *
258
+ * @examplePrompt Where does Section A run?
259
+ * @examplePrompt How deep is this section?
260
+ *
261
+ * # Example
262
+ * ```ts
263
+ * const section = await snaptrude.presentation.sections.get(sectionId)
264
+ * console.log(section?.start, section?.end)
265
+ * ```
266
+ */
267
+ public abstract get(sectionId: string): PluginApiReturn<PluginSection | null>
268
+
269
+ /**
270
+ * Get the section whose view is open.
271
+ *
272
+ * @returns The open {@linkcode PluginSection}, or `null` when no section view is open.
273
+ *
274
+ * @examplePrompt Which section am I looking at?
275
+ *
276
+ * # Example
277
+ * ```ts
278
+ * const open = await snaptrude.presentation.sections.getActive()
279
+ * ```
280
+ */
281
+ public abstract getActive(): PluginApiReturn<PluginSection | null>
282
+
283
+ /**
284
+ * Open a section's view, or close the open one with `null`. Opening frames
285
+ * the section's saved camera, or a straight-on view when it has none.
286
+ * Closing returns to 3D; with no section view open, `null` does nothing. Not
287
+ * an edit: nothing is added to the undo history.
288
+ *
289
+ * @param sectionId - The section to open, or `null` to close the section view
290
+ * @returns The open {@linkcode PluginSection}, or `null` after closing.
291
+ * @throws HANDLE_INVALID when there is no section with that id.
292
+ *
293
+ * @examplePrompt Open Section A
294
+ * @examplePrompt Show me the section through the atrium
295
+ * @examplePrompt Close the section view
296
+ *
297
+ * # Example
298
+ * ```ts
299
+ * await snaptrude.presentation.sections.setActive(section.sectionId)
300
+ * await snaptrude.presentation.sections.setActive(null)
301
+ * ```
302
+ */
303
+ public abstract setActive(
304
+ sectionId: string | null,
305
+ ): PluginApiReturn<PluginSection | null>
306
+
307
+ /**
308
+ * Draw a section line from `start` to `end` on the plan. The section looks
309
+ * along the line's direction turned a quarter turn — a line drawn toward +x
310
+ * looks toward +z; flip it with `update(id, { isFlipped: true })`. Its slice
311
+ * defaults to the building's full height and its depth to the far side of
312
+ * the model. Write-gated; one undo step.
313
+ *
314
+ * @param start - First head, a plan point `{ x, z }`
315
+ * @param end - Second head; must differ from `start`
316
+ * @param options - Name, mark, depth, slice, building and whether to open it ({@linkcode PluginSectionCreateOptions})
317
+ * @returns The new {@linkcode PluginSection}.
318
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled. VALIDATION when
319
+ * `start` and `end` coincide or `top` is not above `base`. PRECONDITION_FAILED
320
+ * when the project is view-only or has no model to cut.
321
+ *
322
+ * @examplePrompt Cut a section through the middle of the building, east to west
323
+ * @examplePrompt Add a section across the stair core
324
+ * @examplePrompt Draw a longitudinal section and open it
325
+ *
326
+ * # Example
327
+ * ```ts
328
+ * const section = await snaptrude.presentation.sections.create(
329
+ * { x: -40, z: 10 },
330
+ * { x: 40, z: 10 },
331
+ * { name: "Longitudinal", isActive: true },
332
+ * )
333
+ * ```
334
+ */
335
+ public abstract create(
336
+ start: PluginSectionPoint,
337
+ end: PluginSectionPoint,
338
+ options?: PluginSectionCreateOptions,
339
+ ): PluginApiReturn<PluginSection>
340
+
341
+ /**
342
+ * Change a section. Only the given fields change; the whole patch is one
343
+ * undo step. Flipping without a `depth` carries the depth to the far side of
344
+ * the model in the new direction, as `create` does. Write-gated.
345
+ *
346
+ * @param sectionId - The section's id
347
+ * @param patch - The fields to change ({@linkcode PluginSectionPatch})
348
+ * @returns The updated {@linkcode PluginSection}.
349
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled. HANDLE_INVALID when
350
+ * there is no section with that id. VALIDATION when the heads coincide or `top`
351
+ * is not above `base`. PRECONDITION_FAILED when the project is view-only, or the
352
+ * patch changes a locked section's geometry.
353
+ *
354
+ * @examplePrompt Make Section A look the other way
355
+ * @examplePrompt Only show the ground floor in this section
356
+ * @examplePrompt Rename the section to "Through atrium"
357
+ * @examplePrompt Move the section line 5 m north
358
+ *
359
+ * # Example
360
+ * ```ts
361
+ * await snaptrude.presentation.sections.update(sectionId, {
362
+ * isFlipped: true,
363
+ * depth: 60,
364
+ * })
365
+ * ```
366
+ */
367
+ public abstract update(
368
+ sectionId: string,
369
+ patch: PluginSectionPatch,
370
+ ): PluginApiReturn<PluginSection>
371
+
372
+ /**
373
+ * Delete a section. Closes its view first if it is open. Write-gated; one
374
+ * undo step.
375
+ *
376
+ * @param sectionId - The section's id
377
+ * @returns `true` once it has been deleted.
378
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled. HANDLE_INVALID when
379
+ * there is no section with that id. PRECONDITION_FAILED when the project is view-only.
380
+ *
381
+ * @examplePrompt Delete Section B
382
+ *
383
+ * # Example
384
+ * ```ts
385
+ * await snaptrude.presentation.sections.delete(sectionId)
386
+ * ```
387
+ */
388
+ public abstract delete(sectionId: string): PluginApiReturn<boolean>
389
+
390
+ /**
391
+ * What a section cuts: every element its cutting plane passes through within
392
+ * the section's extents, with the cut's area, outline length and extent on
393
+ * the plane, largest first. Computed from the model, not from the drawing, so
394
+ * it needs no open view and works however the section is shown; furniture is
395
+ * left out, as in the drawing, and so is anything hidden in the model. Areas are exact for closed solids. Repeated
396
+ * calls reuse the cuts of elements that have not changed. Read-only.
397
+ *
398
+ * @param sectionId - The section's id
399
+ * @param options - Whether to return outline segments ({@linkcode PluginSectionCutOptions})
400
+ * @returns The {@linkcode PluginSectionCut}.
401
+ * @throws HANDLE_INVALID when there is no section with that id.
402
+ *
403
+ * @examplePrompt Which walls does Section A cut?
404
+ * @examplePrompt How thick is the slab where the section crosses it?
405
+ * @examplePrompt Does this section go through the stair?
406
+ * @examplePrompt What is the floor-to-floor height in this section?
407
+ *
408
+ * # Example
409
+ * ```ts
410
+ * const cut = await snaptrude.presentation.sections.getCut(sectionId)
411
+ * const walls = cut.elements.filter((element) => element.type === "wall")
412
+ * const thickest = walls[0]
413
+ * console.log(thickest.extent.uMax - thickest.extent.uMin)
414
+ * ```
415
+ */
416
+ public abstract getCut(
417
+ sectionId: string,
418
+ options?: PluginSectionCutOptions,
419
+ ): PluginApiReturn<PluginSectionCut>
420
+ }