Ejemplo n.º 1
0
def processXMLElement(xmlElement):
    "Process the xml element."
    fileName = evaluate.getEvaluatedValue('file', xmlElement)
    if fileName == None:
        return
    parserFileName = xmlElement.getRoot().parser.fileName
    absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, fileName)
    xmlText = ''
    if fileName.endswith('.xml'):
        xmlText = archive.getFileText(absoluteFileName)
    else:
        xmlText = getXMLFromCarvingFileName(absoluteFileName)
    if xmlText == '':
        print(
            'The file %s could not be found in the folder which the fabmetheus xml file is in.'
            % fileName)
        return
    if '_importname' in xmlElement.attributeDictionary:
        xmlElement.importName = xmlElement.attributeDictionary['_importname']
    else:
        xmlElement.importName = archive.getUntilDot(fileName)
        xmlElement.attributeDictionary['_importname'] = xmlElement.importName
    XMLSimpleReader(parserFileName, xmlElement, xmlText)
    originalChildren = xmlElement.children[:]
    xmlElement.children = []
    for child in originalChildren:
        for subchild in child.children:
            subchild.setParentAddToChildren(xmlElement)
        for attributeDictionaryKey in child.attributeDictionary.keys():
            if attributeDictionaryKey != 'version':
                xmlElement.attributeDictionary[
                    attributeDictionaryKey] = child.attributeDictionary[
                        attributeDictionaryKey]
    group.processShape(group.Group, xmlElement)
Ejemplo n.º 2
0
def processXMLElement(xmlElement):
    "Process the xml element."
    fileName = evaluate.getEvaluatedValue("file", xmlElement)
    if fileName == None:
        return
    parserFileName = xmlElement.getRoot().parser.fileName
    absoluteFileName = gcodec.getAbsoluteFolderPath(parserFileName, fileName)
    xmlText = ""
    if fileName.endswith(".xml"):
        xmlText = gcodec.getFileText(absoluteFileName)
    else:
        xmlText = getXMLFromCarvingFileName(absoluteFileName)
    if xmlText == "":
        print("The file %s could not be found in the folder which the fabmetheus xml file is in." % fileName)
        return
    if "_importname" in xmlElement.attributeDictionary:
        xmlElement.importName = xmlElement.attributeDictionary["_importname"]
    else:
        xmlElement.importName = gcodec.getUntilDot(fileName)
        xmlElement.attributeDictionary["_importname"] = xmlElement.importName
    XMLSimpleReader(parserFileName, xmlElement, xmlText)
    originalChildren = xmlElement.children[:]
    xmlElement.children = []
    for child in originalChildren:
        for subchild in child.children:
            subchild.setParentAddToChildren(xmlElement)
        for attributeDictionaryKey in child.attributeDictionary.keys():
            if attributeDictionaryKey != "version":
                xmlElement.attributeDictionary[attributeDictionaryKey] = child.attributeDictionary[
                    attributeDictionaryKey
                ]
    group.processShape(group.Group, xmlElement)
Ejemplo n.º 3
0
def processXMLElement( xmlElement, xmlProcessor ):
	"Process the xml element."
	fileName = evaluate.getEvaluatedValue('file', xmlElement )
	if fileName == None:
		return
	parserFileName = xmlElement.getRoot().parser.fileName
	absoluteFileName = gcodec.getAbsoluteFolderPath( parserFileName, fileName )
	xmlText = ''
	if fileName.endswith('.xml'):
		xmlText = gcodec.getFileText( absoluteFileName )
	else:
		xmlText = getXMLFromCarvingFileName( absoluteFileName )
	if xmlText == '':
		print('The file %s could not be found in the folder which the fabmetheus xml file is in.' % fileName )
		return
	if '_importname' in xmlElement.attributeDictionary:
		xmlElement.importName = xmlElement.attributeDictionary['_importname']
	else:
		xmlElement.importName = gcodec.getUntilDot( fileName )
		xmlElement.attributeDictionary['_importname'] = xmlElement.importName
	XMLSimpleReader( parserFileName, xmlElement, xmlText )
	originalChildren = xmlElement.children[ : ]
	xmlElement.children = []
	for child in originalChildren:
		for subchild in child.children:
			subchild.setParentAddToChildren(xmlElement)
		for attributeDictionaryKey in child.attributeDictionary.keys():
			if attributeDictionaryKey != 'version':
				xmlElement.attributeDictionary[ attributeDictionaryKey ] = child.attributeDictionary[ attributeDictionaryKey ]
	group.processShape( group.Group, xmlElement, xmlProcessor )
	root = xmlElement.getRoot()
	root.idDictionary[ xmlElement.importName ] = evaluate.ElementID(xmlElement)
	root.nameDictionary[ xmlElement.importName ] = evaluate.ElementName(xmlElement)
