Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Preserve reusable assembly definitions in AP242 round trips

Yuechen Li078e45746662
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index ba36911d..13985936 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -3300,7 +3300,7 @@ public static class CliRunner
if (!export.IsSuccess) { foreach (var diagnostic in export.Diagnostics) stderr.WriteLine($"{diagnostic.Source}: {diagnostic.Message}"); return 1; }
var fullOutput = Path.GetFullPath(output); Directory.CreateDirectory(Path.GetDirectoryName(fullOutput)!); File.WriteAllText(fullOutput, export.Value);
var hash = Convert.ToHexString(SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(export.Value)));
- stdout.WriteLine(json ? JsonSerializer.Serialize(new { success = true, output = fullOutput, sha256 = hash, occurrenceCount = compilation.Ir!.Instances.Count - 1, definitionCount = compilation.Geometry!.Artifact.Definitions.Count }, JsonOptions) : $"Exported native AP242 assembly: {fullOutput} sha256={hash}");
+ stdout.WriteLine(json ? JsonSerializer.Serialize(new { success = true, output = fullOutput, sha256 = hash, occurrenceCount = compilation.Ir!.Instances.Count - 1, definitionCount = compilation.Geometry!.Artifact.Definitions.Count + (compilation.Ir.AssemblyDefinitions?.Count ?? 0) }, JsonOptions) : $"Exported native AP242 assembly: {fullOutput} sha256={hash}");
return 0;
}
diff --git a/Aetheris.Kernel.Core/Step242/Step242AssemblyProductStructure.cs b/Aetheris.Kernel.Core/Step242/Step242AssemblyProductStructure.cs
index 122877b4..640aa726 100644
--- a/Aetheris.Kernel.Core/Step242/Step242AssemblyProductStructure.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242AssemblyProductStructure.cs
@@ -8,7 +8,7 @@ using Aetheris.Kernel.Core.Results;
namespace Aetheris.Kernel.Core.Step242;
-public sealed record Step242AssemblyDefinition(string StableId, string Name, BrepBody Body);
+public sealed record Step242AssemblyDefinition(string StableId, string Name, BrepBody? Body);
public sealed record Step242AssemblyOccurrence(
string StableId,
@@ -55,9 +55,9 @@ public static class Step242AssemblyExporter
var entities = new List<string>();
var definitionRefs = new Dictionary<string, (int ProductDefinition, int Representation)>(StringComparer.Ordinal);
- foreach (var definition in model.Definitions.OrderBy(item => item.StableId, StringComparer.Ordinal))
+ foreach (var definition in model.Definitions.Where(item => item.Body is not null).OrderBy(item => item.StableId, StringComparer.Ordinal))
{
- var exported = Step242Exporter.ExportBody(definition.Body, options: new Step242ExportOptions
+ var exported = Step242Exporter.ExportBody(definition.Body!, options: new Step242ExportOptions
{
ProductId = definition.StableId,
ProductName = definition.Name,
@@ -97,6 +97,17 @@ public static class Step242AssemblyExporter
var solidAngleUnit = AddRaw("(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT())");
var representationContext = AddRaw($"(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT(({Ref(lengthUnit)},{Ref(angleUnit)},{Ref(solidAngleUnit)}))REPRESENTATION_CONTEXT('3','3D'))");
+ foreach (var definition in model.Definitions.Where(item => item.Body is null).OrderBy(item => item.StableId, StringComparer.Ordinal))
+ {
+ var product = Add("PRODUCT", Str(definition.StableId), Str(definition.Name), Str("Aetheris reusable assembly definition"), $"({Ref(productContext)})");
+ var formation = Add("PRODUCT_DEFINITION_FORMATION", Str(""), Str(""), Ref(product));
+ var productDefinition = Add("PRODUCT_DEFINITION", Str(definition.StableId), Str(""), Ref(formation), Ref(definitionContext));
+ var shape = Add("PRODUCT_DEFINITION_SHAPE", Str(""), Str(""), Ref(productDefinition));
+ var representation = Add("SHAPE_REPRESENTATION", Str(definition.Name), "()", Ref(representationContext));
+ Add("SHAPE_DEFINITION_REPRESENTATION", Ref(shape), Ref(representation));
+ definitionRefs[definition.StableId] = (productDefinition, representation);
+ }
+
var assemblyRefs = new Dictionary<string, (int ProductDefinition, int Representation)>(StringComparer.Ordinal);
foreach (var occurrence in model.Occurrences.Where(item => item.DefinitionStableId is null).OrderBy(item => item.StableId, StringComparer.Ordinal))
{
@@ -111,19 +122,25 @@ public static class Step242AssemblyExporter
var identityPoint = Add("CARTESIAN_POINT", Str(""), "(0.,0.,0.)");
var identityAxis = Add("AXIS2_PLACEMENT_3D", Str(""), Ref(identityPoint), "$", "$" );
+ var emittedDefinitionLocalUsages = new HashSet<string>(StringComparer.Ordinal);
foreach (var occurrence in model.Occurrences.Where(item => item.ParentStableId is not null).OrderBy(item => item.StableId, StringComparer.Ordinal))
{
- var parent = assemblyRefs[occurrence.ParentStableId!];
+ var parentOccurrence = model.Occurrences.Single(item => item.StableId == occurrence.ParentStableId);
+ var parent = parentOccurrence.DefinitionStableId is not null ? definitionRefs[parentOccurrence.DefinitionStableId] : assemblyRefs[parentOccurrence.StableId];
var child = occurrence.DefinitionStableId is null ? assemblyRefs[occurrence.StableId] : definitionRefs[occurrence.DefinitionStableId];
- var usage = Add("NEXT_ASSEMBLY_USAGE_OCCURRENCE", Str(occurrence.StableId), Str(occurrence.Name), Str(""), Ref(parent.ProductDefinition), Ref(child.ProductDefinition), "$" );
+ var definitionLocalKey = parentOccurrence.DefinitionStableId is null ? occurrence.StableId
+ : parentOccurrence.DefinitionStableId + "|" + occurrence.Name + "|" + (occurrence.DefinitionStableId ?? occurrence.StableId) + "|" + string.Join(",", occurrence.LocalTransform.Select(Num));
+ if (!emittedDefinitionLocalUsages.Add(definitionLocalKey)) continue;
+ var usageStableId = parentOccurrence.DefinitionStableId is null ? occurrence.StableId : "definition-usage:" + definitionLocalKey;
+ var usage = Add("NEXT_ASSEMBLY_USAGE_OCCURRENCE", Str(usageStableId), Str(occurrence.Name), Str(""), Ref(parent.ProductDefinition), Ref(child.ProductDefinition), "$" );
var usageShape = Add("PRODUCT_DEFINITION_SHAPE", Str(""), Str(""), Ref(usage));
var m = occurrence.LocalTransform;
var point = Add("CARTESIAN_POINT", Str(""), $"({Num(m[12])},{Num(m[13])},{Num(m[14])})");
var z = Add("DIRECTION", Str(""), $"({Num(m[8])},{Num(m[9])},{Num(m[10])})");
var x = Add("DIRECTION", Str(""), $"({Num(m[0])},{Num(m[1])},{Num(m[2])})");
var placement = Add("AXIS2_PLACEMENT_3D", Str(""), Ref(point), Ref(z), Ref(x));
- var transformation = Add("ITEM_DEFINED_TRANSFORMATION", Str(occurrence.StableId), Str("Aetheris rigid occurrence transform"), Ref(identityAxis), Ref(placement));
- var relationship = Add("REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION", Str(occurrence.StableId), Str(""), Ref(parent.Representation), Ref(child.Representation), Ref(transformation));
+ var transformation = Add("ITEM_DEFINED_TRANSFORMATION", Str(usageStableId), Str("Aetheris rigid occurrence transform"), Ref(identityAxis), Ref(placement));
+ var relationship = Add("REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION", Str(usageStableId), Str(""), Ref(parent.Representation), Ref(child.Representation), Ref(transformation));
Add("CONTEXT_DEPENDENT_SHAPE_REPRESENTATION", Ref(relationship), Ref(usageShape));
}
@@ -239,17 +256,23 @@ public static class Step242AssemblyImporter
var transform = document.TryGetEntity(transformId.Value).Value;
var placementId = Ref(transform, 3); if (placementId is not null) transformByUsage[usageId] = Placement(document, placementId.Value);
}
- var occurrences = usages.Select(usage =>
- {
- var parentPd = Ref(usage, 3)!.Value; var childPd = Ref(usage, 4)!.Value;
- var parentUsage = usages.FirstOrDefault(candidate => Ref(candidate, 4) == parentPd);
- return new Step242ImportedProductOccurrence(
- occurrenceStableByUsage[usage.Id], Text(usage, 1) ?? occurrenceStableByUsage[usage.Id],
- parentUsage is null ? null : occurrenceStableByUsage[parentUsage.Id], stableByPd[childPd],
- transformByUsage.TryGetValue(usage.Id, out var matrix) ? matrix : Identity(), usage.Id);
- }).ToArray();
var childPds = usages.Select(usage => Ref(usage, 4)!.Value).ToHashSet();
var rootPd = usages.Select(usage => Ref(usage, 3)!.Value).First(id => !childPds.Contains(id));
+ var usagesByParentDefinition = usages.GroupBy(usage => Ref(usage, 3)!.Value).ToDictionary(group => group.Key, group => group.OrderBy(item => item.Id).ToArray());
+ var occurrences = new List<Step242ImportedProductOccurrence>();
+ var usedOccurrenceStableIds = new HashSet<string>(StringComparer.Ordinal);
+ foreach (var usage in usagesByParentDefinition.GetValueOrDefault(rootPd, [])) Expand(usage, null, 0);
+ void Expand(Step242ParsedEntity usage, string? parentStableId, int depth)
+ {
+ if (depth > usages.Length) throw new InvalidOperationException("AP242 assembly definition hierarchy is cyclic.");
+ var baseStableId = occurrenceStableByUsage[usage.Id];
+ var stableId = usedOccurrenceStableIds.Add(baseStableId) ? baseStableId : parentStableId + "/" + baseStableId;
+ usedOccurrenceStableIds.Add(stableId);
+ var childPd = Ref(usage, 4)!.Value;
+ occurrences.Add(new(stableId, Text(usage, 1) ?? baseStableId, parentStableId, stableByPd[childPd],
+ transformByUsage.TryGetValue(usage.Id, out var matrix) ? matrix : Identity(), usage.Id));
+ foreach (var childUsage in usagesByParentDefinition.GetValueOrDefault(childPd, [])) Expand(childUsage, stableId, depth + 1);
+ }
return KernelResult<Step242ProductStructure>.Success(new(stableByPd[rootPd], importedDefinitions, occurrences));
}
diff --git a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM0Tests.cs b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM0Tests.cs
index 4b0ac7d0..1a8c7459 100644
--- a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM0Tests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM0Tests.cs
@@ -6,6 +6,47 @@ namespace Aetheris.Kernel.Firmament.Tests.Assembly;
public sealed class AssemblyM0Tests
{
+ [Fact]
+ public void TemplateAssembly_ReusesDefinitionAndExposesOnlyIntentionalSurface()
+ {
+ const string source = """
+ Template < Spec: ModuleSpec >
+ Assembly BearingModule {
+ <Assembly BearingModule>
+ <Part Housing = HousingPart>
+ Semantic Mount { Axis Axis = [0,0,0] -> [0,0,1]; Dimension Offset = 45mm tol +0.10mm -0.08mm; }
+ </Part>
+ </Assembly>
+ Anchor: BearingModule.Housing.Mount;
+ Expose { Semantic Mount = Housing.Mount; Dimension MountToDriveOffset = Housing.Mount.Offset; }
+ }
+ Interface MountPair { Role Module requires AxisCapable; Role Frame requires AxisCapable; }
+ Assembly Machine {
+ <Assembly Machine>
+ <Part Frame = FramePart> Semantic Mount { Axis Axis = [0,0,0] -> [0,0,1]; } </Part>
+ <Assembly Left = BearingModule<Spec: StandardSpec>></Assembly>
+ <Assembly Right = BearingModule<Spec: StandardSpec>></Assembly>
+ </Assembly>
+ Anchor: Machine.Frame.Mount;
+ Mate LeftMount: MountPair { Module: Machine.Left.Mount; Frame: Machine.Frame.Mount; }
+ }
+ """;
+ var parsed = new AssemblyM0Parser().Parse(source);
+ Assert.True(parsed.IsSuccess, string.Join(Environment.NewLine, parsed.Diagnostics.Select(x => x.Message)));
+ var result = new AssemblyM0Compiler().Compile(parsed.Source!);
+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics.Select(x => x.Message)));
+ var left = result.Ir!.Instances.Single(instance => instance.Path.ToString() == "Machine.Left");
+ var right = result.Ir.Instances.Single(instance => instance.Path.ToString() == "Machine.Right");
+ Assert.True(left.IsEncapsulatedDefinition);
+ Assert.Equal(left.DefinitionIdentity, right.DefinitionIdentity);
+ Assert.NotEqual(left.SemanticRoot.ExposedMembers["Mount"].StableIdentity, right.SemanticRoot.ExposedMembers["Mount"].StableIdentity);
+ Assert.Equal("valid", Assert.Single(result.Ir.Mates).ValidationStatus);
+
+ var hidden = source.Replace("Machine.Left.Mount", "Machine.Left.Housing.Mount", StringComparison.Ordinal);
+ var hiddenResult = new AssemblyM0Compiler().Compile(new AssemblyM0Parser().Parse(hidden).Source!);
+ Assert.Contains(hiddenResult.Diagnostics, diagnostic => diagnostic.Code == "assembly-internal-member-hidden");
+ }
+
[Fact]
public void BearingModule_CompilesTreeMatesPlacementFitAndAutomaticStackup()
{
diff --git a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM2InteropTests.cs b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM2InteropTests.cs
index 561f2f36..feb385a2 100644
--- a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM2InteropTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM2InteropTests.cs
@@ -58,15 +58,56 @@ public sealed class AssemblyM2InteropTests
imported.Value.Occurrences.Single(occurrence => occurrence.Name == "part_004_plate_inst_001").LocalTransform[12], 8);
}
+ [Fact]
+ public void TemplateAssembly_Ap242RoundTripPreservesNestedReuseAndComposedTransforms()
+ {
+ var path = FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/AssemblyM3/bearing-module.firmament");
+ var compiled = new AssemblyM1Pipeline().CompileFile(path);
+ Assert.True(compiled.IsSuccess, string.Join(Environment.NewLine, compiled.Diagnostics.Select(item => item.Code + ": " + item.Message)));
+ var exported = AssemblyIrAp242Exporter.Export(compiled);
+ Assert.True(exported.IsSuccess, string.Join(Environment.NewLine, exported.Diagnostics.Select(item => item.Message)));
+
+ var imported = Step242AssemblyImporter.Import(exported.Value);
+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(item => item.Message)));
+ Assert.Equal(11, imported.Value.Occurrences.Count);
+ var assemblyDefinition = Assert.Single(imported.Value.Definitions, item => item.Geometry is null && item.Name.StartsWith("BearingModule<", StringComparison.Ordinal));
+ Assert.Null(assemblyDefinition.Geometry);
+ Assert.Equal(3, imported.Value.Definitions.Count(item => item.Geometry is not null));
+ Assert.Equal(2, imported.Value.Occurrences.Count(item => item.DefinitionStableId == assemblyDefinition.StableId));
+
+ var leftShaft = imported.Value.Occurrences.Single(item => item.Name == "Shaft" && item.ParentStableId!.Contains("LeftModule", StringComparison.Ordinal));
+ var rightShaft = imported.Value.Occurrences.Single(item => item.Name == "Shaft" && item.ParentStableId!.Contains("RightModule", StringComparison.Ordinal));
+ Assert.Equal(10, leftShaft.LocalTransform[14], 8);
+ Assert.Equal(leftShaft.DefinitionStableId, rightShaft.DefinitionStableId);
+ Assert.NotEqual(leftShaft.StableId, rightShaft.StableId);
+ }
+
[Fact]
public void FirmasmProfile_RequiresExactlyOneRootAssembly()
{
Assert.Contains(FirmamentAssemblyDocumentCompiler.ValidateProfile("Record X { }", FirmamentDocumentProfile.Assembly), diagnostic => diagnostic.Code == "assembly-profile-no-root");
Assert.Contains(FirmamentAssemblyDocumentCompiler.ValidateProfile("Assembly A { }\nAssembly B { }", FirmamentDocumentProfile.Assembly), diagnostic => diagnostic.Code == "assembly-profile-multiple-roots");
Assert.Empty(FirmamentAssemblyDocumentCompiler.ValidateProfile("Assembly A { }", FirmamentDocumentProfile.Assembly));
+ Assert.Empty(FirmamentAssemblyDocumentCompiler.ValidateProfile("Template < Spec: X >\nAssembly Reusable { }\nAssembly Root { }", FirmamentDocumentProfile.Assembly));
Assert.Empty(FirmamentAssemblyDocumentCompiler.ValidateProfile("Assembly A { }\nAssembly B { }", FirmamentDocumentProfile.General));
}
+ [Fact]
+ public void FirmasmProfile_CompilesRecordsTablesPartTemplatesAndOneTemplateAssemblyDefinition()
+ {
+ var source = FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/AssemblyM3/bearing-module.firmament");
+ var temporary = Path.Combine(Path.GetTempPath(), "aetheris-m3-" + Guid.NewGuid().ToString("N") + ".firmasm");
+ try
+ {
+ File.Copy(source, temporary);
+ var result = new FirmamentAssemblyDocumentCompiler().CompileFile(temporary);
+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Compilation.Diagnostics.Select(item => item.Code + ": " + item.Message)));
+ Assert.Equal(FirmamentDocumentProfile.Assembly, result.Profile);
+ Assert.Single(result.Compilation.Ir!.AssemblyDefinitions!);
+ }
+ finally { File.Delete(temporary); }
+ }
+
private static string TempDirectory()
{
var path = Path.Combine(Path.GetTempPath(), "aetheris-m2-" + Guid.NewGuid().ToString("N"));
diff --git a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM3Tests.cs b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM3Tests.cs
new file mode 100644
index 00000000..3890e54f
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyM3Tests.cs
@@ -0,0 +1,98 @@
+using Aetheris.Kernel.Firmament.Assembly;
+using Aetheris.Semantics;
+
+namespace Aetheris.Kernel.Firmament.Tests.Assembly;
+
+public sealed class AssemblyM3Tests
+{
+ private static string Fixture => FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/AssemblyM3/bearing-module.firmament");
+
+ [Fact]
+ public void BearingModule_SolvesDefinitionOnceAndComposesOccurrenceWorldTransforms()
+ {
+ var first = new AssemblyM1Pipeline().CompileFile(Fixture);
+ var second = new AssemblyM1Pipeline().CompileFile(Fixture);
+ Assert.True(first.IsSuccess, Evidence(first));
+
+ var definition = Assert.Single(first.Ir!.AssemblyDefinitions!);
+ Assert.Equal("BearingModule<Spec:StandardModuleSpec>", definition.SpecializationIdentity);
+ Assert.Equal(5, definition.LocalInstances.Count);
+ Assert.Equal("valid", Assert.Single(definition.LocalMates).ValidationStatus);
+ Assert.True(Assert.Single(definition.LocalToleranceStackups).Passed);
+ Assert.Contains(definition.Provenance, item => item.Stage == "static-table" && item.Identity == "BlockStandards");
+ Assert.Contains(definition.Provenance, item => item.Stage == "static-with" && item.Identity == "StandardModuleSpec");
+
+ var left = first.Ir.Instances.Single(item => item.Path.ToString() == "Machine.LeftModule");
+ var right = first.Ir.Instances.Single(item => item.Path.ToString() == "Machine.RightModule");
+ Assert.Equal(left.DefinitionIdentity, right.DefinitionIdentity);
+ Assert.Equal(-30, left.ResolvedTransform!.Matrix[12], 8);
+ Assert.Equal(30, right.ResolvedTransform!.Matrix[12], 8);
+ var leftShaft = first.Ir.Instances.Single(item => item.Path.ToString() == "Machine.LeftModule.Shaft");
+ var rightShaft = first.Ir.Instances.Single(item => item.Path.ToString() == "Machine.RightModule.Shaft");
+ Assert.Equal(-30, leftShaft.ResolvedTransform!.Matrix[12], 8);
+ Assert.Equal(30, rightShaft.ResolvedTransform!.Matrix[12], 8);
+ Assert.Equal(10, leftShaft.ResolvedTransform.Matrix[14], 8);
+
+ Assert.Equal(first.Geometry!.Artifact.DeterministicSha256, second.Geometry!.Artifact.DeterministicSha256);
+ Assert.Equal(definition.StableId, Assert.Single(second.Ir!.AssemblyDefinitions!).StableId);
+ }
+
+ [Fact]
+ public void BearingModule_PublicWorldDatumsAndParentToleranceRetainExpandedPrivateChain()
+ {
+ var result = new AssemblyM1Pipeline().CompileFile(Fixture);
+ Assert.True(result.IsSuccess, Evidence(result));
+ var left = result.Ir!.Instances.Single(item => item.Path.ToString() == "Machine.LeftModule");
+
+ var axis = Assert.IsType<ExactAxisBinding>(AssemblyWorldQuery.Resolve(result.Ir, left.SemanticRoot.ExposedMembers["DriveAxis"].StableIdentity));
+ var plane = Assert.IsType<ExactPlaneBinding>(AssemblyWorldQuery.Resolve(result.Ir, left.SemanticRoot.ExposedMembers["MountFace"].StableIdentity));
+ var point = Assert.IsType<ExactPointBinding>(AssemblyWorldQuery.Resolve(result.Ir, left.SemanticRoot.ExposedMembers["MountPoint"].StableIdentity));
+ Assert.Equal(-30, axis.OriginX, 8); Assert.Equal(10, axis.OriginZ, 8);
+ Assert.Equal(-30, plane.OriginX, 8); Assert.Equal(-30, point.X, 8);
+
+ var summary = result.Ir.DimensionalRelations.Single(item => item.OriginInstancePath == "Machine.LeftModule" && item.ExpandedContributors is not null);
+ Assert.Equal(45, summary.Nominal, 8); Assert.Equal(-0.08, summary.LowerTolerance, 8); Assert.Equal(0.10, summary.UpperTolerance, 8);
+ Assert.Equal(3, summary.ExpandedContributors!.Count);
+ Assert.Contains(summary.SourceProvenance!, item => item.Stage == "static-with");
+
+ var stack = Assert.Single(result.Ir.ToleranceStackups);
+ Assert.True(stack.Passed); Assert.Equal(45, stack.Nominal, 8);
+ Assert.Equal(44.92, stack.WorstCaseMinimum, 8); Assert.Equal(45.10, stack.WorstCaseMaximum, 8);
+ var publicStep = Assert.Single(stack.Contributions, item => item.ExpandedContributors is not null);
+ Assert.Equal(["Housing seat", "Bearing width / BlockStandards", "Spacer width / StandardModuleSpec with"],
+ publicStep.ExpandedContributors!.Select(item => item.Provenance));
+
+ Assert.Equal("valid", result.Ir.Mates.Single(item => item.Name == "PlaceLeft").ValidationStatus);
+ var hiddenSource = File.ReadAllText(Fixture).Replace("Machine.LeftModule.Mount", "Machine.LeftModule.Housing.Mount", StringComparison.Ordinal);
+ var hidden = new AssemblyM0Parser().Parse(hiddenSource, Fixture);
+ var hiddenCompilation = new AssemblyM0Compiler().Compile(hidden.Source!);
+ Assert.Contains(hiddenCompilation.Diagnostics, item => item.Code == "assembly-internal-member-hidden");
+ }
+
+ [Fact]
+ public void InternallyUnderconstrainedTemplateSpecializationIsRejectedBeforeParentExecution()
+ {
+ var source = File.ReadAllText(Fixture).Replace("Mate ShaftSeat: RigidSeat", "// Mate ShaftSeat: RigidSeat", StringComparison.Ordinal);
+ var parsed = new AssemblyM0Parser().Parse(source, Fixture);
+ Assert.False(parsed.IsSuccess);
+ Assert.Contains(parsed.Diagnostics, item => item.Code == "assembly-template-internal-constraint-failure" && item.Message.Contains("Shaft", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void DifferentAssemblyTemplateArgumentsProduceDistinctLocallySolvedDefinitions()
+ {
+ var source = File.ReadAllText(Fixture).Replace(
+ "<Assembly RightModule = BearingModule<Spec: StandardModuleSpec>>",
+ "<Assembly RightModule = BearingModule<Spec: BaseModuleSpec>>", StringComparison.Ordinal);
+ var parsed = new AssemblyM0Parser().Parse(source, Fixture);
+ Assert.True(parsed.IsSuccess, string.Join(Environment.NewLine, parsed.Diagnostics.Select(item => item.Message)));
+ var compiled = new AssemblyM0Compiler().Compile(parsed.Source!);
+ Assert.Equal(2, compiled.Ir!.AssemblyDefinitions!.Count);
+ Assert.NotEqual(
+ compiled.Ir.Instances.Single(item => item.Path.ToString() == "Machine.LeftModule").DefinitionIdentity,
+ compiled.Ir.Instances.Single(item => item.Path.ToString() == "Machine.RightModule").DefinitionIdentity);
+ Assert.All(compiled.Ir.AssemblyDefinitions, item => Assert.True(item.SolveMilliseconds > 0));
+ }
+
+ private static string Evidence(AssemblyM1CompilationResult result) => string.Join(Environment.NewLine, result.Diagnostics.Select(item => item.Code + ": " + item.Message));
+}
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs
index 7e0e24d6..f81bf562 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs
@@ -45,6 +45,7 @@ public sealed class AssemblyM0Compiler
var graphWatch = Stopwatch.StartNew();
var relations = BindDimensionalRelations(source, instances, diagnostics)
+ .Concat(LowerAssemblyDefinitionRelations(source, instances))
.Concat(LowerInterfaceDimensionalRelations(mates, interfaces, instances, diagnostics))
.OrderBy(relation => relation.StableId, StringComparer.Ordinal).ToArray();
graphWatch.Stop();
@@ -58,9 +59,11 @@ public sealed class AssemblyM0Compiler
var perf = new AssemblyPerformanceIr(parseMilliseconds, bindWatch.Elapsed.TotalMilliseconds,
mateWatch.Elapsed.TotalMilliseconds, placementWatch.Elapsed.TotalMilliseconds,
graphWatch.Elapsed.TotalMilliseconds, toleranceWatch.Elapsed.TotalMilliseconds);
+ var assemblyDefinitions = source.Root.Flatten().Select(member => member.SolvedAssemblyDefinition).Where(definition => definition is not null)
+ .Cast<AssemblyDefinitionIr>().DistinctBy(definition => definition.StableId).OrderBy(definition => definition.StableId, StringComparer.Ordinal).ToArray();
var ir = new AssemblyIr("aetheris/assembly-ir/m0", $"assembly:{source.Name}", source.Name,
instances.Single(x => x.ParentStableId is null).StableId, instances, source.Interfaces, mates,
- constraints, placements, relations, stackups, fits, diagnostics);
+ constraints, placements, relations, stackups, fits, diagnostics, assemblyDefinitions);
return new(ir, diagnostics, perf);
}
@@ -82,7 +85,7 @@ public sealed class AssemblyM0Compiler
diagnostics.Add(new("assembly-instance-path-collision", "Assembly contains duplicate deterministic instance paths."));
return flat.Select(x => new AssemblyInstanceIr(x.id, x.path, x.member.Kind, x.member.DefinitionIdentity, x.parent,
flat.Where(c => c.parent == x.id).Select(c => c.id).Order(StringComparer.Ordinal).ToArray(), x.semantic,
- x.member.ExplicitTransform, null, x.member.Provenance ?? [], x.member.PlacementAuthority)).ToArray();
+ x.member.ExplicitTransform, null, x.member.Provenance ?? [], x.member.PlacementAuthority, x.member.IsEncapsulatedDefinition)).ToArray();
}
private static SemanticValue InstanceScope(AssemblyMemberSource member, AssemblyPath path, string sourceIdentity)
@@ -114,7 +117,13 @@ public sealed class AssemblyM0Compiler
var assignment = mate.Roles.FirstOrDefault(x => x.Role == role.Name);
if (assignment is null) { diagnostics.Add(new(MissingRole, $"Mate '{mate.Name}' is missing required Role '{role.Name}'.")); continue; }
if (!TryResolve(assignment.Participant, byPath.Values, out var reference))
- { diagnostics.Add(new(OutsideScope, $"Mate '{mate.Name}' Role '{role.Name}' participant '{assignment.Participant}' is not reachable in the Assembly tree.")); continue; }
+ {
+ var boundary = EncapsulationBoundary(assignment.Participant, byPath.Values);
+ diagnostics.Add(boundary is null
+ ? new(OutsideScope, $"Mate '{mate.Name}' Role '{role.Name}' participant '{assignment.Participant}' is not reachable in the Assembly tree.")
+ : new("assembly-internal-member-hidden", $"'{assignment.Participant}' crosses the private boundary of Assembly '{boundary.Path}'. Expose a semantic member from the Assembly if parent assemblies must depend on it."));
+ continue;
+ }
var missing = role.RequiredCapabilities.Where(c => !HasCapability(reference!.Value, c)).ToArray();
if (missing.Length > 0)
diagnostics.Add(new(CapabilityMismatch, $"Mate '{mate.Name}' Role '{role.Name}' participant '{assignment.Participant}' lacks: {string.Join(", ", missing)}."));
@@ -172,6 +181,8 @@ public sealed class AssemblyM0Compiler
if (anchor is null) diagnostics.Add(new("assembly-anchor-invalid", $"Anchor '{source.Anchor}' is outside the Assembly tree."));
var known = new Dictionary<string, AssemblyTransform>(StringComparer.Ordinal);
var overconstrained = new HashSet<string>(StringComparer.Ordinal);
+ var root = instances.Single(instance => instance.ParentStableId is null);
+ known[root.StableId] = AssemblyTransform.Identity;
if (anchor is not null) known[anchor.StableId] = AssemblyTransform.Identity;
var explicitPending = instances.Where(instance => instance.LocalTransform is not null).OrderBy(instance => instance.Path.Segments.Count).ToList();
var explicitProgress = true;
@@ -230,10 +241,27 @@ public sealed class AssemblyM0Compiler
}
}
+ // A parent Mate may have resolved a subassembly occurrence after the
+ // first explicit-local pass. Compose its already-solved definition
+ // children now; no internal Mate is evaluated in the parent scope.
+ explicitProgress = true;
+ while (explicitProgress && explicitPending.Count > 0)
+ {
+ explicitProgress = false;
+ foreach (var instance in explicitPending.ToArray())
+ {
+ var parent = instance.ParentStableId is null ? null : instances.Single(candidate => candidate.StableId == instance.ParentStableId);
+ AssemblyTransform? parentWorld = null;
+ if (parent is not null && !known.TryGetValue(parent.StableId, out parentWorld)) continue;
+ var world = parent is null ? ToMatrix(instance.LocalTransform!) : ToMatrix(instance.LocalTransform!) * ToMatrix(parentWorld!);
+ known[instance.StableId] = FromMatrix(world); explicitPending.Remove(instance); explicitProgress = true;
+ }
+ }
+
var results = new List<PlacementResultIr>();
foreach (var instance in instances)
{
- if (anchor is not null && instance.StableId == anchor.StableId)
+ if ((anchor is not null && instance.StableId == anchor.StableId) || instance.ParentStableId is null)
{ results.Add(new(instance.StableId, PlacementStatus.Anchored, AssemblyTransform.Identity, [], [], [], instance.PlacementAuthority)); continue; }
if (instance.LocalTransform is not null && known.TryGetValue(instance.StableId, out var explicitTransform))
{ results.Add(new(instance.StableId, PlacementStatus.Resolved, explicitTransform, [], [], [], instance.PlacementAuthority)); continue; }
@@ -332,6 +360,32 @@ public sealed class AssemblyM0Compiler
return result;
}
+ private static IReadOnlyList<DimensionalRelationIr> LowerAssemblyDefinitionRelations(AssemblySource source, IReadOnlyList<AssemblyInstanceIr> instances)
+ {
+ var definitions = source.Root.Flatten().Where(member => member.SolvedAssemblyDefinition is not null)
+ .ToDictionary(member => member.Name, member => member.SolvedAssemblyDefinition!, StringComparer.Ordinal);
+ var result = new List<DimensionalRelationIr>();
+ foreach (var instance in instances.Where(item => item.IsEncapsulatedDefinition))
+ {
+ if (!definitions.TryGetValue(instance.Path.Segments.Last(), out var definition)) continue;
+ foreach (var relation in definition.PublicDimensionalRelations)
+ {
+ if (!instance.SemanticRoot.ExposedMembers.TryGetValue(relation.FromSemanticValueId, out var from)
+ || !instance.SemanticRoot.ExposedMembers.TryGetValue(relation.ToSemanticValueId, out var to)) continue;
+ result.Add(relation with
+ {
+ StableId = relation.StableId + ":occurrence:" + instance.StableId,
+ FromSemanticValueId = from.StableIdentity,
+ ToSemanticValueId = to.StableIdentity,
+ OriginInstancePath = instance.Path.ToString(),
+ AssemblyDefinitionStableId = definition.StableId,
+ SourceProvenance = [.. relation.SourceProvenance ?? [], .. instance.Provenance]
+ });
+ }
+ }
+ return result;
+ }
+
private static IReadOnlyList<InterfaceFitResultIr> AnalyzeFits(IReadOnlyList<MateIr> mates,
IReadOnlyDictionary<string, InterfaceDefinition> interfaces, IReadOnlyList<AssemblyInstanceIr> instances,
List<AssemblyDiagnostic> diagnostics)
@@ -416,7 +470,8 @@ public sealed class AssemblyM0Compiler
step.sign * step.edge.Nominal,
step.sign > 0 ? step.edge.LowerTolerance : -step.edge.UpperTolerance,
step.sign > 0 ? step.edge.UpperTolerance : -step.edge.LowerTolerance,
- step.edge.Unit, step.edge.OriginInstancePath, step.edge.Provenance, step.edge.MateStableId, step.edge.InterfaceStableId, step.edge.SourceProvenance)).ToArray();
+ step.edge.Unit, step.edge.OriginInstancePath, step.edge.Provenance, step.edge.MateStableId, step.edge.InterfaceStableId, step.edge.SourceProvenance,
+ step.edge.ExpandedContributors)).ToArray();
if (contributions.Any(x => x.Unit != assertion.Unit))
{ diagnostics.Add(new("assembly-tolerance-unit-mismatch", $"Assert ToleranceStackup '{assertion.Name}' mixes units.")); continue; }
var nominal = contributions.Sum(x => x.Nominal);
@@ -455,6 +510,7 @@ public sealed class AssemblyM0Compiler
{
reference = null;
var all = instances.ToArray();
+ if (EncapsulationBoundary(path, all) is not null) return false;
var instance = all.Where(x => path.Segments.Count >= x.Path.Segments.Count && path.Segments.Take(x.Path.Segments.Count).SequenceEqual(x.Path.Segments))
.OrderByDescending(x => x.Path.Segments.Count).FirstOrDefault();
if (instance is null) return false;
@@ -469,6 +525,19 @@ public sealed class AssemblyM0Compiler
return true;
}
+ private static AssemblyInstanceIr? EncapsulationBoundary(AssemblyPath path, IEnumerable<AssemblyInstanceIr> instances)
+ {
+ var all = instances.ToArray();
+ return all.Where(instance => instance.IsEncapsulatedDefinition
+ && path.Segments.Count > instance.Path.Segments.Count
+ && path.Segments.Take(instance.Path.Segments.Count).SequenceEqual(instance.Path.Segments)
+ // A direct next segment is a public semantic name. Crossing into
+ // an actual child occurrence is the prohibited traversal.
+ && all.Any(child => child.ParentStableId == instance.StableId
+ && child.Path.Segments.Last() == path.Segments[instance.Path.Segments.Count]))
+ .OrderByDescending(instance => instance.Path.Segments.Count).FirstOrDefault();
+ }
+
private static IEnumerable<SemanticValue> Flatten(IEnumerable<SemanticValue> roots)
{
foreach (var root in roots)
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs
index d1e36dd6..7311c43e 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs
@@ -33,7 +33,24 @@ public sealed record AssemblyMemberSource(
IReadOnlyList<DimensionalRelationSource>? DimensionalRelations = null,
IReadOnlyList<SemanticProvenance>? Provenance = null,
AssemblyTransform? ExplicitTransform = null,
- PlacementAuthority PlacementAuthority = PlacementAuthority.MateDerived);
+ PlacementAuthority PlacementAuthority = PlacementAuthority.MateDerived,
+ bool IsEncapsulatedDefinition = false,
+ AssemblyDefinitionIr? SolvedAssemblyDefinition = null);
+
+/// <summary>A reusable, locally-authored Assembly product definition. Its children
+/// remain product-visible, while only <see cref="AssemblyMemberSource.ExposedSemantics"/>
+/// participates in references outside an occurrence boundary.</summary>
+public sealed record AssemblyDefinitionSource(
+ string Name, string ParameterName, string ParameterType, AssemblyMemberSource LocalRoot,
+ string DefinitionIdentity, IReadOnlyList<SemanticProvenance> Provenance,
+ AssemblyPath? LocalAnchor = null,
+ IReadOnlyList<MateSource>? LocalMates = null,
+ IReadOnlyList<DimensionalRelationSource>? LocalDimensionalRelations = null,
+ IReadOnlyList<ToleranceStackupAssertSource>? LocalStackupAsserts = null,
+ IReadOnlyList<AssemblyExposedRelationSource>? ExposedRelations = null);
+
+public sealed record AssemblyExposedRelationSource(
+ string Name, string PublicFrom, string PublicTo, AssemblyPath InternalFrom, AssemblyPath InternalTo);
public sealed record MateRoleAssignment(string Role, AssemblyPath Participant);
public sealed record MateSource(string Name, string InterfaceName, IReadOnlyList<MateRoleAssignment> Roles, SemanticSourceSpan? SourceSpan = null);
@@ -45,7 +62,8 @@ public sealed record AssemblySource(
IReadOnlyList<DimensionalRelationSource> DimensionalRelations,
IReadOnlyList<ToleranceStackupAssertSource> StackupAsserts,
string SourceIdentity,
- string? DefinitionSource = null);
+ string? DefinitionSource = null,
+ IReadOnlyList<AssemblyDefinitionSource>? AssemblyDefinitions = null);
public sealed record AssemblyTransform(double[] Matrix)
{
@@ -57,7 +75,8 @@ public sealed record AssemblyInstanceIr(
string? ParentStableId, IReadOnlyList<string> ChildrenStableIds,
SemanticValue SemanticRoot, AssemblyTransform? LocalTransform, AssemblyTransform? ResolvedTransform,
IReadOnlyList<SemanticProvenance> Provenance,
- PlacementAuthority PlacementAuthority = PlacementAuthority.MateDerived);
+ PlacementAuthority PlacementAuthority = PlacementAuthority.MateDerived,
+ bool IsEncapsulatedDefinition = false);
public sealed record MateEndpointIr(string Role, AssemblyPath ParticipantPath, string ParticipantSemanticValueId, IReadOnlyList<string> RequiredCapabilities);
public sealed record MateIr(string StableId, string Name, string InterfaceStableId, IReadOnlyList<MateEndpointIr> Roles, IReadOnlyList<string> ConstraintIds, string ValidationStatus);
@@ -71,12 +90,15 @@ public sealed record DimensionalRelationIr(
string StableId, string FromSemanticValueId, string ToSemanticValueId,
double Nominal, double LowerTolerance, double UpperTolerance, string Unit,
int Sign, string OriginInstancePath, string Provenance, string? MateStableId = null, string? InterfaceStableId = null,
- IReadOnlyList<SemanticProvenance>? SourceProvenance = null);
+ IReadOnlyList<SemanticProvenance>? SourceProvenance = null,
+ IReadOnlyList<StackupContributionIr>? ExpandedContributors = null,
+ string? AssemblyDefinitionStableId = null);
public sealed record StackupContributionIr(
string RelationStableId, int Sign, double Nominal, double LowerTolerance, double UpperTolerance,
string Unit, string OriginInstancePath, string Provenance, string? MateStableId, string? InterfaceStableId,
- IReadOnlyList<SemanticProvenance>? SourceProvenance = null);
+ IReadOnlyList<SemanticProvenance>? SourceProvenance = null,
+ IReadOnlyList<StackupContributionIr>? ExpandedContributors = null);
public sealed record ToleranceStackupResultIr(
string Name, string StartSemanticValueId, string EndSemanticValueId,
double Nominal, double WorstCaseMinimum, double WorstCaseMaximum,
@@ -85,6 +107,15 @@ public sealed record ToleranceStackupResultIr(
public sealed record InterfaceFitResultIr(
string MateStableId, double NominalClearance, double WorstCaseMinimum, double WorstCaseMaximum, string Unit, bool Compatible);
+public sealed record AssemblyDefinitionIr(
+ string StableId, string DefinitionIdentity, string TemplateName, string SpecializationIdentity,
+ IReadOnlyList<SemanticProvenance> Provenance, IReadOnlyList<AssemblyInstanceIr> LocalInstances,
+ IReadOnlyList<MateIr> LocalMates, IReadOnlyList<PlacementResultIr> LocalPlacements,
+ IReadOnlyList<DimensionalRelationIr> LocalDimensionalRelations,
+ IReadOnlyList<ToleranceStackupResultIr> LocalToleranceStackups,
+ IReadOnlyList<SemanticValue> PublicSemantics, IReadOnlyList<DimensionalRelationIr> PublicDimensionalRelations,
+ double SolveMilliseconds);
+
public sealed record AssemblyPerformanceIr(double ParseMilliseconds, double BindMilliseconds, double MateValidationMilliseconds, double PlacementMilliseconds, double DimensionalGraphMilliseconds, double ToleranceAnalysisMilliseconds, double DefinitionMaterializationMilliseconds = 0, double GeometryExecutionMilliseconds = 0);
public sealed record AssemblyGeometryMetricsIr(int Bodies, int Faces, int Edges, int Vertices, double[] Minimum, double[] Maximum);
public sealed record AssemblyDefinitionArtifactIr(string StableId, string DefinitionIdentity, string SpecializationIdentity, string StepSha256, AssemblyGeometryMetricsIr Metrics, IReadOnlyList<SemanticProvenance> Provenance);
@@ -97,7 +128,8 @@ public sealed record AssemblyIr(
IReadOnlyList<MateIr> Mates, IReadOnlyList<PlacementConstraintIr> PlacementConstraints,
IReadOnlyList<PlacementResultIr> Placements, IReadOnlyList<DimensionalRelationIr> DimensionalRelations,
IReadOnlyList<ToleranceStackupResultIr> ToleranceStackups, IReadOnlyList<InterfaceFitResultIr> FitResults,
- IReadOnlyList<AssemblyDiagnostic> Diagnostics);
+ IReadOnlyList<AssemblyDiagnostic> Diagnostics,
+ IReadOnlyList<AssemblyDefinitionIr>? AssemblyDefinitions = null);
public sealed record AssemblyCompilationResult(AssemblyIr? Ir, IReadOnlyList<AssemblyDiagnostic> Diagnostics, AssemblyPerformanceIr? Performance = null)
{
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs
index cdb7b1b9..9ceeda69 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs
@@ -19,12 +19,20 @@ public sealed class AssemblyM0Parser
var diagnostics = new List<AssemblyDiagnostic>();
var source = Regex.Replace(input, @"//[^\r\n]*", string.Empty);
var interfaces = ParseInterfaces(source, sourceIdentity, diagnostics);
- var assemblyHeader = Regex.Match(source, @"\bAssembly\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);
+ var templateRanges = new List<(int Start, int Length)>();
+ var assemblyDefinitions = ParseAssemblyDefinitions(source, sourceIdentity, interfaces, diagnostics, templateRanges);
+ // Template-produced Assembly bodies are declarations, not exported roots.
+ // Blank them without changing offsets, then locate the single root Assembly.
+ var rootSearch = source.ToCharArray();
+ foreach (var range in templateRanges) Array.Fill(rootSearch, ' ', range.Start, range.Length);
+ var rootSource = new string(rootSearch);
+ var assemblyHeader = Regex.Match(rootSource, @"\bAssembly\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);
if (!assemblyHeader.Success)
{ diagnostics.Add(new("assembly-parse-missing-root", "Expected 'Assembly Name { ... }'.")); return Done(null); }
var body = BalancedBody(source, assemblyHeader.Index + assemblyHeader.Length - 1, diagnostics, "Assembly");
if (body is null) return Done(null);
- var tree = ParseTree(body, sourceIdentity, diagnostics);
+ var specializationCache = new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal);
+ var tree = ParseTree(body, sourceIdentity, diagnostics, assemblyDefinitions, interfaces, specializationCache);
if (tree is null) return Done(null);
var mates = ParseMates(body, sourceIdentity, diagnostics);
var relations = ParseRelations(body, diagnostics);
@@ -36,8 +44,11 @@ public sealed class AssemblyM0Parser
Regex.Match(source, @"^[ \t]*Interface\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant | RegexOptions.Multiline),
Regex.Match(source, @"^[ \t]*Assembly\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant | RegexOptions.Multiline)
}.Where(match => match.Success).Select(match => match.Index).DefaultIfEmpty(0).Min();
- var definitionSource = definitionBoundary > 0 ? source[..definitionBoundary].Trim() : null;
- var result = new AssemblySource(assemblyHeader.Groups["name"].Value, tree, interfaces, mates, anchor, relations, asserts, sourceIdentity, definitionSource);
+ var declarationChars = source.ToCharArray();
+ foreach (var range in templateRanges) Array.Fill(declarationChars, ' ', range.Start, range.Length);
+ var declarations = new string(declarationChars);
+ var definitionSource = definitionBoundary > 0 ? declarations[..definitionBoundary].Trim() : null;
+ var result = new AssemblySource(assemblyHeader.Groups["name"].Value, tree, interfaces, mates, anchor, relations, asserts, sourceIdentity, definitionSource, assemblyDefinitions);
return Done(result);
ParseResult Done(AssemblySource? value) { watch.Stop(); return new(value, diagnostics, watch.Elapsed.TotalMilliseconds); }
@@ -78,9 +89,199 @@ public sealed class AssemblyM0Parser
public MutableNode? Parent { get; set; }
public AssemblyTransform? ExplicitTransform { get; set; }
public PlacementAuthority PlacementAuthority { get; set; } = PlacementAuthority.MateDerived;
+ public bool IsEncapsulatedDefinition { get; set; }
+ public AssemblyDefinitionIr? SolvedAssemblyDefinition { get; set; }
}
- private static AssemblyMemberSource? ParseTree(string body, string sourceIdentity, List<AssemblyDiagnostic> diagnostics)
+ private static IReadOnlyList<AssemblyDefinitionSource> ParseAssemblyDefinitions(string source, string sourceIdentity,
+ IReadOnlyList<InterfaceDefinition> interfaces, List<AssemblyDiagnostic> diagnostics, List<(int Start, int Length)> ranges)
+ {
+ var result = new List<AssemblyDefinitionSource>();
+ foreach (Match template in Regex.Matches(source,
+ @"\bTemplate\s*<\s*(?<parameter>[A-Za-z_]\w*)\s*:\s*(?<type>[A-Za-z_]\w*)\s*>\s*Assembly\s+(?<name>[A-Za-z_]\w*)\s*\{",
+ RegexOptions.CultureInvariant))
+ {
+ var body = BalancedBody(source, template.Index + template.Length - 1, diagnostics, "Template Assembly");
+ if (body is null) continue;
+ var close = template.Index + template.Length + body.Length + 1;
+ ranges.Add((template.Index, close - template.Index));
+ var root = ParseTree(body, sourceIdentity, diagnostics);
+ if (root is null) continue;
+ var exposed = ParseAssemblyExposes(body, root, sourceIdentity, diagnostics);
+ root = root with { ExposedSemantics = exposed, IsEncapsulatedDefinition = true };
+ var name = template.Groups["name"].Value;
+ if (result.Any(item => item.Name == name))
+ {
+ diagnostics.Add(new("assembly-template-duplicate-definition", $"Assembly Template '{name}' is declared more than once."));
+ continue;
+ }
+ var anchorMatch = Regex.Match(RemoveBlocks(body, "Mate", @"Assert\s+ToleranceStackup", "Expose"), @"\bAnchor\s*:\s*(?<path>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*;", RegexOptions.CultureInvariant);
+ var anchor = anchorMatch.Success ? AssemblyPath.Parse(anchorMatch.Groups["path"].Value) : new AssemblyPath([root.Name]);
+ var exposedRelations = ParseExposedRelations(body);
+ var staticProvenance = Regex.Matches(source, @"\bStatic\s+Table\s+(?<name>[A-Za-z_]\w*)[^\{]*\{", RegexOptions.CultureInvariant)
+ .Select(match => new SemanticProvenance("static-table", match.Groups["name"].Value, match.Value.Trim(), SemanticSourceSpan.Generated(sourceIdentity)))
+ .Concat(Regex.Matches(source, @"\bStatic\s+(?<name>[A-Za-z_]\w*)[^=]*=\s*(?<base>[A-Za-z_]\w*)\s+with\s*\{", RegexOptions.CultureInvariant)
+ .Select(match => new SemanticProvenance("static-with", match.Groups["name"].Value, "derivedFrom:" + match.Groups["base"].Value, SemanticSourceSpan.Generated(sourceIdentity))))
+ .Concat(Regex.Matches(source, @"\bStatic\s+(?<name>[A-Za-z_]\w*)\s*:\s*(?<type>[A-Za-z_]\w*)\s*=\s*\k<type>\s*\{", RegexOptions.CultureInvariant)
+ .Select(match => new SemanticProvenance("static-record", match.Groups["name"].Value, match.Groups["type"].Value, SemanticSourceSpan.Generated(sourceIdentity))))
+ .ToArray();
+ result.Add(new(name, template.Groups["parameter"].Value, template.Groups["type"].Value, root, name,
+ [new("assembly-template-definition", name, template.Groups["parameter"].Value + ":" + template.Groups["type"].Value, SemanticSourceSpan.Generated(sourceIdentity)), .. staticProvenance],
+ anchor, ParseMates(body, sourceIdentity, diagnostics), ParseRelations(body, diagnostics), ParseAsserts(body, sourceIdentity, diagnostics), exposedRelations));
+ }
+ return result;
+ }
+
+ private static IReadOnlyList<AssemblyExposedRelationSource> ParseExposedRelations(string body)
+ {
+ var header = Regex.Match(body, @"\bExpose\s*\{", RegexOptions.CultureInvariant);
+ if (!header.Success) return [];
+ var diagnostics = new List<AssemblyDiagnostic>();
+ var block = BalancedBody(body, header.Index + header.Length - 1, diagnostics, "Assembly Expose") ?? string.Empty;
+ return Regex.Matches(block, @"\bRelation\s+(?<name>[A-Za-z_]\w*)\s*:\s*(?<publicFrom>[A-Za-z_]\w*)\s*->\s*(?<publicTo>[A-Za-z_]\w*)\s*=\s*(?<internalFrom>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*->\s*(?<internalTo>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*;", RegexOptions.CultureInvariant)
+ .Select(match => new AssemblyExposedRelationSource(match.Groups["name"].Value, match.Groups["publicFrom"].Value, match.Groups["publicTo"].Value,
+ AssemblyPath.Parse(match.Groups["internalFrom"].Value), AssemblyPath.Parse(match.Groups["internalTo"].Value))).ToArray();
+ }
+
+ private static IReadOnlyList<SemanticValue> ParseAssemblyExposes(string body, AssemblyMemberSource root, string sourceIdentity, List<AssemblyDiagnostic> diagnostics)
+ {
+ var header = Regex.Match(body, @"\bExpose\s*\{", RegexOptions.CultureInvariant);
+ if (!header.Success) return [];
+ var block = BalancedBody(body, header.Index + header.Length - 1, diagnostics, "Assembly Expose") ?? string.Empty;
+ var result = new List<SemanticValue>();
+ foreach (Match expose in Regex.Matches(block, @"\b(?:Semantic|Axis|Plane|Point|Dimension)\s+(?<name>[A-Za-z_]\w*)\s*=\s*(?<path>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*;", RegexOptions.CultureInvariant))
+ {
+ var alias = expose.Groups["name"].Value;
+ if (result.Any(value => value.ExposedName == alias)) { diagnostics.Add(new("assembly-expose-duplicate-name", $"Assembly Expose declares '{alias}' more than once.")); continue; }
+ var segments = expose.Groups["path"].Value.Split('.');
+ var child = root.Children.SingleOrDefault(item => item.Name == segments[0]);
+ SemanticValue? value = child is null ? null : child.ExposedSemantics.SingleOrDefault(item => item.ExposedName == segments.ElementAtOrDefault(1));
+ for (var i = 2; value is not null && i < segments.Length; i++) value = value.ExposedMembers.GetValueOrDefault(segments[i]);
+ if (value is null)
+ {
+ diagnostics.Add(new("assembly-expose-unresolved-path", $"Assembly Expose '{alias}' references nonexistent internal path '{expose.Groups["path"].Value}'."));
+ continue;
+ }
+ result.Add(new SemanticValue(value.StableIdentity + ":expose:" + alias, value.Type, value.Capabilities.Values, value.Bindings,
+ value.ExposedMembers.Values, [.. value.Provenance, new("assembly-expose", alias, expose.Groups["path"].Value, SemanticSourceSpan.Generated(sourceIdentity))],
+ value.AuthoredSourceSpan, value.GeneratedSourceSpan, alias));
+ }
+ return result;
+ }
+
+ private static AssemblyMemberSource? InstantiateAssemblyDefinition(string occurrenceName, string identity,
+ IReadOnlyList<AssemblyDefinitionSource> definitions, IReadOnlyList<InterfaceDefinition> interfaces,
+ IDictionary<string, AssemblyMemberSource> specializationCache, string sourceIdentity, List<AssemblyDiagnostic> diagnostics)
+ {
+ var application = Regex.Match(identity, @"^(?<name>[A-Za-z_]\w*)\s*<\s*(?<parameter>[A-Za-z_]\w*)\s*:\s*(?<argument>[^>]+)\s*>$", RegexOptions.CultureInvariant);
+ if (!application.Success) { diagnostics.Add(new("assembly-template-unresolved-definition", $"Assembly occurrence '{occurrenceName}' references unresolved definition '{identity}'.")); return null; }
+ var definition = definitions.SingleOrDefault(item => item.Name == application.Groups["name"].Value);
+ if (definition is null) { diagnostics.Add(new("assembly-template-unresolved-definition", $"Assembly Template '{application.Groups["name"].Value}' was not found.")); return null; }
+ if (application.Groups["parameter"].Value != definition.ParameterName) { diagnostics.Add(new("assembly-template-argument-mismatch", $"Assembly Template '{definition.Name}' expects argument '{definition.ParameterName}'.")); return null; }
+ var argument = application.Groups["argument"].Value.Trim();
+ var specializationIdentity = NormalizeIdentity(identity);
+ if (specializationCache.TryGetValue(specializationIdentity, out var cached))
+ return RenameOccurrence(cached, occurrenceName);
+ AssemblyMemberSource Replace(AssemblyMemberSource item) => item with
+ {
+ Name = item.Name,
+ DefinitionIdentity = Regex.Replace(item.DefinitionIdentity, $@"(?<prefix>:\s*)\b{Regex.Escape(definition.ParameterName)}\b(?=\s*>)", "${prefix}" + argument),
+ Children = item.Children.Select(Replace).ToArray(),
+ Provenance = [.. item.Provenance ?? [], new("assembly-template-specialization", definition.Name, specializationIdentity, SemanticSourceSpan.Generated(sourceIdentity))],
+ IsEncapsulatedDefinition = false
+ };
+ var specializedRoot = Replace(definition.LocalRoot);
+ var localSource = new AssemblySource(definition.Name, specializedRoot, interfaces, definition.LocalMates ?? [], definition.LocalAnchor ?? new([definition.Name]),
+ definition.LocalDimensionalRelations ?? [], definition.LocalStackupAsserts ?? [], sourceIdentity);
+ var watch = Stopwatch.StartNew();
+ var local = new AssemblyM0Compiler().Compile(localSource);
+ watch.Stop();
+ var localFailures = local.Diagnostics.Where(diagnostic => diagnostic.Severity == AssemblyDiagnosticSeverity.Error).ToArray();
+ var invalidPlacement = local.Ir?.Placements.FirstOrDefault(placement => placement.InstanceStableId != local.Ir.RootInstanceStableId
+ && placement.Status is PlacementStatus.Underconstrained or PlacementStatus.Overconstrained or PlacementStatus.Unresolved);
+ if (localFailures.Length > 0 || invalidPlacement is not null)
+ {
+ foreach (var failure in localFailures) diagnostics.Add(new("assembly-template-internal-" + failure.Code, $"Assembly Template specialization '{specializationIdentity}' is internally invalid: {failure.Message}"));
+ if (invalidPlacement is not null) diagnostics.Add(new("assembly-template-internal-constraint-failure", $"Assembly Template specialization '{specializationIdentity}' has internal placement '{invalidPlacement.InstanceStableId}' in state {invalidPlacement.Status}."));
+ return null;
+ }
+ if (local.Ir is null) return null;
+ AssemblyMemberSource ApplyLocal(AssemblyMemberSource item, AssemblyPath path)
+ {
+ var localInstance = local.Ir.Instances.Single(instance => instance.Path.ToString() == path.ToString());
+ return item with { Children = item.Children.Select(child => ApplyLocal(child, path.Append(child.Name))).ToArray(), ExplicitTransform = item == specializedRoot ? null : localInstance.ResolvedTransform };
+ }
+ specializedRoot = ApplyLocal(specializedRoot, new([specializedRoot.Name]));
+ var publicSemantics = specializedRoot.ExposedSemantics.Select(value => BindPublicSemantic(value, local.Ir, sourceIdentity)).ToArray();
+ var publicRelations = BuildPublicRelations(definition, specializationIdentity, publicSemantics, local.Ir, diagnostics);
+ var stableId = "assembly-definition:" + Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(specializationIdentity)))[..16];
+ var definitionIr = new AssemblyDefinitionIr(stableId, specializationIdentity, definition.Name, specializationIdentity,
+ [.. definition.Provenance, new("assembly-template-specialization", definition.Name, specializationIdentity, SemanticSourceSpan.Generated(sourceIdentity))],
+ local.Ir.Instances, local.Ir.Mates, local.Ir.Placements, local.Ir.DimensionalRelations, local.Ir.ToleranceStackups,
+ publicSemantics, publicRelations, watch.Elapsed.TotalMilliseconds);
+ specializedRoot = specializedRoot with { ExposedSemantics = publicSemantics, IsEncapsulatedDefinition = true, SolvedAssemblyDefinition = definitionIr, DefinitionIdentity = specializationIdentity };
+ specializationCache[specializationIdentity] = specializedRoot;
+ return RenameOccurrence(specializedRoot, occurrenceName);
+
+ static AssemblyMemberSource RenameOccurrence(AssemblyMemberSource root, string name) => root with { Name = name };
+ }
+
+ private static SemanticValue BindPublicSemantic(SemanticValue exposed, AssemblyIr localIr, string sourceIdentity)
+ {
+ var internalPath = exposed.Provenance.LastOrDefault(item => item.Stage == "assembly-expose")?.Evidence;
+ if (internalPath is null || !AssemblyM0Compiler.TryResolve(AssemblyPath.Parse(localIr.Name + "." + internalPath), localIr.Instances, out var reference)) return exposed;
+ var bindings = exposed.Bindings.Where(binding => binding is TolerancedDimensionBinding).ToList();
+ try { bindings.Add(AssemblyWorldQuery.Resolve(localIr, reference!.Value.StableIdentity)); } catch (InvalidOperationException) { }
+ return new(exposed.StableIdentity, exposed.Type, exposed.Capabilities.Values, bindings, exposed.ExposedMembers.Values, exposed.Provenance,
+ exposed.AuthoredSourceSpan, SemanticSourceSpan.Generated(sourceIdentity), exposed.ExposedName);
+ }
+
+ private static IReadOnlyList<DimensionalRelationIr> BuildPublicRelations(AssemblyDefinitionSource definition, string specializationIdentity,
+ IReadOnlyList<SemanticValue> publicSemantics, AssemblyIr localIr, List<AssemblyDiagnostic> diagnostics)
+ {
+ var result = new List<DimensionalRelationIr>();
+ foreach (var exposed in definition.ExposedRelations ?? [])
+ {
+ var fromPath = Prefix(exposed.InternalFrom, definition.Name); var toPath = Prefix(exposed.InternalTo, definition.Name);
+ if (!AssemblyM0Compiler.TryResolve(fromPath, localIr.Instances, out var from) || !AssemblyM0Compiler.TryResolve(toPath, localIr.Instances, out var to))
+ { diagnostics.Add(new("assembly-exposed-relation-unresolved", $"Exposed relation '{exposed.Name}' has an unresolved internal endpoint.")); continue; }
+ var paths = FindRelationPaths(from!.Value.StableIdentity, to!.Value.StableIdentity, localIr.DimensionalRelations, 2);
+ if (paths.Count != 1) { diagnostics.Add(new(paths.Count == 0 ? "assembly-exposed-relation-missing-chain" : "assembly-exposed-relation-ambiguous", $"Exposed relation '{exposed.Name}' requires exactly one internal dimensional chain.")); continue; }
+ var contributions = paths[0].Select(step => new StackupContributionIr(step.Edge.StableId, step.Sign, step.Sign * step.Edge.Nominal,
+ step.Sign > 0 ? step.Edge.LowerTolerance : -step.Edge.UpperTolerance, step.Sign > 0 ? step.Edge.UpperTolerance : -step.Edge.LowerTolerance,
+ step.Edge.Unit, step.Edge.OriginInstancePath, step.Edge.Provenance, step.Edge.MateStableId, step.Edge.InterfaceStableId, step.Edge.SourceProvenance)).ToArray();
+ if (!publicSemantics.Any(value => value.ExposedName == exposed.PublicFrom) || !publicSemantics.Any(value => value.ExposedName == exposed.PublicTo))
+ { diagnostics.Add(new("assembly-exposed-relation-public-endpoint-missing", $"Exposed relation '{exposed.Name}' references a public semantic name that is not exposed.")); continue; }
+ var nominal = contributions.Sum(item => item.Nominal); var lower = contributions.Sum(item => item.LowerTolerance); var upper = contributions.Sum(item => item.UpperTolerance);
+ result.Add(new("assembly-public-relation:" + specializationIdentity + ":" + exposed.Name, exposed.PublicFrom, exposed.PublicTo,
+ nominal, lower, upper, contributions[0].Unit, 1, definition.Name, exposed.Name, SourceProvenance: definition.Provenance, ExpandedContributors: contributions));
+ }
+ return result;
+ static AssemblyPath Prefix(AssemblyPath path, string root) => path.Segments.FirstOrDefault() == root ? path : new([root, .. path.Segments]);
+ }
+
+ private static List<List<(DimensionalRelationIr Edge, int Sign)>> FindRelationPaths(string start, string end, IReadOnlyList<DimensionalRelationIr> edges, int limit)
+ {
+ var result = new List<List<(DimensionalRelationIr, int)>>();
+ void Visit(string node, HashSet<string> visited, List<(DimensionalRelationIr, int)> path)
+ {
+ if (result.Count >= limit) return;
+ if (node == end) { result.Add([.. path]); return; }
+ foreach (var edge in edges.OrderBy(item => item.StableId, StringComparer.Ordinal))
+ {
+ var next = edge.FromSemanticValueId == node ? edge.ToSemanticValueId : edge.ToSemanticValueId == node ? edge.FromSemanticValueId : null;
+ if (next is null || visited.Contains(next)) continue;
+ visited.Add(next); path.Add((edge, edge.FromSemanticValueId == node ? 1 : -1)); Visit(next, visited, path); path.RemoveAt(path.Count - 1); visited.Remove(next);
+ }
+ }
+ Visit(start, new([start], StringComparer.Ordinal), []); return result;
+ }
+
+ private static string NormalizeIdentity(string value) => Regex.Replace(value, @"\s+", string.Empty);
+
+ private static AssemblyMemberSource? ParseTree(string body, string sourceIdentity, List<AssemblyDiagnostic> diagnostics,
+ IReadOnlyList<AssemblyDefinitionSource>? definitions = null, IReadOnlyList<InterfaceDefinition>? interfaces = null,
+ IDictionary<string, AssemblyMemberSource>? specializationCache = null)
{
// One bounded generic argument list is admitted in a Part definition. The
// inner '>' belongs to the Firmament Template application, not the XML-like tag.
@@ -96,11 +297,24 @@ public sealed class AssemblyM0Parser
{
var rest = tag.Groups["rest"].Value.Trim();
var nodeMatch = kind == "Assembly"
- ? Regex.Match(rest, @"^(?<name>[A-Za-z_]\w*)$")
+ ? Regex.Match(rest, @"^(?<name>[A-Za-z_]\w*)(?:\s*=\s*(?<definition>[A-Za-z_]\w*(?:\s*<[^>]+>)?))?$")
: Regex.Match(rest, @"^(?<name>[A-Za-z_]\w*)\s*=\s*(?<definition>[A-Za-z_]\w*(?:\s*<[^>]+>)?)$");
if (!nodeMatch.Success) { diagnostics.Add(new("assembly-tree-invalid-tag", $"Invalid <{kind}> tree tag '{tag.Value}'.")); continue; }
var node = new MutableNode(nodeMatch.Groups["name"].Value, kind == "Assembly" ? AssemblyInstanceKind.Assembly : AssemblyInstanceKind.Part,
- kind == "Assembly" ? nodeMatch.Groups["name"].Value : nodeMatch.Groups["definition"].Value);
+ kind == "Assembly" ? (nodeMatch.Groups["definition"].Success ? NormalizeIdentity(nodeMatch.Groups["definition"].Value) : nodeMatch.Groups["name"].Value) : nodeMatch.Groups["definition"].Value);
+ if (kind == "Assembly" && nodeMatch.Groups["definition"].Success)
+ {
+ var instantiated = InstantiateAssemblyDefinition(node.Name, node.Definition, definitions ?? [], interfaces ?? [], specializationCache ?? new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal), sourceIdentity, diagnostics);
+ if (instantiated is not null)
+ {
+ node.Children.AddRange(instantiated.Children.Select(ToMutable));
+ node.Semantics.AddRange(instantiated.ExposedSemantics);
+ node.ExplicitTransform = instantiated.ExplicitTransform;
+ node.PlacementAuthority = instantiated.PlacementAuthority;
+ node.IsEncapsulatedDefinition = true;
+ node.SolvedAssemblyDefinition = instantiated.SolvedAssemblyDefinition;
+ }
+ }
if (stack.Count > 0) { node.Parent = stack.Peek().node; node.Parent.Children.Add(node); }
else if (root is null) root = node;
else diagnostics.Add(new("assembly-tree-multiple-roots", "Assembly source must contain exactly one XML-like tree root."));
@@ -137,8 +351,16 @@ public sealed class AssemblyM0Parser
if (root is null) diagnostics.Add(new("assembly-tree-missing", "Assembly body requires a nested <Assembly Name> product tree."));
AssemblyMemberSource Freeze(MutableNode node) => new(node.Name, node.Kind, node.Definition,
node.Children.Select(Freeze).ToArray(), node.Semantics, [], [new("assembly-source", node.Name, node.Definition, SemanticSourceSpan.Generated(sourceIdentity))],
- node.ExplicitTransform, node.PlacementAuthority);
+ node.ExplicitTransform, node.PlacementAuthority, node.IsEncapsulatedDefinition, node.SolvedAssemblyDefinition);
return root is null ? null : Freeze(root);
+
+ MutableNode ToMutable(AssemblyMemberSource source)
+ {
+ var mutable = new MutableNode(source.Name, source.Kind, source.DefinitionIdentity) { ExplicitTransform = source.ExplicitTransform, PlacementAuthority = source.PlacementAuthority, IsEncapsulatedDefinition = source.IsEncapsulatedDefinition, SolvedAssemblyDefinition = source.SolvedAssemblyDefinition };
+ mutable.Semantics.AddRange(source.ExposedSemantics);
+ mutable.Children.AddRange(source.Children.Select(ToMutable));
+ return mutable;
+ }
}
private static IEnumerable<SemanticValue> ParseSemantics(string body, string definition, string sourceIdentity, List<AssemblyDiagnostic> diagnostics)
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM2Interop.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM2Interop.cs
index c0b58627..ca9c1e74 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM2Interop.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM2Interop.cs
@@ -106,8 +106,11 @@ public static class AssemblyIrAp242Exporter
var ir = compilation.Ir;
var artifactByIdentity = compilation.Geometry.Artifact.Definitions.ToDictionary(item => item.DefinitionIdentity, item => item.StableId, StringComparer.Ordinal);
var definitions = compilation.Geometry.DefinitionBodies.OrderBy(pair => pair.Key, StringComparer.Ordinal)
- .Select(pair => new Step242AssemblyDefinition(artifactByIdentity[pair.Key], pair.Key, pair.Value)).ToArray();
+ .Select(pair => new Step242AssemblyDefinition(artifactByIdentity[pair.Key], pair.Key, pair.Value))
+ .Concat((ir.AssemblyDefinitions ?? []).Select(definition => new Step242AssemblyDefinition(definition.StableId, definition.DefinitionIdentity, null)))
+ .OrderBy(definition => definition.StableId, StringComparer.Ordinal).ToArray();
var byId = ir.Instances.ToDictionary(item => item.StableId, StringComparer.Ordinal);
+ var assemblyDefinitionByIdentity = (ir.AssemblyDefinitions ?? []).ToDictionary(item => item.DefinitionIdentity, item => item.StableId, StringComparer.Ordinal);
var occurrences = ir.Instances.OrderBy(item => item.Path.Segments.Count).ThenBy(item => item.StableId, StringComparer.Ordinal).Select(instance =>
{
var world = instance.ResolvedTransform ?? AssemblyTransform.Identity;
@@ -118,7 +121,8 @@ public static class AssemblyIrAp242Exporter
local = (Transform3D.FromRowMajor(world.Matrix) * parent.Inverse()).ToRowMajor();
}
return new Step242AssemblyOccurrence(instance.StableId, instance.Path.Segments.Last(), instance.ParentStableId,
- instance.Kind == AssemblyInstanceKind.Part ? artifactByIdentity[instance.DefinitionIdentity] : null, local);
+ instance.Kind == AssemblyInstanceKind.Part ? artifactByIdentity[instance.DefinitionIdentity]
+ : instance.IsEncapsulatedDefinition ? assemblyDefinitionByIdentity[instance.DefinitionIdentity] : null, local);
}).ToArray();
return Step242AssemblyExporter.Export(new(ir.Name, ir.RootInstanceStableId, definitions, occurrences));
}
diff --git a/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs b/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs
index f93e1fe5..5a555e43 100644
--- a/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs
@@ -78,7 +78,11 @@ public sealed class FirmamentAssemblyDocumentCompiler
public static IReadOnlyList<AssemblyDiagnostic> ValidateProfile(string source, FirmamentDocumentProfile profile)
{
if (profile == FirmamentDocumentProfile.General) return [];
- var roots = Regex.Matches(source, @"(?m)^\s*Assembly\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant).Count;
+ var assemblies = Regex.Matches(source, @"(?m)^\s*Assembly\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant).Count;
+ // A Template-produced Assembly is a reusable definition, not an exported
+ // product root. It intentionally shares the existing Template keyword.
+ var templateAssemblies = Regex.Matches(source, @"\bTemplate\s*<[^>]+>\s*Assembly\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant).Count;
+ var roots = assemblies - templateAssemblies;
return roots switch
{
0 => [new("assembly-profile-no-root", ".firmasm requires exactly one exported/root Assembly product; none was found.")],
diff --git a/Aetheris.Server.Tests/KernelApiIntegrationTests.cs b/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
index d22635ef..4cdfbb78 100644
--- a/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
+++ b/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
@@ -935,6 +935,30 @@ public sealed class KernelApiIntegrationTests : IClassFixture<WebApplicationFact
Assert.All(envelope.Data.Occurrences, occurrence => Assert.Equal("MateDerived", occurrence.PlacementAuthority));
}
+ [Fact]
+ public async Task AssemblyDisplay_TemplateSubassemblyPublishesNestedTreeSelectionAndPublicSurface()
+ {
+ var path = Path.Combine(RepositoryRoot(), "fixtures", "AssemblyM3", "bearing-module.firmament");
+ var response = await _client.PostAsJsonAsync("/api/v1/assemblies/display", new AssemblyDisplayRequestDto(path));
+ response.EnsureSuccessStatusCode();
+ var envelope = await response.Content.ReadFromJsonAsync<ApiResponseDto<AssemblyDisplayPacketDto>>();
+
+ Assert.True(envelope!.Success);
+ Assert.Equal("aetheris/cadmata-assembly-display/m3", envelope.Data!.Schema);
+ Assert.Equal(12, envelope.Data.Occurrences.Count);
+ var left = envelope.Data.Occurrences.Single(item => item.InstancePath == "Machine.LeftModule");
+ var right = envelope.Data.Occurrences.Single(item => item.InstancePath == "Machine.RightModule");
+ Assert.Equal(left.DefinitionStableId, right.DefinitionStableId);
+ Assert.Equal(5, left.SelectionMembers!.Count);
+ Assert.DoesNotContain(right.StableId, left.SelectionMembers);
+ Assert.Single(envelope.Data.ModuleDefinitions!);
+ var module = envelope.Data.ModuleDefinitions![0];
+ Assert.Contains(module.PublicSemantics, item => item.Name == "Mount" && item.InternalImplementationPath == "Housing.Mount");
+ Assert.Contains(module.PublicSemantics, item => item.Name == "DriveAxis" && item.Capabilities.Contains("AxisCapable"));
+ Assert.Contains(envelope.Data.Mates.Single(item => item.Name == "PlaceLeft").Participants, item => item.Contains("Machine.LeftModule.Mount", StringComparison.Ordinal));
+ Assert.Equal(3, Assert.Single(envelope.Data.ToleranceStackups).ExpandedContributors!.Count);
+ }
+
private static string RepositoryRoot()
{
var current = new DirectoryInfo(AppContext.BaseDirectory);
diff --git a/Aetheris.Server/Api/AssemblyDisplayService.cs b/Aetheris.Server/Api/AssemblyDisplayService.cs
index 60f12fb0..df06f1b9 100644
--- a/Aetheris.Server/Api/AssemblyDisplayService.cs
+++ b/Aetheris.Server/Api/AssemblyDisplayService.cs
@@ -35,18 +35,28 @@ public static class AssemblyDisplayService
}
var occurrences = compilation.Ir.Instances.OrderBy(item => item.Path.Segments.Count).ThenBy(item => item.Path.ToString(), StringComparer.Ordinal).Select(instance => new AssemblyDisplayOccurrenceDto(
instance.StableId, instance.Path.Segments[^1], instance.Path.ToString(), instance.ParentStableId,
- instance.Kind == AssemblyInstanceKind.Part ? artifactByIdentity.GetValueOrDefault(instance.DefinitionIdentity) : null,
- instance.Kind.ToString(), (instance.ResolvedTransform ?? AssemblyTransform.Identity).Matrix, instance.PlacementAuthority.ToString())).ToArray();
+ instance.Kind == AssemblyInstanceKind.Part ? artifactByIdentity.GetValueOrDefault(instance.DefinitionIdentity)
+ : (compilation.Ir.AssemblyDefinitions ?? []).SingleOrDefault(item => item.DefinitionIdentity == instance.DefinitionIdentity)?.StableId,
+ instance.Kind.ToString(), (instance.ResolvedTransform ?? AssemblyTransform.Identity).Matrix, instance.PlacementAuthority.ToString(),
+ compilation.Ir.Instances.Where(candidate => candidate.Path.Segments.Count >= instance.Path.Segments.Count
+ && candidate.Path.Segments.Take(instance.Path.Segments.Count).SequenceEqual(instance.Path.Segments)).Select(candidate => candidate.StableId).ToArray())).ToArray();
var mates = compilation.Ir.Mates.Select(mate => new AssemblyDisplayMateDto(mate.StableId, mate.Name, mate.InterfaceStableId,
mate.Roles.Select(role => $"{role.Role}: {role.ParticipantPath}").ToArray(), mate.ConstraintIds, mate.ValidationStatus)).ToArray();
var tolerances = compilation.Ir.ToleranceStackups.Select(stack => new AssemblyDisplayToleranceDto(stack.Name, stack.Passed, stack.Nominal, stack.WorstCaseMinimum, stack.WorstCaseMaximum, stack.Unit,
- stack.Contributions.Select(contribution => $"{contribution.OriginInstancePath}: {contribution.RelationStableId}").ToArray())).ToArray();
+ stack.Contributions.Select(contribution => $"{contribution.OriginInstancePath}: {contribution.RelationStableId}").ToArray(),
+ stack.Contributions.SelectMany(contribution => contribution.ExpandedContributors ?? []).Select(item => $"{item.Provenance}: {item.Nominal:G6} {item.Unit} [{item.Nominal + item.LowerTolerance:G6}, {item.Nominal + item.UpperTolerance:G6}]").ToArray())).ToArray();
+ var modules = (compilation.Ir.AssemblyDefinitions ?? []).Select(definition => new AssemblyDisplayModuleDefinitionDto(
+ definition.StableId, definition.DefinitionIdentity, definition.TemplateName, definition.SpecializationIdentity,
+ definition.Provenance.Select(item => $"{item.Stage}:{item.Identity}:{item.Evidence}").ToArray(),
+ definition.PublicSemantics.Select(semantic => new AssemblyDisplayPublicSemanticDto(semantic.ExposedName ?? semantic.StableIdentity, semantic.Type.Name,
+ semantic.Capabilities.Values.Select(item => item.Name).Order(StringComparer.Ordinal).ToArray(), semantic.Bindings.Select(item => item.Kind).Order(StringComparer.Ordinal).ToArray(),
+ semantic.Provenance.LastOrDefault(item => item.Stage == "assembly-expose")?.Evidence)).ToArray(), definition.SolveMilliseconds)).ToArray();
var metrics = compilation.Geometry.Artifact.Instances.Select(item => item.Metrics).ToArray();
var minimum = metrics.Length == 0 ? new[] { 0d,0d,0d } : new[] { metrics.Min(item => item.Minimum[0]), metrics.Min(item => item.Minimum[1]), metrics.Min(item => item.Minimum[2]) };
var maximum = metrics.Length == 0 ? new[] { 0d,0d,0d } : new[] { metrics.Max(item => item.Maximum[0]), metrics.Max(item => item.Maximum[1]), metrics.Max(item => item.Maximum[2]) };
watch.Stop();
- packet = new("aetheris/cadmata-assembly-display/m2", compilation.Ir.Name, compilation.Ir.RootInstanceStableId, definitions, occurrences, mates, tolerances,
- new(minimum, maximum), diagnostics, new Dictionary<string, double> { ["packetMilliseconds"] = watch.Elapsed.TotalMilliseconds, ["definitionCount"] = definitions.Count, ["occurrenceCount"] = occurrences.Length });
+ packet = new("aetheris/cadmata-assembly-display/m3", compilation.Ir.Name, compilation.Ir.RootInstanceStableId, definitions, occurrences, mates, tolerances,
+ new(minimum, maximum), diagnostics, new Dictionary<string, double> { ["packetMilliseconds"] = watch.Elapsed.TotalMilliseconds, ["definitionCount"] = definitions.Count, ["moduleDefinitionCount"] = modules.Length, ["occurrenceCount"] = occurrences.Length }, modules);
return true;
}
}
diff --git a/Aetheris.Server/Contracts/ApiContracts.cs b/Aetheris.Server/Contracts/ApiContracts.cs
index aeea76ec..def1b151 100644
--- a/Aetheris.Server/Contracts/ApiContracts.cs
+++ b/Aetheris.Server/Contracts/ApiContracts.cs
@@ -217,11 +217,13 @@ public sealed record DisplayDiagnosticDto(
public sealed record AssemblyDisplayRequestDto(string Path);
public sealed record AssemblyDisplayDefinitionDto(string StableId, string DefinitionIdentity, IReadOnlyList<FacePatchDto> FacePatches);
-public sealed record AssemblyDisplayOccurrenceDto(string StableId, string Name, string InstancePath, string? ParentStableId, string? DefinitionStableId, string Kind, IReadOnlyList<double> WorldTransform, string PlacementAuthority);
+public sealed record AssemblyDisplayPublicSemanticDto(string Name, string Type, IReadOnlyList<string> Capabilities, IReadOnlyList<string> BindingKinds, string? InternalImplementationPath);
+public sealed record AssemblyDisplayModuleDefinitionDto(string StableId, string DefinitionIdentity, string TemplateName, string SpecializationIdentity, IReadOnlyList<string> Provenance, IReadOnlyList<AssemblyDisplayPublicSemanticDto> PublicSemantics, double LocalSolveMilliseconds);
+public sealed record AssemblyDisplayOccurrenceDto(string StableId, string Name, string InstancePath, string? ParentStableId, string? DefinitionStableId, string Kind, IReadOnlyList<double> WorldTransform, string PlacementAuthority, IReadOnlyList<string>? SelectionMembers = null);
public sealed record AssemblyDisplayMateDto(string StableId, string Name, string InterfaceStableId, IReadOnlyList<string> Participants, IReadOnlyList<string> ConstraintIds, string ValidationStatus);
-public sealed record AssemblyDisplayToleranceDto(string Name, bool Passed, double Nominal, double Minimum, double Maximum, string Unit, IReadOnlyList<string> Contributors);
+public sealed record AssemblyDisplayToleranceDto(string Name, bool Passed, double Nominal, double Minimum, double Maximum, string Unit, IReadOnlyList<string> Contributors, IReadOnlyList<string>? ExpandedContributors = null);
public sealed record AssemblyDisplayBoundsDto(IReadOnlyList<double> Minimum, IReadOnlyList<double> Maximum);
-public sealed record AssemblyDisplayPacketDto(string Schema, string Name, string RootOccurrenceStableId, IReadOnlyList<AssemblyDisplayDefinitionDto> Definitions, IReadOnlyList<AssemblyDisplayOccurrenceDto> Occurrences, IReadOnlyList<AssemblyDisplayMateDto> Mates, IReadOnlyList<AssemblyDisplayToleranceDto> ToleranceStackups, AssemblyDisplayBoundsDto Bounds, IReadOnlyList<DisplayDiagnosticDto> Diagnostics, IReadOnlyDictionary<string, double> Performance);
+public sealed record AssemblyDisplayPacketDto(string Schema, string Name, string RootOccurrenceStableId, IReadOnlyList<AssemblyDisplayDefinitionDto> Definitions, IReadOnlyList<AssemblyDisplayOccurrenceDto> Occurrences, IReadOnlyList<AssemblyDisplayMateDto> Mates, IReadOnlyList<AssemblyDisplayToleranceDto> ToleranceStackups, AssemblyDisplayBoundsDto Bounds, IReadOnlyList<DisplayDiagnosticDto> Diagnostics, IReadOnlyDictionary<string, double> Performance, IReadOnlyList<AssemblyDisplayModuleDefinitionDto>? ModuleDefinitions = null);
public sealed record PickOptionsDto(bool? NearestOnly, bool? IncludeBackfaces, double? EdgeTolerance, double? SortTieTolerance, double? MaxDistance);
diff --git a/aetheris.client/src/App.tsx b/aetheris.client/src/App.tsx
index 2070caef..4e8da0b5 100644
--- a/aetheris.client/src/App.tsx
+++ b/aetheris.client/src/App.tsx
@@ -1102,7 +1102,7 @@ function App() {
(item) => item.stableId === selectedAssemblyOccurrenceId,
);
return occurrence ? (
- <p className="semantic-provenance">
+ <div className="semantic-provenance">
<strong>{occurrence.instancePath}</strong>
<br />
Placement:{" "}
@@ -1111,7 +1111,38 @@ function App() {
: occurrence.placementAuthority === "ImportedOccurrence"
? "Imported occurrence"
: "Legacy explicit transform"}
- </p>
+ {(() => {
+ const definition = assemblyPacket.moduleDefinitions?.find(
+ (item) => item.stableId === occurrence.definitionStableId,
+ );
+ return definition ? (
+ <>
+ <br />
+ Definition: {definition.definitionIdentity}
+ <br />
+ Template: {definition.templateName}
+ <br />
+ Public surface:
+ <ul>
+ {definition.publicSemantics.map((semantic) => (
+ <li key={semantic.name}>
+ <strong>
+ {occurrence.name}.{semantic.name}
+ </strong>{" "}
+ · {semantic.capabilities.join(", ")}
+ {semantic.internalImplementationPath ? (
+ <small>
+ {" "}
+ (implemented by {semantic.internalImplementationPath})
+ </small>
+ ) : null}
+ </li>
+ ))}
+ </ul>
+ </>
+ ) : null;
+ })()}
+ </div>
) : null;
})()
: null}
@@ -1139,6 +1170,17 @@ function App() {
</strong>
<br />
{stack.nominal} {stack.unit} [{stack.minimum}, {stack.maximum}]
+ {stack.expandedContributors?.length ? (
+ <details>
+ <summary>Expanded internal contributors</summary>
+ {stack.expandedContributors.map((item) => (
+ <span key={item}>
+ {item}
+ <br />
+ </span>
+ ))}
+ </details>
+ ) : null}
</p>
))}
</>
diff --git a/aetheris.client/src/api/aetherisApi.ts b/aetheris.client/src/api/aetherisApi.ts
index 642bad78..1583b59e 100644
--- a/aetheris.client/src/api/aetherisApi.ts
+++ b/aetheris.client/src/api/aetherisApi.ts
@@ -131,6 +131,23 @@ export interface AssemblyDisplayOccurrenceDto {
kind: "Assembly" | "Part";
worldTransform: number[];
placementAuthority: "MateDerived" | "ImportedOccurrence" | "LegacyExplicit";
+ selectionMembers?: string[];
+}
+export interface AssemblyDisplayPublicSemanticDto {
+ name: string;
+ type: string;
+ capabilities: string[];
+ bindingKinds: string[];
+ internalImplementationPath: string | null;
+}
+export interface AssemblyDisplayModuleDefinitionDto {
+ stableId: string;
+ definitionIdentity: string;
+ templateName: string;
+ specializationIdentity: string;
+ provenance: string[];
+ publicSemantics: AssemblyDisplayPublicSemanticDto[];
+ localSolveMilliseconds: number;
}
export interface AssemblyDisplayMateDto {
stableId: string;
@@ -148,6 +165,7 @@ export interface AssemblyDisplayToleranceDto {
maximum: number;
unit: string;
contributors: string[];
+ expandedContributors?: string[];
}
export interface AssemblyDisplayPacketDto {
schema: string;
@@ -160,6 +178,7 @@ export interface AssemblyDisplayPacketDto {
bounds: { minimum: number[]; maximum: number[] };
diagnostics: DisplayDiagnosticDto[];
performance: Record<string, number>;
+ moduleDefinitions?: AssemblyDisplayModuleDefinitionDto[];
}
export interface AnalyticDisplayPlaneGeometryDto {
diff --git a/aetheris.client/src/viewer/AetherisViewport.tsx b/aetheris.client/src/viewer/AetherisViewport.tsx
index 2576a261..46f4a1fe 100644
--- a/aetheris.client/src/viewer/AetherisViewport.tsx
+++ b/aetheris.client/src/viewer/AetherisViewport.tsx
@@ -513,6 +513,14 @@ function AssemblyMeshes({
),
[packet],
);
+ const selectedMembers = useMemo(
+ () =>
+ new Set(
+ packet.occurrences.find((item) => item.stableId === selectedId)?.selectionMembers ??
+ (selectedId ? [selectedId] : []),
+ ),
+ [packet, selectedId],
+ );
return packet.occurrences
.filter((occurrence) => occurrence.kind === "Part" && occurrence.definitionStableId)
.map((occurrence) => {
@@ -533,7 +541,7 @@ function AssemblyMeshes({
positions={patch.positions}
normals={patch.normals}
indices={patch.indices}
- isHighlighted={selectedId === occurrence.stableId}
+ isHighlighted={selectedMembers.has(occurrence.stableId)}
theme={theme}
/>
))}
diff --git a/docs/assembly/artifacts/m3/ap242-roundtrip.md b/docs/assembly/artifacts/m3/ap242-roundtrip.md
new file mode 100644
index 00000000..b8c413a7
--- /dev/null
+++ b/docs/assembly/artifacts/m3/ap242-roundtrip.md
@@ -0,0 +1,18 @@
+# AP242 nested round-trip
+
+Artifact: `bearing-module-ap242.step`
+
+- export SHA-256: `CBC0E664ED03FAFD272F344E160F85C7832D2C81668592A5C02A1B1158672DD3`
+- logical occurrences excluding root: 11
+- exact geometric definitions: 3
+- reusable Template Assembly definitions: 1
+- occurrences of reusable BearingModule definition: 2
+- reimport logical occurrences: 11
+- generated `.firmasm` recompilation instances including root: 12
+- generated `.firmasm` recompilation exact definitions: 3
+- generated `.firmasm` SHA-256: `A315B1797359DE1C7D3E9F19EA53808AEF53F31F298E2B7D44EF36D4CC717BA5`
+
+Definition-local AP242 child usages are emitted once beneath the reusable
+BearingModule product definition. Import expands those usages under each module
+occurrence, producing distinct Left/Right child occurrence identities while
+retaining shared Part definitions and local transforms.
diff --git a/docs/assembly/artifacts/m3/bearing-module-ap242.step b/docs/assembly/artifacts/m3/bearing-module-ap242.step
new file mode 100644
index 00000000..083225c4
--- /dev/null
+++ b/docs/assembly/artifacts/m3/bearing-module-ap242.step
@@ -0,0 +1,870 @@
+ISO-10303-21;
+HEADER;
+FILE_DESCRIPTION(('Aetheris AP242 assembly product structure'),'2;1');
+FILE_NAME('aetheris_assembly.step','1970-01-01T00:00:00',('Aetheris'),('Aetheris'),'Aetheris.Kernel','Aetheris.Kernel','');
+FILE_SCHEMA(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'));
+ENDSEC;
+DATA;
+#1=CARTESIAN_POINT($,(0,0,0));
+#2=DIRECTION($,(0,0,-1));
+#3=DIRECTION($,(1,0,0));
+#4=AXIS2_PLACEMENT_3D($,#1,#2,#3);
+#5=PLANE($,#4);
+#6=CARTESIAN_POINT($,(-10,-10,-0));
+#7=VERTEX_POINT($,#6);
+#8=CARTESIAN_POINT($,(10,-10,-0));
+#9=VERTEX_POINT($,#8);
+#10=CARTESIAN_POINT($,(-10,-10,-0));
+#11=DIRECTION($,(1,0,0));
+#12=VECTOR($,#11,1);
+#13=LINE($,#10,#12);
+#14=EDGE_CURVE($,#7,#9,#13,.T.);
+#15=ORIENTED_EDGE($,$,$,#14,.T.);
+#16=CARTESIAN_POINT($,(10,10,-0));
+#17=VERTEX_POINT($,#16);
+#18=CARTESIAN_POINT($,(10,-10,-0));
+#19=DIRECTION($,(0,1,0));
+#20=VECTOR($,#19,1);
+#21=LINE($,#18,#20);
+#22=EDGE_CURVE($,#9,#17,#21,.T.);
+#23=ORIENTED_EDGE($,$,$,#22,.T.);
+#24=CARTESIAN_POINT($,(-10,10,-0));
+#25=VERTEX_POINT($,#24);
+#26=CARTESIAN_POINT($,(10,10,-0));
+#27=DIRECTION($,(-1,0,0));
+#28=VECTOR($,#27,1);
+#29=LINE($,#26,#28);
+#30=EDGE_CURVE($,#17,#25,#29,.T.);
+#31=ORIENTED_EDGE($,$,$,#30,.T.);
+#32=CARTESIAN_POINT($,(-10,10,-0));
+#33=DIRECTION($,(0,-1,0));
+#34=VECTOR($,#33,1);
+#35=LINE($,#32,#34);
+#36=EDGE_CURVE($,#25,#7,#35,.T.);
+#37=ORIENTED_EDGE($,$,$,#36,.T.);
+#38=EDGE_LOOP($,(#15,#23,#31,#37));
+#39=FACE_OUTER_BOUND('',#38,.T.);
+#40=ADVANCED_FACE('',(#39),#5,.T.);
+#41=CARTESIAN_POINT($,(0,0,10));
+#42=DIRECTION($,(0,0,1));
+#43=DIRECTION($,(1,0,0));
+#44=AXIS2_PLACEMENT_3D($,#41,#42,#43);
+#45=PLANE($,#44);
+#46=CARTESIAN_POINT($,(-9,9,10));
+#47=VERTEX_POINT($,#46);
+#48=CARTESIAN_POINT($,(-9,-9,10));
+#49=VERTEX_POINT($,#48);
+#50=CARTESIAN_POINT($,(-9,9,10));
+#51=DIRECTION($,(0,-1,0));
+#52=VECTOR($,#51,1);
+#53=LINE($,#50,#52);
+#54=EDGE_CURVE($,#47,#49,#53,.T.);
+#55=ORIENTED_EDGE($,$,$,#54,.F.);
+#56=CARTESIAN_POINT($,(9,9,10));
+#57=VERTEX_POINT($,#56);
+#58=CARTESIAN_POINT($,(9,9,10));
+#59=DIRECTION($,(-1,0,0));
+#60=VECTOR($,#59,1);
+#61=LINE($,#58,#60);
+#62=EDGE_CURVE($,#57,#47,#61,.T.);
+#63=ORIENTED_EDGE($,$,$,#62,.F.);
+#64=CARTESIAN_POINT($,(9,-9,10));
+#65=VERTEX_POINT($,#64);
+#66=CARTESIAN_POINT($,(9,-9,10));
+#67=DIRECTION($,(0,1,0));
+#68=VECTOR($,#67,1);
+#69=LINE($,#66,#68);
+#70=EDGE_CURVE($,#65,#57,#69,.T.);
+#71=ORIENTED_EDGE($,$,$,#70,.F.);
+#72=CARTESIAN_POINT($,(-9,-9,10));
+#73=DIRECTION($,(1,0,0));
+#74=VECTOR($,#73,1);
+#75=LINE($,#72,#74);
+#76=EDGE_CURVE($,#49,#65,#75,.T.);
+#77=ORIENTED_EDGE($,$,$,#76,.F.);
+#78=EDGE_LOOP($,(#55,#63,#71,#77));
+#79=FACE_OUTER_BOUND('',#78,.T.);
+#80=ADVANCED_FACE('',(#79),#45,.T.);
+#81=CARTESIAN_POINT($,(-10,-10,0));
+#82=DIRECTION($,(0,-1,0));
+#83=DIRECTION($,(1,0,0));
+#84=AXIS2_PLACEMENT_3D($,#81,#82,#83);
+#85=PLANE($,#84);
+#86=ORIENTED_EDGE($,$,$,#14,.T.);
+#87=CARTESIAN_POINT($,(10,-10,9));
+#88=VERTEX_POINT($,#87);
+#89=CARTESIAN_POINT($,(10,-10,-0));
+#90=DIRECTION($,(0,0,1));
+#91=VECTOR($,#90,1);
+#92=LINE($,#89,#91);
+#93=EDGE_CURVE($,#9,#88,#92,.T.);
+#94=ORIENTED_EDGE($,$,$,#93,.T.);
+#95=CARTESIAN_POINT($,(-10,-10,9));
+#96=VERTEX_POINT($,#95);
+#97=CARTESIAN_POINT($,(-10,-10,9));
+#98=DIRECTION($,(1,0,0));
+#99=VECTOR($,#98,1);
+#100=LINE($,#97,#99);
+#101=EDGE_CURVE($,#96,#88,#100,.T.);
+#102=ORIENTED_EDGE($,$,$,#101,.F.);
+#103=CARTESIAN_POINT($,(-10,-10,-0));
+#104=DIRECTION($,(0,0,1));
+#105=VECTOR($,#104,1);
+#106=LINE($,#103,#105);
+#107=EDGE_CURVE($,#7,#96,#106,.T.);
+#108=ORIENTED_EDGE($,$,$,#107,.F.);
+#109=EDGE_LOOP($,(#86,#94,#102,#108));
+#110=FACE_OUTER_BOUND('',#109,.T.);
+#111=ADVANCED_FACE('',(#110),#85,.T.);
+#112=CARTESIAN_POINT($,(10,-10,0));
+#113=DIRECTION($,(1,0,0));
+#114=DIRECTION($,(0,1,0));
+#115=AXIS2_PLACEMENT_3D($,#112,#113,#114);
+#116=PLANE($,#115);
+#117=ORIENTED_EDGE($,$,$,#22,.T.);
+#118=CARTESIAN_POINT($,(10,10,9));
+#119=VERTEX_POINT($,#118);
+#120=CARTESIAN_POINT($,(10,10,-0));
+#121=DIRECTION($,(0,0,1));
+#122=VECTOR($,#121,1);
+#123=LINE($,#120,#122);
+#124=EDGE_CURVE($,#17,#119,#123,.T.);
+#125=ORIENTED_EDGE($,$,$,#124,.T.);
+#126=CARTESIAN_POINT($,(10,-10,9));
+#127=DIRECTION($,(0,1,0));
+#128=VECTOR($,#127,1);
+#129=LINE($,#126,#128);
+#130=EDGE_CURVE($,#88,#119,#129,.T.);
+#131=ORIENTED_EDGE($,$,$,#130,.F.);
+#132=ORIENTED_EDGE($,$,$,#93,.F.);
+#133=EDGE_LOOP($,(#117,#125,#131,#132));
+#134=FACE_OUTER_BOUND('',#133,.T.);
+#135=ADVANCED_FACE('',(#134),#116,.T.);
+#136=CARTESIAN_POINT($,(10,10,0));
+#137=DIRECTION($,(0,1,-0));
+#138=DIRECTION($,(-1,0,0));
+#139=AXIS2_PLACEMENT_3D($,#136,#137,#138);
+#140=PLANE($,#139);
+#141=ORIENTED_EDGE($,$,$,#30,.T.);
+#142=CARTESIAN_POINT($,(-10,10,9));
+#143=VERTEX_POINT($,#142);
+#144=CARTESIAN_POINT($,(-10,10,-0));
+#145=DIRECTION($,(0,0,1));
+#146=VECTOR($,#145,1);
+#147=LINE($,#144,#146);
+#148=EDGE_CURVE($,#25,#143,#147,.T.);
+#149=ORIENTED_EDGE($,$,$,#148,.T.);
+#150=CARTESIAN_POINT($,(10,10,9));
+#151=DIRECTION($,(-1,0,0));
+#152=VECTOR($,#151,1);
+#153=LINE($,#150,#152);
+#154=EDGE_CURVE($,#119,#143,#153,.T.);
+#155=ORIENTED_EDGE($,$,$,#154,.F.);
+#156=ORIENTED_EDGE($,$,$,#124,.F.);
+#157=EDGE_LOOP($,(#141,#149,#155,#156));
+#158=FACE_OUTER_BOUND('',#157,.T.);
+#159=ADVANCED_FACE('',(#158),#140,.T.);
+#160=CARTESIAN_POINT($,(-10,10,0));
+#161=DIRECTION($,(-1,0,0));
+#162=DIRECTION($,(0,-1,0));
+#163=AXIS2_PLACEMENT_3D($,#160,#161,#162);
+#164=PLANE($,#163);
+#165=ORIENTED_EDGE($,$,$,#36,.T.);
+#166=ORIENTED_EDGE($,$,$,#107,.T.);
+#167=CARTESIAN_POINT($,(-10,10,9));
+#168=DIRECTION($,(0,-1,0));
+#169=VECTOR($,#168,1);
+#170=LINE($,#167,#169);
+#171=EDGE_CURVE($,#143,#96,#170,.T.);
+#172=ORIENTED_EDGE($,$,$,#171,.F.);
+#173=ORIENTED_EDGE($,$,$,#148,.F.);
+#174=EDGE_LOOP($,(#165,#166,#172,#173));
+#175=FACE_OUTER_BOUND('',#174,.T.);
+#176=ADVANCED_FACE('',(#175),#164,.T.);
+#177=CARTESIAN_POINT($,(-10,-10,9));
+#178=DIRECTION($,(0,-0.707106781186548,0.707106781186548));
+#179=DIRECTION($,(1,0,0));
+#180=AXIS2_PLACEMENT_3D($,#177,#178,#179);
+#181=PLANE($,#180);
+#182=ORIENTED_EDGE($,$,$,#101,.T.);
+#183=CARTESIAN_POINT($,(10,-10,9));
+#184=DIRECTION($,(-0.577350269189626,0.577350269189626,0.577350269189626));
+#185=VECTOR($,#184,1);
+#186=LINE($,#183,#185);
+#187=EDGE_CURVE($,#88,#65,#186,.T.);
+#188=ORIENTED_EDGE($,$,$,#187,.T.);
+#189=ORIENTED_EDGE($,$,$,#76,.F.);
+#190=CARTESIAN_POINT($,(-10,-10,9));
+#191=DIRECTION($,(0.577350269189626,0.577350269189626,0.577350269189626));
+#192=VECTOR($,#191,1);
+#193=LINE($,#190,#192);
+#194=EDGE_CURVE($,#96,#49,#193,.T.);
+#195=ORIENTED_EDGE($,$,$,#194,.F.);
+#196=EDGE_LOOP($,(#182,#188,#189,#195));
+#197=FACE_OUTER_BOUND('',#196,.T.);
+#198=ADVANCED_FACE('',(#197),#181,.T.);
+#199=CARTESIAN_POINT($,(10,-10,9));
+#200=DIRECTION($,(0.707106781186548,-0,0.707106781186548));
+#201=DIRECTION($,(0,1,0));
+#202=AXIS2_PLACEMENT_3D($,#199,#200,#201);
+#203=PLANE($,#202);
+#204=ORIENTED_EDGE($,$,$,#130,.T.);
+#205=CARTESIAN_POINT($,(10,10,9));
+#206=DIRECTION($,(-0.577350269189626,-0.577350269189626,0.577350269189626));
+#207=VECTOR($,#206,1);
+#208=LINE($,#205,#207);
+#209=EDGE_CURVE($,#119,#57,#208,.T.);
+#210=ORIENTED_EDGE($,$,$,#209,.T.);
+#211=ORIENTED_EDGE($,$,$,#70,.F.);
+#212=ORIENTED_EDGE($,$,$,#187,.F.);
+#213=EDGE_LOOP($,(#204,#210,#211,#212));
+#214=FACE_OUTER_BOUND('',#213,.T.);
+#215=ADVANCED_FACE('',(#214),#203,.T.);
+#216=CARTESIAN_POINT($,(10,10,9));
+#217=DIRECTION($,(0,0.707106781186548,0.707106781186548));
+#218=DIRECTION($,(-1,0,0));
+#219=AXIS2_PLACEMENT_3D($,#216,#217,#218);
+#220=PLANE($,#219);
+#221=ORIENTED_EDGE($,$,$,#154,.T.);
+#222=CARTESIAN_POINT($,(-10,10,9));
+#223=DIRECTION($,(0.577350269189626,-0.577350269189626,0.577350269189626));
+#224=VECTOR($,#223,1);
+#225=LINE($,#222,#224);
+#226=EDGE_CURVE($,#143,#47,#225,.T.);
+#227=ORIENTED_EDGE($,$,$,#226,.T.);
+#228=ORIENTED_EDGE($,$,$,#62,.F.);
+#229=ORIENTED_EDGE($,$,$,#209,.F.);
+#230=EDGE_LOOP($,(#221,#227,#228,#229));
+#231=FACE_OUTER_BOUND('',#230,.T.);
+#232=ADVANCED_FACE('',(#231),#220,.T.);
+#233=CARTESIAN_POINT($,(-10,10,9));
+#234=DIRECTION($,(-0.707106781186548,0,0.707106781186548));
+#235=DIRECTION($,(0,-1,0));
+#236=AXIS2_PLACEMENT_3D($,#233,#234,#235);
+#237=PLANE($,#236);
+#238=ORIENTED_EDGE($,$,$,#171,.T.);
+#239=ORIENTED_EDGE($,$,$,#194,.T.);
+#240=ORIENTED_EDGE($,$,$,#54,.F.);
+#241=ORIENTED_EDGE($,$,$,#226,.F.);
+#242=EDGE_LOOP($,(#238,#239,#240,#241));
+#243=FACE_OUTER_BOUND('',#242,.T.);
+#244=ADVANCED_FACE('',(#243),#237,.T.);
+#245=CLOSED_SHELL($,(#40,#80,#111,#135,#159,#176,#198,#215,#232,#244));
+#246=MANIFOLD_SOLID_BREP('AssemblyBlock<Spec: HousingSpec>',#245);
+#247=APPLICATION_CONTEXT('mechanical design');
+#248=PRODUCT_CONTEXT('',#247,'mechanical');
+#249=PRODUCT('assembly-definition:2D6E0B6EEEAE5CE1','AssemblyBlock<Spec: HousingSpec>','Aetheris shared assembly definition',(#248));
+#250=PRODUCT_DEFINITION_FORMATION('','',#249);
+#251=PRODUCT_DEFINITION_CONTEXT('design',#247,'design');
+#252=PRODUCT_DEFINITION('','',#250,#251);
+#253=PRODUCT_DEFINITION_SHAPE('','',#252);
+#254=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#255=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#256=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#257=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#254,#255,#256))REPRESENTATION_CONTEXT('3','3D'));
+#258=SHAPE_REPRESENTATION('AssemblyBlock<Spec: HousingSpec>',(#246),#257);
+#259=SHAPE_DEFINITION_REPRESENTATION(#253,#258);
+#260=CARTESIAN_POINT($,(0,0,0));
+#261=DIRECTION($,(0,0,-1));
+#262=DIRECTION($,(1,0,0));
+#263=AXIS2_PLACEMENT_3D($,#260,#261,#262);
+#264=PLANE($,#263);
+#265=CARTESIAN_POINT($,(-4,-4,-0));
+#266=VERTEX_POINT($,#265);
+#267=CARTESIAN_POINT($,(4,-4,-0));
+#268=VERTEX_POINT($,#267);
+#269=CARTESIAN_POINT($,(-4,-4,-0));
+#270=DIRECTION($,(1,0,0));
+#271=VECTOR($,#270,1);
+#272=LINE($,#269,#271);
+#273=EDGE_CURVE($,#266,#268,#272,.T.);
+#274=ORIENTED_EDGE($,$,$,#273,.T.);
+#275=CARTESIAN_POINT($,(4,4,-0));
+#276=VERTEX_POINT($,#275);
+#277=CARTESIAN_POINT($,(4,-4,-0));
+#278=DIRECTION($,(0,1,0));
+#279=VECTOR($,#278,1);
+#280=LINE($,#277,#279);
+#281=EDGE_CURVE($,#268,#276,#280,.T.);
+#282=ORIENTED_EDGE($,$,$,#281,.T.);
+#283=CARTESIAN_POINT($,(-4,4,-0));
+#284=VERTEX_POINT($,#283);
+#285=CARTESIAN_POINT($,(4,4,-0));
+#286=DIRECTION($,(-1,0,0));
+#287=VECTOR($,#286,1);
+#288=LINE($,#285,#287);
+#289=EDGE_CURVE($,#276,#284,#288,.T.);
+#290=ORIENTED_EDGE($,$,$,#289,.T.);
+#291=CARTESIAN_POINT($,(-4,4,-0));
+#292=DIRECTION($,(0,-1,0));
+#293=VECTOR($,#292,1);
+#294=LINE($,#291,#293);
+#295=EDGE_CURVE($,#284,#266,#294,.T.);
+#296=ORIENTED_EDGE($,$,$,#295,.T.);
+#297=EDGE_LOOP($,(#274,#282,#290,#296));
+#298=FACE_OUTER_BOUND('',#297,.T.);
+#299=ADVANCED_FACE('',(#298),#264,.T.);
+#300=CARTESIAN_POINT($,(0,0,10));
+#301=DIRECTION($,(0,0,1));
+#302=DIRECTION($,(1,0,0));
+#303=AXIS2_PLACEMENT_3D($,#300,#301,#302);
+#304=PLANE($,#303);
+#305=CARTESIAN_POINT($,(-3,3,10));
+#306=VERTEX_POINT($,#305);
+#307=CARTESIAN_POINT($,(-3,-3,10));
+#308=VERTEX_POINT($,#307);
+#309=CARTESIAN_POINT($,(-3,3,10));
+#310=DIRECTION($,(0,-1,0));
+#311=VECTOR($,#310,1);
+#312=LINE($,#309,#311);
+#313=EDGE_CURVE($,#306,#308,#312,.T.);
+#314=ORIENTED_EDGE($,$,$,#313,.F.);
+#315=CARTESIAN_POINT($,(3,3,10));
+#316=VERTEX_POINT($,#315);
+#317=CARTESIAN_POINT($,(3,3,10));
+#318=DIRECTION($,(-1,0,0));
+#319=VECTOR($,#318,1);
+#320=LINE($,#317,#319);
+#321=EDGE_CURVE($,#316,#306,#320,.T.);
+#322=ORIENTED_EDGE($,$,$,#321,.F.);
+#323=CARTESIAN_POINT($,(3,-3,10));
+#324=VERTEX_POINT($,#323);
+#325=CARTESIAN_POINT($,(3,-3,10));
+#326=DIRECTION($,(0,1,0));
+#327=VECTOR($,#326,1);
+#328=LINE($,#325,#327);
+#329=EDGE_CURVE($,#324,#316,#328,.T.);
+#330=ORIENTED_EDGE($,$,$,#329,.F.);
+#331=CARTESIAN_POINT($,(-3,-3,10));
+#332=DIRECTION($,(1,0,0));
+#333=VECTOR($,#332,1);
+#334=LINE($,#331,#333);
+#335=EDGE_CURVE($,#308,#324,#334,.T.);
+#336=ORIENTED_EDGE($,$,$,#335,.F.);
+#337=EDGE_LOOP($,(#314,#322,#330,#336));
+#338=FACE_OUTER_BOUND('',#337,.T.);
+#339=ADVANCED_FACE('',(#338),#304,.T.);
+#340=CARTESIAN_POINT($,(-4,-4,0));
+#341=DIRECTION($,(0,-1,0));
+#342=DIRECTION($,(1,0,0));
+#343=AXIS2_PLACEMENT_3D($,#340,#341,#342);
+#344=PLANE($,#343);
+#345=ORIENTED_EDGE($,$,$,#273,.T.);
+#346=CARTESIAN_POINT($,(4,-4,9));
+#347=VERTEX_POINT($,#346);
+#348=CARTESIAN_POINT($,(4,-4,-0));
+#349=DIRECTION($,(0,0,1));
+#350=VECTOR($,#349,1);
+#351=LINE($,#348,#350);
+#352=EDGE_CURVE($,#268,#347,#351,.T.);
+#353=ORIENTED_EDGE($,$,$,#352,.T.);
+#354=CARTESIAN_POINT($,(-4,-4,9));
+#355=VERTEX_POINT($,#354);
+#356=CARTESIAN_POINT($,(-4,-4,9));
+#357=DIRECTION($,(1,0,0));
+#358=VECTOR($,#357,1);
+#359=LINE($,#356,#358);
+#360=EDGE_CURVE($,#355,#347,#359,.T.);
+#361=ORIENTED_EDGE($,$,$,#360,.F.);
+#362=CARTESIAN_POINT($,(-4,-4,-0));
+#363=DIRECTION($,(0,0,1));
+#364=VECTOR($,#363,1);
+#365=LINE($,#362,#364);
+#366=EDGE_CURVE($,#266,#355,#365,.T.);
+#367=ORIENTED_EDGE($,$,$,#366,.F.);
+#368=EDGE_LOOP($,(#345,#353,#361,#367));
+#369=FACE_OUTER_BOUND('',#368,.T.);
+#370=ADVANCED_FACE('',(#369),#344,.T.);
+#371=CARTESIAN_POINT($,(4,-4,0));
+#372=DIRECTION($,(1,0,0));
+#373=DIRECTION($,(0,1,0));
+#374=AXIS2_PLACEMENT_3D($,#371,#372,#373);
+#375=PLANE($,#374);
+#376=ORIENTED_EDGE($,$,$,#281,.T.);
+#377=CARTESIAN_POINT($,(4,4,9));
+#378=VERTEX_POINT($,#377);
+#379=CARTESIAN_POINT($,(4,4,-0));
+#380=DIRECTION($,(0,0,1));
+#381=VECTOR($,#380,1);
+#382=LINE($,#379,#381);
+#383=EDGE_CURVE($,#276,#378,#382,.T.);
+#384=ORIENTED_EDGE($,$,$,#383,.T.);
+#385=CARTESIAN_POINT($,(4,-4,9));
+#386=DIRECTION($,(0,1,0));
+#387=VECTOR($,#386,1);
+#388=LINE($,#385,#387);
+#389=EDGE_CURVE($,#347,#378,#388,.T.);
+#390=ORIENTED_EDGE($,$,$,#389,.F.);
+#391=ORIENTED_EDGE($,$,$,#352,.F.);
+#392=EDGE_LOOP($,(#376,#384,#390,#391));
+#393=FACE_OUTER_BOUND('',#392,.T.);
+#394=ADVANCED_FACE('',(#393),#375,.T.);
+#395=CARTESIAN_POINT($,(4,4,0));
+#396=DIRECTION($,(0,1,-0));
+#397=DIRECTION($,(-1,0,0));
+#398=AXIS2_PLACEMENT_3D($,#395,#396,#397);
+#399=PLANE($,#398);
+#400=ORIENTED_EDGE($,$,$,#289,.T.);
+#401=CARTESIAN_POINT($,(-4,4,9));
+#402=VERTEX_POINT($,#401);
+#403=CARTESIAN_POINT($,(-4,4,-0));
+#404=DIRECTION($,(0,0,1));
+#405=VECTOR($,#404,1);
+#406=LINE($,#403,#405);
+#407=EDGE_CURVE($,#284,#402,#406,.T.);
+#408=ORIENTED_EDGE($,$,$,#407,.T.);
+#409=CARTESIAN_POINT($,(4,4,9));
+#410=DIRECTION($,(-1,0,0));
+#411=VECTOR($,#410,1);
+#412=LINE($,#409,#411);
+#413=EDGE_CURVE($,#378,#402,#412,.T.);
+#414=ORIENTED_EDGE($,$,$,#413,.F.);
+#415=ORIENTED_EDGE($,$,$,#383,.F.);
+#416=EDGE_LOOP($,(#400,#408,#414,#415));
+#417=FACE_OUTER_BOUND('',#416,.T.);
+#418=ADVANCED_FACE('',(#417),#399,.T.);
+#419=CARTESIAN_POINT($,(-4,4,0));
+#420=DIRECTION($,(-1,0,0));
+#421=DIRECTION($,(0,-1,0));
+#422=AXIS2_PLACEMENT_3D($,#419,#420,#421);
+#423=PLANE($,#422);
+#424=ORIENTED_EDGE($,$,$,#295,.T.);
+#425=ORIENTED_EDGE($,$,$,#366,.T.);
+#426=CARTESIAN_POINT($,(-4,4,9));
+#427=DIRECTION($,(0,-1,0));
+#428=VECTOR($,#427,1);
+#429=LINE($,#426,#428);
+#430=EDGE_CURVE($,#402,#355,#429,.T.);
+#431=ORIENTED_EDGE($,$,$,#430,.F.);
+#432=ORIENTED_EDGE($,$,$,#407,.F.);
+#433=EDGE_LOOP($,(#424,#425,#431,#432));
+#434=FACE_OUTER_BOUND('',#433,.T.);
+#435=ADVANCED_FACE('',(#434),#423,.T.);
+#436=CARTESIAN_POINT($,(-4,-4,9));
+#437=DIRECTION($,(0,-0.707106781186548,0.707106781186548));
+#438=DIRECTION($,(1,0,0));
+#439=AXIS2_PLACEMENT_3D($,#436,#437,#438);
+#440=PLANE($,#439);
+#441=ORIENTED_EDGE($,$,$,#360,.T.);
+#442=CARTESIAN_POINT($,(4,-4,9));
+#443=DIRECTION($,(-0.577350269189626,0.577350269189626,0.577350269189626));
+#444=VECTOR($,#443,1);
+#445=LINE($,#442,#444);
+#446=EDGE_CURVE($,#347,#324,#445,.T.);
+#447=ORIENTED_EDGE($,$,$,#446,.T.);
+#448=ORIENTED_EDGE($,$,$,#335,.F.);
+#449=CARTESIAN_POINT($,(-4,-4,9));
+#450=DIRECTION($,(0.577350269189626,0.577350269189626,0.577350269189626));
+#451=VECTOR($,#450,1);
+#452=LINE($,#449,#451);
+#453=EDGE_CURVE($,#355,#308,#452,.T.);
+#454=ORIENTED_EDGE($,$,$,#453,.F.);
+#455=EDGE_LOOP($,(#441,#447,#448,#454));
+#456=FACE_OUTER_BOUND('',#455,.T.);
+#457=ADVANCED_FACE('',(#456),#440,.T.);
+#458=CARTESIAN_POINT($,(4,-4,9));
+#459=DIRECTION($,(0.707106781186548,-0,0.707106781186548));
+#460=DIRECTION($,(0,1,0));
+#461=AXIS2_PLACEMENT_3D($,#458,#459,#460);
+#462=PLANE($,#461);
+#463=ORIENTED_EDGE($,$,$,#389,.T.);
+#464=CARTESIAN_POINT($,(4,4,9));
+#465=DIRECTION($,(-0.577350269189626,-0.577350269189626,0.577350269189626));
+#466=VECTOR($,#465,1);
+#467=LINE($,#464,#466);
+#468=EDGE_CURVE($,#378,#316,#467,.T.);
+#469=ORIENTED_EDGE($,$,$,#468,.T.);
+#470=ORIENTED_EDGE($,$,$,#329,.F.);
+#471=ORIENTED_EDGE($,$,$,#446,.F.);
+#472=EDGE_LOOP($,(#463,#469,#470,#471));
+#473=FACE_OUTER_BOUND('',#472,.T.);
+#474=ADVANCED_FACE('',(#473),#462,.T.);
+#475=CARTESIAN_POINT($,(4,4,9));
+#476=DIRECTION($,(0,0.707106781186548,0.707106781186548));
+#477=DIRECTION($,(-1,0,0));
+#478=AXIS2_PLACEMENT_3D($,#475,#476,#477);
+#479=PLANE($,#478);
+#480=ORIENTED_EDGE($,$,$,#413,.T.);
+#481=CARTESIAN_POINT($,(-4,4,9));
+#482=DIRECTION($,(0.577350269189626,-0.577350269189626,0.577350269189626));
+#483=VECTOR($,#482,1);
+#484=LINE($,#481,#483);
+#485=EDGE_CURVE($,#402,#306,#484,.T.);
+#486=ORIENTED_EDGE($,$,$,#485,.T.);
+#487=ORIENTED_EDGE($,$,$,#321,.F.);
+#488=ORIENTED_EDGE($,$,$,#468,.F.);
+#489=EDGE_LOOP($,(#480,#486,#487,#488));
+#490=FACE_OUTER_BOUND('',#489,.T.);
+#491=ADVANCED_FACE('',(#490),#479,.T.);
+#492=CARTESIAN_POINT($,(-4,4,9));
+#493=DIRECTION($,(-0.707106781186548,0,0.707106781186548));
+#494=DIRECTION($,(0,-1,0));
+#495=AXIS2_PLACEMENT_3D($,#492,#493,#494);
+#496=PLANE($,#495);
+#497=ORIENTED_EDGE($,$,$,#430,.T.);
+#498=ORIENTED_EDGE($,$,$,#453,.T.);
+#499=ORIENTED_EDGE($,$,$,#313,.F.);
+#500=ORIENTED_EDGE($,$,$,#485,.F.);
+#501=EDGE_LOOP($,(#497,#498,#499,#500));
+#502=FACE_OUTER_BOUND('',#501,.T.);
+#503=ADVANCED_FACE('',(#502),#496,.T.);
+#504=CLOSED_SHELL($,(#299,#339,#370,#394,#418,#435,#457,#474,#491,#503));
+#505=MANIFOLD_SOLID_BREP('AssemblyBlock<Spec: ShaftSpec>',#504);
+#506=APPLICATION_CONTEXT('mechanical design');
+#507=PRODUCT_CONTEXT('',#506,'mechanical');
+#508=PRODUCT('assembly-definition:589802EEFAB8DBFE','AssemblyBlock<Spec: ShaftSpec>','Aetheris shared assembly definition',(#507));
+#509=PRODUCT_DEFINITION_FORMATION('','',#508);
+#510=PRODUCT_DEFINITION_CONTEXT('design',#506,'design');
+#511=PRODUCT_DEFINITION('','',#509,#510);
+#512=PRODUCT_DEFINITION_SHAPE('','',#511);
+#513=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#514=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#515=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#516=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#513,#514,#515))REPRESENTATION_CONTEXT('3','3D'));
+#517=SHAPE_REPRESENTATION('AssemblyBlock<Spec: ShaftSpec>',(#505),#516);
+#518=SHAPE_DEFINITION_REPRESENTATION(#512,#517);
+#519=CARTESIAN_POINT($,(0,0,0));
+#520=DIRECTION($,(0,0,-1));
+#521=DIRECTION($,(1,0,0));
+#522=AXIS2_PLACEMENT_3D($,#519,#520,#521);
+#523=PLANE($,#522);
+#524=CARTESIAN_POINT($,(-3,-3,-0));
+#525=VERTEX_POINT($,#524);
+#526=CARTESIAN_POINT($,(3,-3,-0));
+#527=VERTEX_POINT($,#526);
+#528=CARTESIAN_POINT($,(-3,-3,-0));
+#529=DIRECTION($,(1,0,0));
+#530=VECTOR($,#529,1);
+#531=LINE($,#528,#530);
+#532=EDGE_CURVE($,#525,#527,#531,.T.);
+#533=ORIENTED_EDGE($,$,$,#532,.T.);
+#534=CARTESIAN_POINT($,(3,3,-0));
+#535=VERTEX_POINT($,#534);
+#536=CARTESIAN_POINT($,(3,-3,-0));
+#537=DIRECTION($,(0,1,0));
+#538=VECTOR($,#537,1);
+#539=LINE($,#536,#538);
+#540=EDGE_CURVE($,#527,#535,#539,.T.);
+#541=ORIENTED_EDGE($,$,$,#540,.T.);
+#542=CARTESIAN_POINT($,(-3,3,-0));
+#543=VERTEX_POINT($,#542);
+#544=CARTESIAN_POINT($,(3,3,-0));
+#545=DIRECTION($,(-1,0,0));
+#546=VECTOR($,#545,1);
+#547=LINE($,#544,#546);
+#548=EDGE_CURVE($,#535,#543,#547,.T.);
+#549=ORIENTED_EDGE($,$,$,#548,.T.);
+#550=CARTESIAN_POINT($,(-3,3,-0));
+#551=DIRECTION($,(0,-1,0));
+#552=VECTOR($,#551,1);
+#553=LINE($,#550,#552);
+#554=EDGE_CURVE($,#543,#525,#553,.T.);
+#555=ORIENTED_EDGE($,$,$,#554,.T.);
+#556=EDGE_LOOP($,(#533,#541,#549,#555));
+#557=FACE_OUTER_BOUND('',#556,.T.);
+#558=ADVANCED_FACE('',(#557),#523,.T.);
+#559=CARTESIAN_POINT($,(0,0,5));
+#560=DIRECTION($,(0,0,1));
+#561=DIRECTION($,(1,0,0));
+#562=AXIS2_PLACEMENT_3D($,#559,#560,#561);
+#563=PLANE($,#562);
+#564=CARTESIAN_POINT($,(-2,2,5));
+#565=VERTEX_POINT($,#564);
+#566=CARTESIAN_POINT($,(-2,-2,5));
+#567=VERTEX_POINT($,#566);
+#568=CARTESIAN_POINT($,(-2,2,5));
+#569=DIRECTION($,(0,-1,0));
+#570=VECTOR($,#569,1);
+#571=LINE($,#568,#570);
+#572=EDGE_CURVE($,#565,#567,#571,.T.);
+#573=ORIENTED_EDGE($,$,$,#572,.F.);
+#574=CARTESIAN_POINT($,(2,2,5));
+#575=VERTEX_POINT($,#574);
+#576=CARTESIAN_POINT($,(2,2,5));
+#577=DIRECTION($,(-1,0,0));
+#578=VECTOR($,#577,1);
+#579=LINE($,#576,#578);
+#580=EDGE_CURVE($,#575,#565,#579,.T.);
+#581=ORIENTED_EDGE($,$,$,#580,.F.);
+#582=CARTESIAN_POINT($,(2,-2,5));
+#583=VERTEX_POINT($,#582);
+#584=CARTESIAN_POINT($,(2,-2,5));
+#585=DIRECTION($,(0,1,0));
+#586=VECTOR($,#585,1);
+#587=LINE($,#584,#586);
+#588=EDGE_CURVE($,#583,#575,#587,.T.);
+#589=ORIENTED_EDGE($,$,$,#588,.F.);
+#590=CARTESIAN_POINT($,(-2,-2,5));
+#591=DIRECTION($,(1,0,0));
+#592=VECTOR($,#591,1);
+#593=LINE($,#590,#592);
+#594=EDGE_CURVE($,#567,#583,#593,.T.);
+#595=ORIENTED_EDGE($,$,$,#594,.F.);
+#596=EDGE_LOOP($,(#573,#581,#589,#595));
+#597=FACE_OUTER_BOUND('',#596,.T.);
+#598=ADVANCED_FACE('',(#597),#563,.T.);
+#599=CARTESIAN_POINT($,(-3,-3,0));
+#600=DIRECTION($,(0,-1,0));
+#601=DIRECTION($,(1,0,0));
+#602=AXIS2_PLACEMENT_3D($,#599,#600,#601);
+#603=PLANE($,#602);
+#604=ORIENTED_EDGE($,$,$,#532,.T.);
+#605=CARTESIAN_POINT($,(3,-3,4));
+#606=VERTEX_POINT($,#605);
+#607=CARTESIAN_POINT($,(3,-3,-0));
+#608=DIRECTION($,(0,0,1));
+#609=VECTOR($,#608,1);
+#610=LINE($,#607,#609);
+#611=EDGE_CURVE($,#527,#606,#610,.T.);
+#612=ORIENTED_EDGE($,$,$,#611,.T.);
+#613=CARTESIAN_POINT($,(-3,-3,4));
+#614=VERTEX_POINT($,#613);
+#615=CARTESIAN_POINT($,(-3,-3,4));
+#616=DIRECTION($,(1,0,0));
+#617=VECTOR($,#616,1);
+#618=LINE($,#615,#617);
+#619=EDGE_CURVE($,#614,#606,#618,.T.);
+#620=ORIENTED_EDGE($,$,$,#619,.F.);
+#621=CARTESIAN_POINT($,(-3,-3,-0));
+#622=DIRECTION($,(0,0,1));
+#623=VECTOR($,#622,1);
+#624=LINE($,#621,#623);
+#625=EDGE_CURVE($,#525,#614,#624,.T.);
+#626=ORIENTED_EDGE($,$,$,#625,.F.);
+#627=EDGE_LOOP($,(#604,#612,#620,#626));
+#628=FACE_OUTER_BOUND('',#627,.T.);
+#629=ADVANCED_FACE('',(#628),#603,.T.);
+#630=CARTESIAN_POINT($,(3,-3,0));
+#631=DIRECTION($,(1,0,0));
+#632=DIRECTION($,(0,1,0));
+#633=AXIS2_PLACEMENT_3D($,#630,#631,#632);
+#634=PLANE($,#633);
+#635=ORIENTED_EDGE($,$,$,#540,.T.);
+#636=CARTESIAN_POINT($,(3,3,4));
+#637=VERTEX_POINT($,#636);
+#638=CARTESIAN_POINT($,(3,3,-0));
+#639=DIRECTION($,(0,0,1));
+#640=VECTOR($,#639,1);
+#641=LINE($,#638,#640);
+#642=EDGE_CURVE($,#535,#637,#641,.T.);
+#643=ORIENTED_EDGE($,$,$,#642,.T.);
+#644=CARTESIAN_POINT($,(3,-3,4));
+#645=DIRECTION($,(0,1,0));
+#646=VECTOR($,#645,1);
+#647=LINE($,#644,#646);
+#648=EDGE_CURVE($,#606,#637,#647,.T.);
+#649=ORIENTED_EDGE($,$,$,#648,.F.);
+#650=ORIENTED_EDGE($,$,$,#611,.F.);
+#651=EDGE_LOOP($,(#635,#643,#649,#650));
+#652=FACE_OUTER_BOUND('',#651,.T.);
+#653=ADVANCED_FACE('',(#652),#634,.T.);
+#654=CARTESIAN_POINT($,(3,3,0));
+#655=DIRECTION($,(0,1,-0));
+#656=DIRECTION($,(-1,0,0));
+#657=AXIS2_PLACEMENT_3D($,#654,#655,#656);
+#658=PLANE($,#657);
+#659=ORIENTED_EDGE($,$,$,#548,.T.);
+#660=CARTESIAN_POINT($,(-3,3,4));
+#661=VERTEX_POINT($,#660);
+#662=CARTESIAN_POINT($,(-3,3,-0));
+#663=DIRECTION($,(0,0,1));
+#664=VECTOR($,#663,1);
+#665=LINE($,#662,#664);
+#666=EDGE_CURVE($,#543,#661,#665,.T.);
+#667=ORIENTED_EDGE($,$,$,#666,.T.);
+#668=CARTESIAN_POINT($,(3,3,4));
+#669=DIRECTION($,(-1,0,0));
+#670=VECTOR($,#669,1);
+#671=LINE($,#668,#670);
+#672=EDGE_CURVE($,#637,#661,#671,.T.);
+#673=ORIENTED_EDGE($,$,$,#672,.F.);
+#674=ORIENTED_EDGE($,$,$,#642,.F.);
+#675=EDGE_LOOP($,(#659,#667,#673,#674));
+#676=FACE_OUTER_BOUND('',#675,.T.);
+#677=ADVANCED_FACE('',(#676),#658,.T.);
+#678=CARTESIAN_POINT($,(-3,3,0));
+#679=DIRECTION($,(-1,0,0));
+#680=DIRECTION($,(0,-1,0));
+#681=AXIS2_PLACEMENT_3D($,#678,#679,#680);
+#682=PLANE($,#681);
+#683=ORIENTED_EDGE($,$,$,#554,.T.);
+#684=ORIENTED_EDGE($,$,$,#625,.T.);
+#685=CARTESIAN_POINT($,(-3,3,4));
+#686=DIRECTION($,(0,-1,0));
+#687=VECTOR($,#686,1);
+#688=LINE($,#685,#687);
+#689=EDGE_CURVE($,#661,#614,#688,.T.);
+#690=ORIENTED_EDGE($,$,$,#689,.F.);
+#691=ORIENTED_EDGE($,$,$,#666,.F.);
+#692=EDGE_LOOP($,(#683,#684,#690,#691));
+#693=FACE_OUTER_BOUND('',#692,.T.);
+#694=ADVANCED_FACE('',(#693),#682,.T.);
+#695=CARTESIAN_POINT($,(-3,-3,4));
+#696=DIRECTION($,(0,-0.707106781186548,0.707106781186548));
+#697=DIRECTION($,(1,0,0));
+#698=AXIS2_PLACEMENT_3D($,#695,#696,#697);
+#699=PLANE($,#698);
+#700=ORIENTED_EDGE($,$,$,#619,.T.);
+#701=CARTESIAN_POINT($,(3,-3,4));
+#702=DIRECTION($,(-0.577350269189626,0.577350269189626,0.577350269189626));
+#703=VECTOR($,#702,1);
+#704=LINE($,#701,#703);
+#705=EDGE_CURVE($,#606,#583,#704,.T.);
+#706=ORIENTED_EDGE($,$,$,#705,.T.);
+#707=ORIENTED_EDGE($,$,$,#594,.F.);
+#708=CARTESIAN_POINT($,(-3,-3,4));
+#709=DIRECTION($,(0.577350269189626,0.577350269189626,0.577350269189626));
+#710=VECTOR($,#709,1);
+#711=LINE($,#708,#710);
+#712=EDGE_CURVE($,#614,#567,#711,.T.);
+#713=ORIENTED_EDGE($,$,$,#712,.F.);
+#714=EDGE_LOOP($,(#700,#706,#707,#713));
+#715=FACE_OUTER_BOUND('',#714,.T.);
+#716=ADVANCED_FACE('',(#715),#699,.T.);
+#717=CARTESIAN_POINT($,(3,-3,4));
+#718=DIRECTION($,(0.707106781186548,-0,0.707106781186548));
+#719=DIRECTION($,(0,1,0));
+#720=AXIS2_PLACEMENT_3D($,#717,#718,#719);
+#721=PLANE($,#720);
+#722=ORIENTED_EDGE($,$,$,#648,.T.);
+#723=CARTESIAN_POINT($,(3,3,4));
+#724=DIRECTION($,(-0.577350269189626,-0.577350269189626,0.577350269189626));
+#725=VECTOR($,#724,1);
+#726=LINE($,#723,#725);
+#727=EDGE_CURVE($,#637,#575,#726,.T.);
+#728=ORIENTED_EDGE($,$,$,#727,.T.);
+#729=ORIENTED_EDGE($,$,$,#588,.F.);
+#730=ORIENTED_EDGE($,$,$,#705,.F.);
+#731=EDGE_LOOP($,(#722,#728,#729,#730));
+#732=FACE_OUTER_BOUND('',#731,.T.);
+#733=ADVANCED_FACE('',(#732),#721,.T.);
+#734=CARTESIAN_POINT($,(3,3,4));
+#735=DIRECTION($,(0,0.707106781186548,0.707106781186548));
+#736=DIRECTION($,(-1,0,0));
+#737=AXIS2_PLACEMENT_3D($,#734,#735,#736);
+#738=PLANE($,#737);
+#739=ORIENTED_EDGE($,$,$,#672,.T.);
+#740=CARTESIAN_POINT($,(-3,3,4));
+#741=DIRECTION($,(0.577350269189626,-0.577350269189626,0.577350269189626));
+#742=VECTOR($,#741,1);
+#743=LINE($,#740,#742);
+#744=EDGE_CURVE($,#661,#565,#743,.T.);
+#745=ORIENTED_EDGE($,$,$,#744,.T.);
+#746=ORIENTED_EDGE($,$,$,#580,.F.);
+#747=ORIENTED_EDGE($,$,$,#727,.F.);
+#748=EDGE_LOOP($,(#739,#745,#746,#747));
+#749=FACE_OUTER_BOUND('',#748,.T.);
+#750=ADVANCED_FACE('',(#749),#738,.T.);
+#751=CARTESIAN_POINT($,(-3,3,4));
+#752=DIRECTION($,(-0.707106781186548,0,0.707106781186548));
+#753=DIRECTION($,(0,-1,0));
+#754=AXIS2_PLACEMENT_3D($,#751,#752,#753);
+#755=PLANE($,#754);
+#756=ORIENTED_EDGE($,$,$,#689,.T.);
+#757=ORIENTED_EDGE($,$,$,#712,.T.);
+#758=ORIENTED_EDGE($,$,$,#572,.F.);
+#759=ORIENTED_EDGE($,$,$,#744,.F.);
+#760=EDGE_LOOP($,(#756,#757,#758,#759));
+#761=FACE_OUTER_BOUND('',#760,.T.);
+#762=ADVANCED_FACE('',(#761),#755,.T.);
+#763=CLOSED_SHELL($,(#558,#598,#629,#653,#677,#694,#716,#733,#750,#762));
+#764=MANIFOLD_SOLID_BREP('AssemblyBlock<Spec: SpacerSpec>',#763);
+#765=APPLICATION_CONTEXT('mechanical design');
+#766=PRODUCT_CONTEXT('',#765,'mechanical');
+#767=PRODUCT('assembly-definition:FE4D3B5CEA66AF52','AssemblyBlock<Spec: SpacerSpec>','Aetheris shared assembly definition',(#766));
+#768=PRODUCT_DEFINITION_FORMATION('','',#767);
+#769=PRODUCT_DEFINITION_CONTEXT('design',#765,'design');
+#770=PRODUCT_DEFINITION('','',#768,#769);
+#771=PRODUCT_DEFINITION_SHAPE('','',#770);
+#772=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#773=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#774=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#775=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#772,#773,#774))REPRESENTATION_CONTEXT('3','3D'));
+#776=SHAPE_REPRESENTATION('AssemblyBlock<Spec: SpacerSpec>',(#764),#775);
+#777=SHAPE_DEFINITION_REPRESENTATION(#771,#776);
+#778=APPLICATION_CONTEXT('mechanical design');
+#779=PRODUCT_CONTEXT('',#778,'mechanical');
+#780=PRODUCT_DEFINITION_CONTEXT('design',#778,'design');
+#781=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#782=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#783=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#784=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#781,#782,#783))REPRESENTATION_CONTEXT('3','3D'));
+#785=PRODUCT('assembly-definition:232D83A6D04B59D4','BearingModule<Spec:StandardModuleSpec>','Aetheris reusable assembly definition',(#779));
+#786=PRODUCT_DEFINITION_FORMATION('','',#785);
+#787=PRODUCT_DEFINITION('assembly-definition:232D83A6D04B59D4','',#786,#780);
+#788=PRODUCT_DEFINITION_SHAPE('','',#787);
+#789=SHAPE_REPRESENTATION('BearingModule<Spec:StandardModuleSpec>',(),#784);
+#790=SHAPE_DEFINITION_REPRESENTATION(#788,#789);
+#791=PRODUCT('assembly-instance:Machine','Machine','Aetheris assembly product',(#779));
+#792=PRODUCT_DEFINITION_FORMATION('','',#791);
+#793=PRODUCT_DEFINITION('assembly-instance:Machine','',#792,#780);
+#794=PRODUCT_DEFINITION_SHAPE('','',#793);
+#795=SHAPE_REPRESENTATION('Machine',(),#784);
+#796=SHAPE_DEFINITION_REPRESENTATION(#794,#795);
+#797=CARTESIAN_POINT('',(0.,0.,0.));
+#798=AXIS2_PLACEMENT_3D('',#797,$,$);
+#799=NEXT_ASSEMBLY_USAGE_OCCURRENCE('assembly-instance:Machine.Frame','Frame','',#793,#252,$);
+#800=PRODUCT_DEFINITION_SHAPE('','',#799);
+#801=CARTESIAN_POINT('',(0,0,0));
+#802=DIRECTION('',(0,0,1));
+#803=DIRECTION('',(1,0,0));
+#804=AXIS2_PLACEMENT_3D('',#801,#802,#803);
+#805=ITEM_DEFINED_TRANSFORMATION('assembly-instance:Machine.Frame','Aetheris rigid occurrence transform',#798,#804);
+#806=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('assembly-instance:Machine.Frame','',#795,#258,#805);
+#807=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#806,#800);
+#808=NEXT_ASSEMBLY_USAGE_OCCURRENCE('assembly-instance:Machine.LeftModule','LeftModule','',#793,#787,$);
+#809=PRODUCT_DEFINITION_SHAPE('','',#808);
+#810=CARTESIAN_POINT('',(-30,0,0));
+#811=DIRECTION('',(0,0,1));
+#812=DIRECTION('',(1,0,0));
+#813=AXIS2_PLACEMENT_3D('',#810,#811,#812);
+#814=ITEM_DEFINED_TRANSFORMATION('assembly-instance:Machine.LeftModule','Aetheris rigid occurrence transform',#798,#813);
+#815=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('assembly-instance:Machine.LeftModule','',#795,#789,#814);
+#816=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#815,#809);
+#817=NEXT_ASSEMBLY_USAGE_OCCURRENCE('definition-usage:assembly-definition:232D83A6D04B59D4|Bearing|assembly-definition:FE4D3B5CEA66AF52|1,0,0,0,0,1,0,0,0,0,1,0,0,30,0,1','Bearing','',#787,#770,$);
+#818=PRODUCT_DEFINITION_SHAPE('','',#817);
+#819=CARTESIAN_POINT('',(0,30,0));
+#820=DIRECTION('',(0,0,1));
+#821=DIRECTION('',(1,0,0));
+#822=AXIS2_PLACEMENT_3D('',#819,#820,#821);
+#823=ITEM_DEFINED_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Bearing|assembly-definition:FE4D3B5CEA66AF52|1,0,0,0,0,1,0,0,0,0,1,0,0,30,0,1','Aetheris rigid occurrence transform',#798,#822);
+#824=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Bearing|assembly-definition:FE4D3B5CEA66AF52|1,0,0,0,0,1,0,0,0,0,1,0,0,30,0,1','',#789,#776,#823);
+#825=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#824,#818);
+#826=NEXT_ASSEMBLY_USAGE_OCCURRENCE('definition-usage:assembly-definition:232D83A6D04B59D4|Housing|assembly-definition:2D6E0B6EEEAE5CE1|1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1','Housing','',#787,#252,$);
+#827=PRODUCT_DEFINITION_SHAPE('','',#826);
+#828=CARTESIAN_POINT('',(0,0,0));
+#829=DIRECTION('',(0,0,1));
+#830=DIRECTION('',(1,0,0));
+#831=AXIS2_PLACEMENT_3D('',#828,#829,#830);
+#832=ITEM_DEFINED_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Housing|assembly-definition:2D6E0B6EEEAE5CE1|1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1','Aetheris rigid occurrence transform',#798,#831);
+#833=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Housing|assembly-definition:2D6E0B6EEEAE5CE1|1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1','',#789,#258,#832);
+#834=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#833,#827);
+#835=NEXT_ASSEMBLY_USAGE_OCCURRENCE('definition-usage:assembly-definition:232D83A6D04B59D4|Shaft|assembly-definition:589802EEFAB8DBFE|1,0,0,0,0,1,0,0,0,0,1,0,0,0,10,1','Shaft','',#787,#511,$);
+#836=PRODUCT_DEFINITION_SHAPE('','',#835);
+#837=CARTESIAN_POINT('',(0,0,10));
+#838=DIRECTION('',(0,0,1));
+#839=DIRECTION('',(1,0,0));
+#840=AXIS2_PLACEMENT_3D('',#837,#838,#839);
+#841=ITEM_DEFINED_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Shaft|assembly-definition:589802EEFAB8DBFE|1,0,0,0,0,1,0,0,0,0,1,0,0,0,10,1','Aetheris rigid occurrence transform',#798,#840);
+#842=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Shaft|assembly-definition:589802EEFAB8DBFE|1,0,0,0,0,1,0,0,0,0,1,0,0,0,10,1','',#789,#517,#841);
+#843=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#842,#836);
+#844=NEXT_ASSEMBLY_USAGE_OCCURRENCE('definition-usage:assembly-definition:232D83A6D04B59D4|Spacer|assembly-definition:FE4D3B5CEA66AF52|1,0,0,0,0,1,0,0,0,0,1,0,0,50,0,1','Spacer','',#787,#770,$);
+#845=PRODUCT_DEFINITION_SHAPE('','',#844);
+#846=CARTESIAN_POINT('',(0,50,0));
+#847=DIRECTION('',(0,0,1));
+#848=DIRECTION('',(1,0,0));
+#849=AXIS2_PLACEMENT_3D('',#846,#847,#848);
+#850=ITEM_DEFINED_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Spacer|assembly-definition:FE4D3B5CEA66AF52|1,0,0,0,0,1,0,0,0,0,1,0,0,50,0,1','Aetheris rigid occurrence transform',#798,#849);
+#851=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('definition-usage:assembly-definition:232D83A6D04B59D4|Spacer|assembly-definition:FE4D3B5CEA66AF52|1,0,0,0,0,1,0,0,0,0,1,0,0,50,0,1','',#789,#776,#850);
+#852=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#851,#845);
+#853=NEXT_ASSEMBLY_USAGE_OCCURRENCE('assembly-instance:Machine.RightModule','RightModule','',#793,#787,$);
+#854=PRODUCT_DEFINITION_SHAPE('','',#853);
+#855=CARTESIAN_POINT('',(30,0,0));
+#856=DIRECTION('',(0,0,1));
+#857=DIRECTION('',(1,0,0));
+#858=AXIS2_PLACEMENT_3D('',#855,#856,#857);
+#859=ITEM_DEFINED_TRANSFORMATION('assembly-instance:Machine.RightModule','Aetheris rigid occurrence transform',#798,#858);
+#860=REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION('assembly-instance:Machine.RightModule','',#795,#789,#859);
+#861=CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(#860,#854);
+ENDSEC;
+END-ISO-10303-21;
diff --git a/docs/assembly/artifacts/m3/cadmata-display.md b/docs/assembly/artifacts/m3/cadmata-display.md
new file mode 100644
index 00000000..32f496fc
--- /dev/null
+++ b/docs/assembly/artifacts/m3/cadmata-display.md
@@ -0,0 +1,17 @@
+# Cadmata nested display evidence
+
+Display schema: `aetheris/cadmata-assembly-display/m3`.
+
+- product occurrences: 12 including Machine root
+- module definitions: 1
+- `LeftModule` selection members: LeftModule plus its four children
+- `RightModule` is absent from the LeftModule selection group
+- child selection members: the selected child only
+- public inspector lists definition, Template specialization, provenance,
+ exposed names, capabilities, binding kinds, and internal alias provenance
+- parent Mate primary endpoint: `Machine.LeftModule.Mount`
+- parent tolerance details: three expanded internal contributors
+
+Geometry definitions remain shared. The viewport derives highlighting from the
+selected occurrence's bounded selection group, preventing reuse-related
+selection leakage.
diff --git a/docs/assembly/artifacts/m3/determinism-and-performance.md b/docs/assembly/artifacts/m3/determinism-and-performance.md
new file mode 100644
index 00000000..87cbdfa9
--- /dev/null
+++ b/docs/assembly/artifacts/m3/determinism-and-performance.md
@@ -0,0 +1,17 @@
+# Determinism and performance
+
+Two complete compilations preserve:
+
+- AssemblyDefinition ID `assembly-definition:232D83A6D04B59D4`
+- specialization identity `BearingModule<Spec:StandardModuleSpec>`
+- deterministic geometry hash
+ `090EC5DD2BA098CE3AAF4138260A03E3EC988F5B9FAFED7F71DDA60C90834E26`
+- local/world transforms
+- public relation interval and three expanded contributors
+- AP242 hierarchy and shared definition references
+
+The evidence run measured the single local solve at approximately 29 ms. Both
+occurrences reuse that artifact; occurrence work is transform composition.
+Cadmata publishes `packetMilliseconds`, definition/module counts, and occurrence
+count in its performance map. The exact timing is environment telemetry and is
+not included in deterministic hashes.
diff --git a/docs/assembly/artifacts/m3/hierarchical-tolerance.md b/docs/assembly/artifacts/m3/hierarchical-tolerance.md
new file mode 100644
index 00000000..8f34fe75
--- /dev/null
+++ b/docs/assembly/artifacts/m3/hierarchical-tolerance.md
@@ -0,0 +1,21 @@
+# Hierarchical tolerance proof
+
+Public edge `MountToDriveOffset`:
+
+- nominal: 45.00 mm
+- interval: 44.92–45.10 mm
+- definition: `BearingModule<Spec:StandardModuleSpec>`
+
+Structured expansion:
+
+| contributor | nominal | lower | upper |
+| --- | ---: | ---: | ---: |
+| Housing seat | 10 | -0.01 | +0.02 |
+| Bearing width / BlockStandards | 20 | -0.03 | +0.03 |
+| Spacer width / StandardModuleSpec with | 15 | -0.04 | +0.05 |
+
+Parent assertion `MachineOffset` traverses `FrameToLeft` and the one public
+module edge. Its required minimum is 44.90 mm; worst-case minimum is 44.92 mm,
+so the assertion passes. The public edge retains `static-table`,
+`static-record`, `static-with`, Template specialization, occurrence, and signed
+internal-relation evidence.
diff --git a/docs/assembly/artifacts/m3/local-solve-and-reuse.md b/docs/assembly/artifacts/m3/local-solve-and-reuse.md
new file mode 100644
index 00000000..8ff95353
--- /dev/null
+++ b/docs/assembly/artifacts/m3/local-solve-and-reuse.md
@@ -0,0 +1,17 @@
+# Local solve and definition reuse
+
+Canonical source: `fixtures/AssemblyM3/bearing-module.firmament`.
+
+- specialization: `BearingModule<Spec:StandardModuleSpec>`
+- AssemblyDefinition ID: `assembly-definition:232D83A6D04B59D4`
+- local product occurrences: definition root plus Housing, Bearing, Spacer, Shaft
+- local Mate: `ShaftSeat`, valid
+- local assertion: `InternalOffset`, pass
+- definition local solve: approximately 29 ms on the evidence run
+- parent occurrences: `Machine.LeftModule`, `Machine.RightModule`
+- compiled AssemblyDefinition count: 1
+- occurrence count for that definition: 2
+
+The specialization cache is keyed by normalized Template application. The
+second occurrence clones the solved local tree and public surface; it does not
+invoke the local compiler again.
diff --git a/docs/assembly/artifacts/m3/local-world-transforms.md b/docs/assembly/artifacts/m3/local-world-transforms.md
new file mode 100644
index 00000000..6c44106e
--- /dev/null
+++ b/docs/assembly/artifacts/m3/local-world-transforms.md
@@ -0,0 +1,15 @@
+# Local/world transform proof
+
+The definition-local Shaft transform is translation Z = 10 mm. Parent Mates
+place the two module occurrences at X = -30 mm and X = +30 mm.
+
+| occurrence | world X | world Z |
+| --- | ---: | ---: |
+| LeftModule | -30 | 0 |
+| LeftModule.Shaft | -30 | 10 |
+| RightModule | 30 | 0 |
+| RightModule.Shaft | 30 | 10 |
+
+The exposed `DriveAxis` world origin is `[-30, 0, 10]` for LeftModule.
+`MountFace` and `MountPoint` resolve at X = -30. These queries use the public
+occurrence semantic identity, not the private child path.
diff --git a/docs/assembly/artifacts/m3/public-surface-and-mate.md b/docs/assembly/artifacts/m3/public-surface-and-mate.md
new file mode 100644
index 00000000..7ed6b81a
--- /dev/null
+++ b/docs/assembly/artifacts/m3/public-surface-and-mate.md
@@ -0,0 +1,14 @@
+# Public Assembly surface and parent Mate
+
+| public name | capability | implementation provenance |
+| --- | --- | --- |
+| Mount | AxisCapable, PlaneCapable, PointCapable | Housing.Mount |
+| Drive | AxisCapable, PlaneCapable, PointCapable | Shaft.Drive |
+| DriveAxis | AxisCapable | Shaft.Drive.Axis |
+| MountFace | PlaneCapable | Housing.Mount.Base |
+| MountPoint | PointCapable | Housing.Mount.Point |
+
+Parent Mate `PlaceLeft` records its public participant as
+`Moving: Machine.LeftModule.Mount`. Direct source dependency on
+`Machine.LeftModule.Housing.Mount` remains rejected with
+`assembly-internal-member-hidden`.
diff --git a/docs/assembly/artifacts/m3/validation.md b/docs/assembly/artifacts/m3/validation.md
new file mode 100644
index 00000000..f06feba2
--- /dev/null
+++ b/docs/assembly/artifacts/m3/validation.md
@@ -0,0 +1,21 @@
+# M3 validation
+
+M3A remains covered by
+`AssemblyM0Tests.TemplateAssembly_ReusesDefinitionAndExposesOnlyIntentionalSurface`.
+
+M3B focused coverage includes:
+
+- `AssemblyM3Tests`: cached local solve, local Mate/assertion ownership, repeated
+ occurrence transform composition, world Axis/Plane/Point, public summary edge,
+ expanded contributors, parent assertion, hidden-path rejection, and internal
+ underconstraint rejection.
+- `AssemblyM2InteropTests.TemplateAssembly_Ap242RoundTripPreservesNestedReuseAndComposedTransforms`:
+ reusable nested AP242 definition, logical occurrence expansion, transforms,
+ and exact shared child geometry.
+- `KernelApiIntegrationTests.AssemblyDisplay_TemplateSubassemblyPublishesNestedTreeSelectionAndPublicSurface`:
+ nested Cadmata packet, isolated selection groups, public inspector, Mate public
+ endpoint, and tolerance details.
+
+The canonical source is
+`fixtures/AssemblyM3/bearing-module.firmament`; the persisted AP242 round-trip
+artifact is `docs/assembly/artifacts/m3/bearing-module-ap242.step`.
diff --git a/docs/assembly/assembly-m3.md b/docs/assembly/assembly-m3.md
new file mode 100644
index 00000000..36f7ae55
--- /dev/null
+++ b/docs/assembly/assembly-m3.md
@@ -0,0 +1,59 @@
+# Assembly M3: template-produced assembly definitions
+
+M3 extends the existing `Template` mechanism; it does not add a `Module` or
+`Port` keyword. A declaration of the following form creates a reusable local
+Assembly definition:
+
+```firmament
+Template < Spec: BearingModuleSpec >
+Assembly BearingModule {
+ <Assembly BearingModule>
+ <Part Housing = HousingPart> Semantic Mount { Axis Axis = [0,0,0] -> [0,0,1]; } </Part>
+ </Assembly>
+ Expose { Semantic Mount = Housing.Mount; }
+}
+```
+
+An occurrence is then authored as `<Assembly Left = BearingModule<Spec:
+StandardSpec>>`. The normalized application is its definition identity, so
+identical applications reuse one definition identity while occurrence-scoped
+semantic values remain distinct.
+
+Assembly internals are private for external semantic resolution. `Left.Mount`
+is valid when exposed; `Left.Housing.Mount` produces
+`assembly-internal-member-hidden` and advises exposing an intentional semantic
+member. Product-tree visibility remains unaffected.
+
+Each normalized specialization is compiled once into an `AssemblyDefinitionIr`.
+That artifact owns the local product tree, Anchor, Mates, placements,
+dimensional relations, local assertions, public semantics, and public summary
+relations. An internally underconstrained, overconstrained, or failing
+specialization is rejected before the parent Assembly is compiled. Parent
+occurrences only compose the cached local transforms:
+
+`World(child) = World(AssemblyOccurrence) * Local(child)`.
+
+Public datum bindings are first converted from the implementing child's local
+frame into the Assembly definition frame. The occurrence transform then yields
+the exact world Axis, Plane, or Point.
+
+An `Expose` block may publish one bounded dimensional summary without exposing
+its private edges:
+
+```firmament
+Expose {
+ Semantic Mount = Housing.Mount;
+ Semantic Drive = Shaft.Drive;
+ Relation MountToDriveOffset: Mount -> Drive = Housing.Mount -> Shaft.Drive;
+}
+```
+
+The internal endpoints must have exactly one local relation path. The public
+edge stores the accumulated nominal/tolerance interval plus structured signed
+contributors. Parent stackups traverse that single edge and may expand it for
+diagnostics or Cadmata details.
+
+AP242 emits one reusable product definition for each Template Assembly
+specialization and separate occurrences beneath the root. Definition-local
+child usages are emitted once and expanded per occurrence on reimport, retaining
+the nested logical occurrence tree and exact part geometry.
diff --git a/docs/assembly/tolerance-stackup.md b/docs/assembly/tolerance-stackup.md
index 20101ad0..441da1f1 100644
--- a/docs/assembly/tolerance-stackup.md
+++ b/docs/assembly/tolerance-stackup.md
@@ -15,3 +15,11 @@ Assert ToleranceStackup AxialReach {
The compiler enumerates deterministic simple paths. Zero paths are `assembly-tolerance-path-missing`; more than one is `assembly-tolerance-path-ambiguous`. It never picks an arbitrary route, so JudgmentEngine is unnecessary for M0. For the unique signed chain, nominal values sum directly. A forward contributor adds `[lower, upper]`; a reversed contributor adds `[-upper, -lower]`. This is bounded worst-case interval propagation—no RSS, distributions, Monte Carlo, or Six Sigma.
The bearing-module proof automatically crosses Housing (30 -0.04/+0.05 mm), a Mate transition, Bearing (10 ±0.02 mm), another Mate transition, Spacer (5 -0.02/+0.03 mm), and the final seating transition. Result: nominal 45.00 mm, worst case 44.92–45.10 mm. The 44.90 mm assertion passes. The paired failing fixture requires 44.95 mm and reports a typed assertion failure while retaining all five contributors.
+
+Template Assembly definitions keep their dimensional graph private. An
+explicitly exposed `Relation` is lowered to one public summary edge containing
+the unique signed internal chain as structured `ExpandedContributors`. A parent
+assertion therefore depends only on `LeftModule.Mount -> LeftModule.Drive`,
+while evidence can expand the edge back to Housing seat, bearing width, spacer
+width, and their Template/Static Table/Record/`with` provenance. No other local
+relation becomes reachable across the encapsulation boundary.
diff --git a/docs/firmament-v2/language-reference.md b/docs/firmament-v2/language-reference.md
index 500c3484..983de92f 100644
--- a/docs/firmament-v2/language-reference.md
+++ b/docs/firmament-v2/language-reference.md
@@ -140,6 +140,21 @@ Interface SeatedAxis {
An `Assembly` body contains one XML-like product tree, an `Anchor`, independent `Mate` declarations, optional explicit `Relation`s, and stackup assertions. Part definitions are named after `=`; M1 also admits one Template application, for example `<Part P = Block<Spec: Standard>></Part>`. `Anchor` selects the instance datum whose owning Part receives identity placement. A final transform is a lowered result from Anchor + Mates.
+`Template < Spec: T > Assembly Name { ... }` creates a reusable Assembly
+definition; `<Assembly Left = Name<Spec: Value>></Assembly>` creates an
+occurrence. The normalized Template application is the definition identity.
+Local Mates, relations, assertions, and child transforms are solved once per
+specialization. Identical occurrences reuse that result and compose child world
+transforms from the occurrence transform.
+
+Template Assembly internals are source-private. Existing `Expose` syntax forms
+the public module surface, so `Left.Mount` can participate in a parent Interface
+while `Left.Housing.Mount` is rejected. Exposed Point/Axis/Plane bindings are
+definition-local and become world bindings through occurrence composition.
+`Expose` may also publish a `Relation Public: From -> To = Internal.From ->
+Internal.To;`; the parent graph sees one summary edge while stackup evidence
+retains its structured private contributor chain.
+
`Relation Name: A -> B = nominal tol ... from "provenance";` is a bounded directed dimensional edge, not an unrestricted equation graph. `Assert ToleranceStackup` finds one deterministic path, sums signed worst-case intervals, retains every contribution, and emits a typed compile failure if its clearance minimum is not met.
## Assertions
diff --git a/fixtures/AssemblyM3/bearing-module.firmament b/fixtures/AssemblyM3/bearing-module.firmament
new file mode 100644
index 00000000..e48f2431
--- /dev/null
+++ b/fixtures/AssemblyM3/bearing-module.firmament
@@ -0,0 +1,118 @@
+Concept AssemblyBlockConcept {
+ Bounds: Box3
+ Axis: Axis
+ Seat: Plane
+ Base: Plane
+ Height: Length
+}
+
+Enum BlockKind { Housing Shaft Spacer }
+Record BlockSpec { Kind: BlockKind Width: Length Depth: Length Height: Length }
+Record BearingModuleSpec { Housing: BlockSpec Shaft: BlockSpec Offset: Length }
+
+Static Table BlockStandards: BlockSpec Key: Kind {
+ Kind: [Housing, Shaft, Spacer]
+ Width: [20mm, 8mm, 6mm]
+ Depth: [20mm, 8mm, 6mm]
+ Height: [10mm, 10mm, 5mm]
+}
+Static HousingSpec = BlockStandards[Housing]
+Static ShaftSpec = BlockStandards[Shaft]
+Static SpacerSpec = BlockStandards[Spacer]
+Static BaseModuleSpec: BearingModuleSpec = BearingModuleSpec { Housing: HousingSpec Shaft: ShaftSpec Offset: 45mm }
+Static StandardModuleSpec = BaseModuleSpec with { Offset: 45mm }
+
+Template < Spec: BlockSpec >
+Struct AssemblyBlock: AssemblyBlockConcept {
+ Require Positive => Spec.Width > 0mm && Spec.Depth > 0mm && Spec.Height > 0mm
+ Concept Struct Design: AssemblyBlockConcept {
+ Bounds: Box3 { Size: [Spec.Width, Spec.Depth, Spec.Height] }
+ Axis: Bounds.Center.Axis(+Z)
+ Seat: Bounds.Face(+Z)
+ Base: Bounds.Face(-Z)
+ Height: Spec.Height
+ }
+ Box Body { Bounds: Design.Bounds }
+ Modify Body {
+ EdgeFinish ProofBreak {
+ Face: Design.Seat
+ Target: Boundary
+ Kind: Chamfer
+ Distance: 1mm
+ }
+ }
+ Expose {
+ Bounds: Design.Bounds
+ Axis: Design.Axis
+ Seat: Design.Seat
+ Base: Design.Base
+ Height: Design.Height
+ }
+}
+
+Interface RigidSeat {
+ Role Fixed requires AxisCapable, PlaneCapable;
+ Role Moving requires AxisCapable, PlaneCapable;
+ Lower AxisCoincident Moving.Axis Fixed.Axis;
+ Lower PlaneCoincident Moving.Base Fixed.Seat;
+ Allow rotation:about-axis;
+}
+
+Template < Spec: BearingModuleSpec >
+Assembly BearingModule {
+ <Assembly BearingModule>
+ <Part Housing = AssemblyBlock<Spec: HousingSpec>>
+ Semantic Mount {
+ Axis Axis = [0,0,0] -> [0,0,1];
+ Plane Base = [0,0,0] normal [0,0,1];
+ Plane Seat = [0,0,10] normal [0,0,1];
+ Point Point = [0,0,0];
+ }
+ </Part>
+ <Part Bearing = AssemblyBlock<Spec: SpacerSpec>>
+ Placement LegacyExplicit = [1,0,0,0,0,1,0,0,0,0,1,0,0,30,0,1];
+ Semantic Stack { Point Point = [0,0,0]; }
+ </Part>
+ <Part Spacer = AssemblyBlock<Spec: SpacerSpec>>
+ Placement LegacyExplicit = [1,0,0,0,0,1,0,0,0,0,1,0,0,50,0,1];
+ Semantic Stack { Point Point = [0,0,0]; }
+ </Part>
+ <Part Shaft = AssemblyBlock<Spec: ShaftSpec>>
+ Semantic Drive {
+ Axis Axis = [0,0,0] -> [0,0,1];
+ Plane Base = [0,0,0] normal [0,0,1];
+ Point Point = [0,0,0];
+ }
+ </Part>
+ </Assembly>
+ Anchor: BearingModule.Housing.Mount;
+ Mate ShaftSeat: RigidSeat { Fixed: BearingModule.Housing.Mount; Moving: BearingModule.Shaft.Drive; }
+ Relation HousingSeat: BearingModule.Housing.Mount -> BearingModule.Bearing.Stack = 10mm tol +0.02mm -0.01mm from "Housing seat";
+ Relation BearingWidth: BearingModule.Bearing.Stack -> BearingModule.Spacer.Stack = 20mm tol 0.03mm from "Bearing width / BlockStandards";
+ Relation SpacerWidth: BearingModule.Spacer.Stack -> BearingModule.Shaft.Drive = 15mm tol +0.05mm -0.04mm from "Spacer width / StandardModuleSpec with";
+ Assert ToleranceStackup InternalOffset { Between: [BearingModule.Housing.Mount, BearingModule.Shaft.Drive]; Require: Clearance >= 44.90mm; }
+ Expose {
+ Semantic Mount = Housing.Mount;
+ Semantic Drive = Shaft.Drive;
+ Axis DriveAxis = Shaft.Drive.Axis;
+ Plane MountFace = Housing.Mount.Base;
+ Point MountPoint = Housing.Mount.Point;
+ Relation MountToDriveOffset: Mount -> Drive = Housing.Mount -> Shaft.Drive;
+ }
+}
+
+Assembly Machine {
+ <Assembly Machine>
+ <Part Frame = AssemblyBlock<Spec: HousingSpec>>
+ Semantic LeftMount { Axis Axis = [-30,0,0] -> [0,0,1]; Plane Seat = [-30,0,0] normal [0,0,1]; }
+ Semantic RightMount { Axis Axis = [30,0,0] -> [0,0,1]; Plane Seat = [30,0,0] normal [0,0,1]; }
+ </Part>
+ <Assembly LeftModule = BearingModule<Spec: StandardModuleSpec>></Assembly>
+ <Assembly RightModule = BearingModule<Spec: StandardModuleSpec>></Assembly>
+ </Assembly>
+ Anchor: Machine.Frame.LeftMount;
+ Mate PlaceLeft: RigidSeat { Fixed: Machine.Frame.LeftMount; Moving: Machine.LeftModule.Mount; }
+ Mate PlaceRight: RigidSeat { Fixed: Machine.Frame.RightMount; Moving: Machine.RightModule.Mount; }
+ Relation FrameToLeft: Machine.Frame.LeftMount -> Machine.LeftModule.Mount = 0mm from "Frame datum to public module mount";
+ Assert ToleranceStackup MachineOffset { Between: [Machine.Frame.LeftMount, Machine.LeftModule.Drive]; Require: Clearance >= 44.90mm; }
+}