FUNCTION find_assembly_root

(* SCHEMA step_merged_ap_schema; *)
-- IN AP242
FUNCTION find_assembly_root
      (constituent : SET OF product_definition ) : SET OF product_definition;
   LOCAL
      local_relation : SET OF assembly_component_usage := [];
      local_relation2 : BAG OF assembly_component_usage := [];
      local_parent : SET OF product_definition := [];
      root : SET OF product_definition;
      i : INTEGER := 0;
      j : INTEGER := 0;
   END_LOCAL;
      IF (SIZEOF(constituent) = 1) AND assembly_root(constituent[1]) THEN
         RETURN ([ constituent[1] ]);
      ELSE
         IF SIZEOF(constituent) = 0 THEN
            RETURN ([]);
         ELSE
            REPEAT j := 1 TO HIINDEX(constituent);
               local_relation2 := local_relation2 + QUERY (pdr <* USEDIN(constituent[j], 'STEP_MERGED_AP_SCHEMA.PRODUCT_DEFINITION_RELATIONSHIP.RELATED_PRODUCT_DEFINITION')| ('STEP_MERGED_AP_SCHEMA.ASSEMBLY_COMPONENT_USAGE' IN TYPEOF(pdr)));
            END_REPEAT;
            local_relation := bag_to_set(local_relation2);
            IF SIZEOF(local_relation) = 0 THEN
               IF SIZEOF(constituent) = 1 THEN
                  RETURN ([ constituent[1] ]);
               ELSE
                  RETURN ([]);
               END_IF;
            ELSE
               REPEAT i := 1 TO HIINDEX(local_relation);
                  REPEAT j := 1 TO HIINDEX(constituent);
                     IF local_relation[i].relating_product_definition <> constituent[j] THEN
                        local_parent := local_parent + local_relation[i].relating_product_definition;
                     END_IF;
                  END_REPEAT;
               END_REPEAT;
               IF (SIZEOF(local_parent) = 1) AND assembly_root(local_parent[1]) THEN
                  RETURN ([ local_parent[1] ]);
               ELSE
                  IF SIZEOF(local_parent) = 0 THEN
                     RETURN ([]);
                  ELSE
                     root := find_assembly_root(local_parent);
                     IF SIZEOF(root) = 1 THEN
                        RETURN (root);
                     ELSE
                        IF SIZEOF(root) = 0 THEN
                           RETURN ([]);
                        END_IF;
                     END_IF;
                  END_IF;
               END_IF;
            END_IF;
         END_IF;
      END_IF;
      RETURN ([]);
END_FUNCTION;

Referenced By

Defintion find_assembly_root is references by the following definitions:
DefinitionType
 shape_aspect_relationship_representation_association ENTITY


[Top Level Definitions] [Exit]

Generated by STEP Tools® EXPRESS to HTML Converter
2020-07-28T17:02:20-04:00