Notifications
Clear all

[Closed] xml export formating

Am writing an xml camera export from 3dsMax to Photoscan with following code.

						
				dotnet.loadAssembly "system.xml"
				XmlDoc=dotNetObject "System.xml.xmlDocument"
					
				docNd=XmlDoc.createElement "document"
				XmlDoc.appendChild docNd
										
				chunkNd=XmlDoc.createElement "chunk"
				docNd.appendChild chunkNd
					
				sensorsNd=XmlDoc.createElement "sensors"
				chunkNd.appendChild sensorsNd
					
				sensorNd = XmlDoc.createElement "sensor"
				sensorNd.setattribute "id" "0"
				sensorNd.setattribute "label" "unknown"
				sensorNd.setattribute "type" "frame"
				sensorsNd.appendChild sensorNd
				
				resolutionNd = XmlDoc.createElement "resolution"
				resolutionNd.setattribute "width" (renderwidth as string)
				resolutionNd.setattribute "height" (renderheight as string)	
				sensorNd.appendChild resolutionNd
				
				propertyNd = XmlDoc.createElement "property"
				propertyNd.setattribute "name" "fixed"
				propertyNd.setattribute "value" "false"
				sensorNd.appendChild propertyNd
				
				calibrationNd = XmlDoc.createElement "calibration"
				calibrationNd.setattribute "type" "frame"
				calibrationNd.setattribute "class" "initial"
				sensorNd.appendChild calibrationNd
								
				global ApertureWidth = getRendApertureWidth()
				global AspectRatio = getRendImageAspect()
				global ApertureHeight = ApertureWidth / AspectRatio 
				global VFOV = 2.0*atan(tan(camera_out.fov/2.0)/AspectRatio)
	
				global Focal_Length = (ApertureWidth/2) /(tan (camera_out.fov/2.0))
						
				FL_pixels_Width = renderwidth * (Focal_Length / ApertureWidth)
				FL_pixels_Height = renderheight * (Focal_Length / ApertureHeight)
				
				resolution2Nd = XmlDoc.createElement "resolution"
				resolution2Nd.setattribute "width" (renderwidth as string)
				resolution2Nd.setattribute "height" (renderheight as string)
				calibrationNd.appendChild resolution2Nd
						
					fxNd = XmlDoc.createElement "fx"  --(FL_pixels_Width as string)
				--	fxNd.InnerText  (FL_pixels_Width as string)
					fxNd.setattribute "AAA"  (FL_pixels_Width as string)
					calibrationNd.appendChild fxNd

					fyNd = XmlDoc.createElement "fy" --(FL_pixels_Height as string)
				--	fyNd.InnerText  (FL_pixels_Height as string)
					fyNd.setattribute "AAA" (FL_pixels_Height as string)
					calibrationNd.appendChild fyNd

				
		XmlDoc.save SaveCameraFileName --"C:/MyTest.xml"

Am trying to achieve this type of formatting:



<document>
  <chunk>
    <sensors>
      <sensor id="0" label="unknown" type="frame">
        <resolution width="1920" height="1080"/>
        <property name="fixed" value="false"/>
        <calibration type="frame" class="initial">
          <resolution width="1920" height="1080"/>
          <fx>1.6444038393145370e+003</fx>
          <fy>1.6224512714671557e+003</fy>
        </calibration>
      </sensor>
    </sensors>
  </chunk>
</document>


But am only able to get following. Am having trouble with getting fx and fy to work without having to use ‘setattribute’.

Should be this: 1418.46
but getting this:


<document>
  <chunk>
    <sensors>
      <sensor id="0" label="unknown" type="frame">
        <resolution width="1920" height="1080" />
        <property name="fixed" value="false" />
        <calibration type="frame" class="initial">
          <resolution width="1920" height="1080" />
          <fx AAA="1418.46" />
          <fy AAA="1418.46" />
        </calibration>
      </sensor>
    </sensors>
  </chunk>
</document>

1 Reply
fxNd = XmlDoc.createElement "fx"  --(FL_pixels_Width as string)
fxNd.InnerText [B]=[/B] (FL_pixels_Width as string)
calibrationNd.appendChild fxNd

fyNd = XmlDoc.createElement "fy" --(FL_pixels_Height as string)
fyNd.InnerText [B]=[/B] (FL_pixels_Height as string)
calibrationNd.appendChild fyNd

InnerText is a property not a function