Ejemplo n.º 4
0
def processXMLElement(xmlElement):
    'Process the xml element.'
    fileName = evaluate.getEvaluatedValue('file', xmlElement)
    if fileName == None:
        return
    parserFileName = xmlElement.getRoot().parser.fileName
    absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, fileName)
    absoluteFileName = os.path.abspath(absoluteFileName)
    if 'models/' not in absoluteFileName:
        print(
            'Warning, models/ was not in the absolute file path, so for security nothing will be done for:'
        )
        print(xmlElement)
        print('For which the absolute file path is:')
        print(absoluteFileName)
        print(
            'The import tool can only read a file which has models/ in the file path.'
        )
        print(
            'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.'
        )
        return
    xmlText = ''
    if fileName.endswith('.xml'):
        xmlText = archive.getFileText(absoluteFileName)
    else:
        xmlText = getXMLFromCarvingFileName(absoluteFileName)
    print('The import tool is opening the file:')
    print(absoluteFileName)
    if xmlText == '':
        print(
            'The file %s could not be found by processXMLElement in import.' %
            fileName)
        return
    if '_importName' in xmlElement.attributeDictionary:
        xmlElement.importName = xmlElement.attributeDictionary['_importName']
    else:
        xmlElement.importName = archive.getUntilDot(fileName)
        if evaluate.getEvaluatedBooleanDefault(True, 'basename', xmlElement):
            xmlElement.importName = os.path.basename(xmlElement.importName)
        xmlElement.attributeDictionary['_importName'] = xmlElement.importName
    importXMLElement = xml_simple_reader.XMLElement()
    xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement,
                                      xmlText)
    for child in importXMLElement.children:
        child.copyXMLChildren('', xmlElement)
        euclidean.removeElementsFromDictionary(child.attributeDictionary,
                                               ['id', 'name'])
        xmlElement.attributeDictionary.update(child.attributeDictionary)
        if evaluate.getEvaluatedBooleanDefault(False, 'overwriteRoot',
                                               xmlElement):
            xmlElement.getRoot().attributeDictionary.update(
                child.attributeDictionary)
    group.processShape(group.Group, xmlElement)
Ejemplo n.º 5
0
def processXMLElement(xmlElement):
	'Process the xml element.'
	fileName = evaluate.getEvaluatedValue('file', xmlElement )
	if fileName == None:
		return
	parserFileName = xmlElement.getRoot().parser.fileName
	absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, fileName)
	absoluteFileName = os.path.abspath(absoluteFileName)
	if 'models/' not in absoluteFileName:
		print('Warning, models/ was not in the absolute file path, so for security nothing will be done for:')
		print(xmlElement)
		print('For which the absolute file path is:')
		print(absoluteFileName)
		print('The import tool can only read a file which has models/ in the file path.')
		print('To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.')
		return
	xmlText = ''
	if fileName.endswith('.xml'):
		xmlText = archive.getFileText(absoluteFileName)
	else:
		xmlText = getXMLFromCarvingFileName(absoluteFileName)
	print('The import tool is opening the file:')
	print(absoluteFileName)
	if xmlText == '':
		print('The file %s could not be found by processXMLElement in import.' % fileName)
		return
	if '_importName' in xmlElement.attributeDictionary:
		xmlElement.importName = xmlElement.attributeDictionary['_importName']
	else:
		xmlElement.importName = archive.getUntilDot(fileName)
		if evaluate.getEvaluatedBooleanDefault(True, 'basename', xmlElement):
			xmlElement.importName = os.path.basename(xmlElement.importName)
		xmlElement.attributeDictionary['_importName'] = xmlElement.importName
	importXMLElement = xml_simple_reader.XMLElement()
	xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement, xmlText)
	for child in importXMLElement.children:
		child.copyXMLChildren('', xmlElement)
		euclidean.removeElementsFromDictionary(child.attributeDictionary, ['id', 'name'])
		xmlElement.attributeDictionary.update(child.attributeDictionary)
		if evaluate.getEvaluatedBooleanDefault(False, 'overwriteRoot', xmlElement):
			xmlElement.getRoot().attributeDictionary.update(child.attributeDictionary)
	group.processShape(group.Group, xmlElement)
