Beispiel #1
0
    def _read_response(self, r_xml: Et._Element) -> bool:
        if r_xml is None:
            return False

        self.scene_root = NodeInfo.get_node_from_as_connector_element(r_xml.find(self.response_xpath))

        for idx, n in enumerate(r_xml.iterfind(self.response_xpath)):
            node = NodeInfo.get_node_from_as_connector_element(n)
            node.knecht_id = None if node.knecht_id == 'None' else node.knecht_id
            self.result[node.knecht_id or node.as_id or idx] = node

        return True
Beispiel #2
0
    def __init__(self, parent_node: NodeInfo = None, name: str = '', lincid: str = '',
                 filename: Path = Path(), load_part: bool = False):
        super(AsNodeCreateRequest, self).__init__('node/create')
        self.result: Optional[NodeInfo] = None

        parent_node = NodeInfo(node_info_type='FILE') if not parent_node else parent_node
        self._set_request(parent_node, name, lincid, filename, load_part)
Beispiel #3
0
    def __init__(self, node: NodeInfo = None):
        super(AsNodeDeleteRequest, self).__init__('node/delete')
        self.result = str()
        self.expected_result = 'true'

        node = NodeInfo() if not node else node
        self._set_request(node)
Beispiel #4
0
    def __init__(self, node: NodeInfo = None, filepath: Path = Path()):
        super(AsNodeAddFilepartRequest, self).__init__('node/addfilepart')
        self.result = str()
        self.expected_result = 'true'

        node = NodeInfo(node_info_type='FILE') if not node else node
        self._set_request(node, filepath)
Beispiel #5
0
    def __init__(self, node: NodeInfo = None, supress_dialogs: bool = True):
        super(AsNodeLoadFilepartRequest, self).__init__('node/loadfilepart')
        self.result = str()
        self.expected_result = 'true'

        node = NodeInfo(node_info_type='FILE') if not node else node

        self._set_request(node, supress_dialogs)
Beispiel #6
0
    def _read_response(self, r_xml: Et._Element) -> bool:
        e = r_xml.find(self.response_xpath)
        LOGGER.debug('Event/Selected result: %s', r_xml)

        if e is not None:
            self.result = NodeInfo.get_node_from_as_connector_element(e)
            return True
        else:
            return False
Beispiel #7
0
    def _read_response(self, r_xml: Et._Element) -> bool:
        e = r_xml.find(self.response_xpath)

        if e is not None:
            self.result = NodeInfo.get_node_from_as_connector_element(e)
            LOGGER.debug('Node/Create result: %s', self.result)
            return True
        else:
            LOGGER.error('Node Create Request failed: %s', self.to_string())
            return False
Beispiel #8
0
    def validate_scene_vs_plmxml(
            self) -> Tuple[bool, List[NodeInfo], Set[str], Optional[NodeInfo]]:
        """ Validate the currently loaded Scene versus
            the PlmXml. Report missing Nodes/Parts and missing material targets.

            Return as invalid if missing Nodes encountered. Missing targets can
            occur due to unloaded parts and will not set status to invalid.

            Note:
             If scene was saved with "Save Structure as..", DeltaGen will also
             save the scene materials regardless of loaded assemblies.
             There could be target materials in the scene that are not bound to any meshes.
             Therefore they will not be reported but still be invalid.

        :return: Request was un/-successful, List of missing nodes, set of missing/unloaded target materials
        :rtype: bool, List[NodeInfo], Set[str]
        """
        missing_nodes: List[NodeInfo] = list()
        missing_target_names: Set[str] = set()
        material_dummy: Optional[NodeInfo] = None

        # ---- Validate scene structure ----
        # -- Create GetSceneStructureRequest
        root_node_dummy = NodeInfo(as_id='root', parent_node_id='root')
        scene_request = AsSceneGetStructureRequest(root_node_dummy, list())
        request_result = self.as_conn.request(scene_request)

        if not request_result:
            # Request failed
            return False, missing_nodes, missing_target_names, material_dummy

        # -- Update As Connector Id's
        self._update_plmxml_with_as_connector_nodes(scene_request.result)

        # -- Check for Material Dummy *.csb Group or Material
        for _id, node in scene_request.result.items():
            if node.name == CSB_DUMMY_MATERIAL and node.type == 'GROUP':
                material_dummy = node

        # -- Compare PlmXml vs Scene
        for node in self.plmxml.iterate_configurable_nodes():
            if node.knecht_id not in scene_request.result:
                missing_nodes.append(node)

        # -- Get Invalid Material Targets
        _, missing_targets = self._get_valid_material_targets()
        missing_target_names = {t.name for t in missing_targets if t.name}

        LOGGER.debug(
            'Validate Scene vs PlmXml Result: %s nodes are missing. '
            '%s Material Targets are missing or unloaded.', len(missing_nodes),
            len(missing_target_names))

        # Request successful, missing LincId's
        return True, missing_nodes, missing_target_names, material_dummy