Import Desenho 3D saved file in Blender using a Python script

I made a python script to load the saved files from the application Desenho 3D (xml format) and with that data I reproduce the saved project in Blender.

I used the Blender 2.78.1 version, my PC has a intel i5 3570k processor but I used the GTX 1060 graphics card for the render, is much faster (in the video the render part is 8 times accelerated).

Video explaining the process

Initially I tried to used the Desenho 3D for creating more realistic images, but for that is necessary to create certain effects files and that was very complicated and when I switch for the display version to a more productive version, all the time was redirect to that version.

This year I started following a Python online course in Coursera, and I had an idea to create a script to recreate my Desenho 3D project in Blender, and there I could have a lot more options, like to render a more photo realistic image.

Images saved after each render

Desenho 3D

I started this project with one idea, create a 3D representation of wardrobes using XNA, but ended doing an almost complete different program.

The final product is far from completed because it has a lot of functions that can be added, but the version I will show here is being used for more than 2 years.

The application reproduces the wardrobe using data inserted and selected (using the client parameters). After the first phase we can add the internal elements and change some structural elements.

Key features

  • Can recreate the wardrobe within the space, single form, dual form (corner) or triple form (U / closet)
  • Has multiple combinations of structure, n for Top, n for Bottom, n for Left and Right
  • Sliding, hinged or plegable doors
  • Multi-material and MDF with patterns preview, both for sliding doors
  • Multiple predefined internal variables, change when needed or load a configuration file
  • Prints data with cut pieces with 2D draw representation
  • Prints label to stick after cut, using 2 kinds of printer, thermal printer type or dot matrix printer type
  • Display approximated weight (kilograms) and cubic size (meters)
  • Can explode/expand the pieces for better understanding

Print using Visual Studio

Using Visual Studio, we can print:

– directly using print method
– insert a generated image with the content and then print
– a combination of both

Form preview

Code for Form

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Print_Etiquetas
    public partial class Form1 : Form
        GenerateImage gImage = new GenerateImage();

        int nPages = 1;
        int Page = 0;
        Bitmap bitmap;

        int dpi = 203;
        Size size_mm = new Size(100, 40);

        public Form1()

            comboBox1.Items.Add("Arial Black");
            comboBox1.Items.Add("Arial Narrow");
            comboBox1.Items.Add("Lucida Console");
            comboBox1.SelectedIndex = 2;

            textBox7.Text = "14"; //default font size

            textBox0.Text = "Dear Sir(s)";

            System.Drawing.Printing.PaperSize custom = new System.Drawing.Printing.PaperSize("custom", 100, 40);
            printDocument1.DefaultPageSettings.PaperSize = custom;
            printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);

            //exit control
            this.FormClosing += Form1_FormClosing;

            updateImage(textBox0.Text, new string[] { "Name", "To", "Address", "State", "Postal Code" });

        //controls if the user wants to exit/close the application
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            DialogResult dialog = MessageBox.Show("Are you sure?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dialog == DialogResult.No)
                e.Cancel = true;

        //generate image
        private void updateImage(string line0, string[] text)
            bitmap = gImage.ImageFromData(line0, text, size_mm, dpi, new Font(comboBox1.SelectedItem.ToString(), int.Parse(textBox7.Text)));

            pictureBox1.BackColor = Color.White;
            pictureBox1.BorderStyle = BorderStyle.FixedSingle;

            Bitmap bitmapResized = new Bitmap(bitmap, new Size(pictureBox1.Width, pictureBox1.Height));

            //show image
            pictureBox1.BackgroundImage = (Image)bitmapResized;

        private void button1_Click(object sender, EventArgs e)
            MessageBox.Show("preview label before print", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            //PrintDialog associate with PrintDocument;
            printDialog1.Document = printDocument1;
            // Show Print selection menu and then print
            if (printDialog1.ShowDialog() == DialogResult.OK)
                printDocument1.DocumentName = "label";
                Page = 0; //reset number of page
                int num;
                bool isNum = int.TryParse(nCopies.Text, out num);
                if (!isNum)
                    MessageBox.Show("You need to insert a valid number for copies");
                nPages = num;
        void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            e.Graphics.PageUnit = GraphicsUnit.Millimeter;

            //prints bitmap
            e.Graphics.DrawImageUnscaled(bitmap, new Point(0, 0));            

            //controls number copies
            if (Page < nPages)
                e.HasMorePages = true;
                e.HasMorePages = false;

        //update preview
        private void button3_Click(object sender, EventArgs e)
            updateImage(textBox0.Text, new string[] { textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text});

        //exit/close application
        private void button5_Click(object sender, EventArgs e)

Code for Class (GenerateImage)

using System.Drawing;

namespace Print_Etiquetas
    class GenerateImage
        public GenerateImage()


        public Bitmap ImageFromData(string line0, string[] data, Size size_mm, int dpi, Font font)
            double inWidth = (size_mm.Width / 25.4) * dpi;
            double inHeight = (size_mm.Height / 25.4) * dpi;

            var bitmap = new Bitmap((int)(inWidth), (int)(inHeight));
            int inc = (bitmap.Height / 6) - 1;
            bitmap.SetResolution(dpi, dpi);
            using (var g = System.Drawing.Graphics.FromImage(bitmap))
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                //process Label
                int yPos = 1;
                g.DrawString(line0, font, Brushes.Black, new Point(2, yPos));
                yPos += inc;

                for (int i = 0; i < data.GetLongLength(0); i++)
                    g.DrawString(data[i], font, Brushes.Black, new Point(2, yPos));
                    yPos += inc;
            return bitmap;

The result

One fact we need to understand when generating an image for print is the size, which is defined by the size in millimeters or inches, multiplied by the dpi (dots per inch)

Let’s take the example of the code, if we need to print a label with 100 x 40mm (width x height):

– Size: 100x40mm (to inch: divide by 25.4) = 100/25.4 by 40/25.4

– Dpi: in my case the printer has a dpi of 203, it’s a TSC TA210 printer.

– So the image needs to be (Width by Height) 203*3.937 by 203*1.575

When printing using the code e.Graphics.DrawImageUnscaled(…) the program will use the real size mm/in for the print, even if the dpi for the printer is different, but it’s advised to use the correct or higher dpi if possible.

4Sim Racing 2nd Screen

This is a application I have done for Project Cars Game

It uses the UDP to transmit from the game to display on the phone or tablet complementary information.

With the new update for Project Cars, update 7.0, console users can now have on their mobile phone or tablet information from the game.


– Project Cars – PC, Xbox One or Playstation 4 version

– UDP connection active on game

– A wireless connection between the PC/Game Console and mobile phone or tablet.

Display current, best and last time, position, lap, session event, session time remaining, speed, rpm, revmeter, fuel, water and oil temperature, and also tires info.

Slide up and down to switch time, slide for any side to show tires information.

Added support for dpad movement for switch time and screen info, single press for time and long press for screen change.

Beep sounds, slide up to change time and every 60 seconds verify fuel (below 5%), water and oil above 115 celsius degrees.


New Gameplay