Ejemplo n.º 6
0
def processXMLElement( xmlElement, xmlProcessor ):
	"Process the xml element."
	fileName = evaluate.getEvaluatedValue( 'file', xmlElement )
	if fileName == None:
		return
	parserFileName = xmlElement.getRoot().parser.fileName
	absoluteFileName = gcodec.getAbsoluteFolderPath( parserFileName, fileName )
	xmlText = getXMLFromFileName( absoluteFileName )
	if xmlText == '':
		print( 'The file %s could not be found in the folder which the fabmetheus xml file is in.' % fileName )
		return
	if '_importname' in xmlElement.attributeDictionary:
		xmlElement.importName = xmlElement.attributeDictionary[ '_importname' ]
	else:
		xmlElement.importName = gcodec.getUntilDot( fileName )
		xmlElement.attributeDictionary[ '_importname' ] = xmlElement.importName
	XMLSimpleParser( parserFileName, xmlElement, xmlText )
	group.processShape( group.Group, xmlElement, xmlProcessor )
	root = xmlElement.getRoot()
	root.idDictionary[ xmlElement.importName ] = evaluate.ElementID( xmlElement )
	root.nameDictionary[ xmlElement.importName ] = evaluate.ElementName( xmlElement )
Ejemplo n.º 7
0
def processXMLElement(xmlElement, xmlProcessor):
    "Process the xml element."
    fileName = evaluate.getEvaluatedValue('file', xmlElement)
    if fileName == None:
        return
    parserFileName = xmlElement.getRoot().parser.fileName
    absoluteFileName = gcodec.getAbsoluteFolderPath(parserFileName, fileName)
    xmlText = getXMLFromFileName(absoluteFileName)
    if xmlText == '':
        print(
            'The file %s could not be found in the folder which the fabmetheus xml file is in.'
            % fileName)
        return
    if '_importname' in xmlElement.attributeDictionary:
        xmlElement.importName = xmlElement.attributeDictionary['_importname']
    else:
        xmlElement.importName = gcodec.getUntilDot(fileName)
        xmlElement.attributeDictionary['_importname'] = xmlElement.importName
    XMLSimpleParser(parserFileName, xmlElement, xmlText)
    group.processShape(group.Group, xmlElement, xmlProcessor)
    root = xmlElement.getRoot()
    root.idDictionary[xmlElement.importName] = evaluate.ElementID(xmlElement)
    root.nameDictionary[xmlElement.importName] = evaluate.ElementName(
        xmlElement)
Ejemplo n.º 8
0
def processXMLElement(xmlElement):
	"Process the xml element."
	group.processShape( Union, xmlElement)
Ejemplo n.º 9
0
def processXMLElement(xmlElement):
    "Process the xml element."
    group.processShape(Sphere, xmlElement)
Ejemplo n.º 10
0
def processXMLElement(xmlElement):
    "Process the xml element."
    group.processShape(Difference, xmlElement)
Ejemplo n.º 11
0
def processXMLElement(xmlElement):
	"Process the xml element."
	group.processShape(Difference, xmlElement)
Ejemplo n.º 12
0
def processXMLElement( xmlElement, xmlProcessor ):
	"Process the xml element."
	group.processShape( TriangleMesh, xmlElement, xmlProcessor )
Ejemplo n.º 13
0
def processXMLElement(xmlElement):
	'Process the xml element.'
	group.processShape( Cylinder, xmlElement)
Ejemplo n.º 14
0
def processXMLElement(xmlElement):
	'Process the xml element.'
	group.processShape( TriangleMesh, xmlElement)
Ejemplo n.º 15
0
def processXMLElement( xmlElement, xmlProcessor ):
	"Process the xml element."
	group.processShape( Sphere, xmlElement, xmlProcessor )
Ejemplo n.º 16
0
def processXMLElement(xmlElement, xmlProcessor):
    "Process the xml element."
    group.processShape(TriangleMesh, xmlElement, xmlProcessor)
Ejemplo n.º 17
0
def processXMLElement(xmlElement, xmlProcessor):
    "Process the xml element."
    group.processShape(Cube, xmlElement, xmlProcessor)
Ejemplo n.º 18
0
def processXMLElement(xmlElement):
	"Process the xml element."
	group.processShape( Cylinder, xmlElement)
Ejemplo n.º 19
0
def processXMLElement(xmlElement):
	'Process the xml element.'
	group.processShape(Sphere, xmlElement)
Ejemplo n.º 20
0
def processXMLElement(xmlElement):
    "Process the xml element."
    group.processShape(Intersection, xmlElement)
Ejemplo n.º 21
0
def processXMLElement(xmlElement):
	"Process the xml element."
	group.processShape( Intersection, xmlElement)
Ejemplo n.º 22
0
def processXMLElement(xmlElement, xmlProcessor):
    "Process the xml element."
    group.processShape(Cylinder, xmlElement, xmlProcessor)