Learning and challenging days

Today I made a few bash scripts which read the data from the file and then process that data in a meaningful way by using Grass software. I have also learnt stuff related to contour by Grass software.

One interesting thing happened today

When I have given my bash script to Amarjeet and he runs my bash script as sh myscript.sh and it gave an error “Unexcepted token error [[” but on my laptop was working fine. On my laptop I run my bash script as ./myscript.sh and then after some time I found the answer that why script gives an error on Amarjeet’s laptop. Actually, he runs my script in sh shell whereas I have written my script according to the bash shell and then I told to Amarjeet to run my bash script as bash myscript.sh or as ./myscript.sh.

Daily diary

Today, I tried to draw dimensions of a part by using the Draft workbench of FreeCAD. However, I can draw the dimensions of through coding but many things that I have to keep in mind like page offset and position of three vectors etc.

I also solved one program of “Roy and Profile Picture” (https://www.hackerearth.com/problem/algorithm/roy-and-profile-picture/) in C++. Here is the solution of the above problem.
https://github.com/amrit3701/Programs/blob/master/roy_and_profile_picture.cpp

Daily diary

Today, I didn’t worked so much but I solved one problem related the Arch module present in the FreeCAD on the Experimental server. Actually, when I imported Arch module in command line FreeCAD freecadcmd it gave a error “Exception while processing file: drawing.FCMacro [‘module’ object has no attribute ‘updateLocale’]”. It was the bug presented in the FreeCAD command line 0.14 version because in 0.14 version Arch module depended on GUI and in command line FreeCAD, GUI is not present. Then, I upgraded the command line FreeCAD to 0.16 version and after this my problem was solved.

Compilied Watertank project

Today, I compiled Water tank project code and trying to open .g format file in FreeCAD by converting .g format file to other format but unable to open it.

Other files include brep-files for objects and thumbnail of drawing. BesidesFreeCAD’s own file format, files could be exchanged by the following file formats: DXF, SVG (Scalable Vector Graphics), STEP, IGES, STL (STereoLithography), OBJ (Wavefront), DAE (Collada), SCAD (OpenSCAD), IV (Inventor) and IFC. (https://en.wikipedia.org/wiki/FreeCAD)

Output of Water tank project after compilation:

watertank

Learning too many new things today

Today, I installed Gitlab server on the experimental server (link) and solved the Monisha’s problem in BuildD project

Few new things that I have learned today:

  • Run Nginx on different ports instead of 80
  • Virtual site configuration with Nginx
  • Port forwarding by using Iptables command
  • Little C++ stuff
  • Working on dictionary list ( keys and values ) in Python
  • jQuery: Conditional show an element based on drop down box selection

Export drawing sheets of FreeCAD into PDF and SVG format from Python console – Done

Finally, I found the answer that how to save the drawing sheets in FreeCAD from Python console. In FreeCAD, whenever we created a new drawing sheet its get stored as temporary file in our system. The below code is used to find the location of the drawing from Python console:

import os
import subprocess

obj = App.ActiveDocument.getObject("Page")
page = getattr(obj, 'PageResult')

The page variable stored the location of the drawing sheet in SVG format.

Converting SVG format to PDF format by using Inkscape:

import os
import subprocess

obj = App.ActiveDocument.getObject("Page")

# Path to Inkscape executable
inkscape_path = "/usr/bin/inkscape"

# Exported PDF file location
file_location = os.path.expanduser("~" + os.sep + obj.Label + ".pdf")

page = getattr(obj, 'PageResult')
call_inkscape = [inkscape_path, "-f", obj.PageResult, "-A", file_location]
subprocess.call(call_inkscape)