Enhancing the power of rebar object – FreeCAD

Today, I added a Total Length property to the rebar object. Total length is the length of the individual rebar multiplied by the number of occurrences of the rebar. Below is a screenshot of rebar object properties. See the Length and Total Length property in property value table.

length_totallength


Yesterday, I also had a discussion with Sean regarding GCI tasks. He told about interoperability task (for eg. export FreeCAD model to BRL-CAD).

Adding Length property in the rebar object – FreeCAD

Today, I introduced a new property in the rebar object of FreeCAD i.e. Length. This property calculates the total length of the rebar. The user will see this property in the property value table. This property is very useful for Bar bending schedule.

Below is the code which calculates the length of rebar:

def getLengthOfRebar(rebar):
    """ getLengthOfRebar(RebarObject): Calculates the length of the rebar."""
    base = rebar.Base
    # When rebar is derived from DWire
    if hasattr(base, "Length"):
        return base.Length
    # When rebar is derived from Sketch
    elif base.isDerivedFrom("Sketcher::SketchObject"):
        length = 0
        for geo in base.Geometry:
            length += geo.length()
        return length
    else:
        FreeCAD.Console.PrintError("Cannot calculate rebar length from its base object\n")
        return None

Dialy diary

Today, I have solved LibreHatti issue. It just took less than my 20 minutes. By reverse engineering, I easily found how to fix the issue. Today, I also learnt how to use Ajax in Django and a little bit JQuery for LuvLdh web app.

Get access_token from Django request

Given a user instance, you can get the token by doing this:

social = request.user.social_auth.get(provider='provider name')
social.extra_data['access_token']

Assuming Facebook provider:

social = request.user.social_auth.get(provider='facebook')
social.extra_data['access_token']

Dialy diary

In LuvLdh web app I used social-auth-pipeline to get extra information from Facebook API response like access_token etc. I have known that using the pipeline for getting information was not a good way but I used it in the app. I have searched it on Google that how to get access_token from Django request but I didn’t found any fruitful result. Today, I searched it on DuckDuckGo instead of Google and I amazed that DuckDuckGo gave an answer of my query in the first link.

Daily diary

Today, I figured out social-auth-pipeline in Django. With this pipeline, we can control and manipulate the flow of user request. I also designed the basic workflow of LuvLdh web app and did some magic with access token using GraphAPI.

Daily diary

Today, I helped Abhinav Handa’s to solving his problem. Actually, he wants to create a dropdown list in a header of OSM map but OSM overlapped drop-down list. When I searched it on the internet and heard new property in the CSS i.e. z-index. After using z-index then I came to know that every page rendering on the browser has at-least one layer like we use simple div tags in an HTML page then all div is under one layer. Div tag(assume as a layer) which has greater z-index value can overwrite all other div’s.

Everywhere fundamentals are same, we just trying to understand by taking some real world example.:)

Parsing functionality of IfcOpenShell in detail

The parsing functionality is a very interesting feature of IfcOpenShell-python. It enables the user to extract information of his/her interest from a .ifc file. For eg. in the below example, we will extract NominalDiameter, CrossSectionArea etc of reinforcing bar from .ifc file using python interactive shell.

In IfcOpenShell-python there are two main functions present.

  1. by_type(<argument>): This enable the user to what type of information (i.e. IfcProject, IfcRoot, IfcSlab etc.) you want to extract from .ifc file. Arguments name is same as all the entities present in IFC2x4 (http://www.buildingsmart-tech.org). For eg. if user want to extract a information of “IfcWall” then they simple put “IfcWall” as argument.
  2. is_a(): We can use this function in two different ways. For eg. if we use is_a() without any argument then it only tell that information present is belonging to which entity or if we use is_a("IfcWall") with one argrument then it will simply check whether the argument name is same or not with entity name of data present in the form of True or False.

Note: Rest of the classes, functions and there arguments name are same as present in IFC2x4. You can understand more in the below example.

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # Importing ifcopenshell                                            
>>> import ifcopenshell                                                 
>>> # Openning .ifc file using open() fuction which is present in ifcopenshell library 
>>> file = ifcopenshell.open("Slab.ifc")                                
>>> # Here we use by_type() function because we want to extract information of IfcReinforcingBar from .ifc file 
>>> rebars = file.by_type("IfcReinforcingBar")                          
>>> # All the rebars present in the .ifc file is store in rebars variable in the form of array
>>> rebars                                                              
>>> [#218=IfcReinforcingBar('3jNYnJqWb9afBZKX5CCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 1',$,'Rebar Bar:NC Rebar:53673',#201,#216,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$),
 #251=IfcReinforcingBar('3jNYnJqWb9afBZKX9CCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 2',$,'Rebar Bar:NC Rebar:53673',#250,#248,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$),
 #270=IfcReinforcingBar('3jNYnJqWb9afBZKXDCCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 3',$,'Rebar Bar:NC Rebar:53673',#269,#267,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$)]
>>> rebar = rebars[0]                                                   
>>> rebar                                                               
>>> #218=IfcReinforcingBar('3jNYnJqWb9afBZKX5CCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 1',$,'Rebar Bar:NC Rebar:53673',#201,#216,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$)
>>> # Extracting actual data of rebar. Here you will find all the list of arguments present in IfcReinforcingBar (http://www.buildingsmart-tech.org/ifc/IFC2x4/alpha/html/ifcstructuralelementsdomain/lexical/ifcreinforcingbar.htm) 
>>> rebar.NominalDiameter                                               
>>> 16.0                                                                
>>> rebar.CrossSectionArea                                              
>>> 0.000201061929829747                                                
>>> rebar.BarLength                                                     
>>> 5920.0                                                              
>>> rebar.BarRole                                                       
>>> 'NOTDEFINED'                                                        
>>> rebar.BarSurface                                                    
>>> rebar.OwnerHistory                                                  
>>> #41=IfcOwnerHistory(#38,#5,$,.NOCHANGE.,$,$,$,1488377749)           
>>> hist = rebar.OwnerHistory                                           
>>> # Using is_a() function to find the data present in hist variable is belonging to which entity
>>> hist.is_a()                                                         
>>> 'IfcOwnerHistory'                                                   
>>> # Here we check whether a data is belonging to specific entities or not
>>> hist.is_a("IfcOwnerHistory")                                        
>>> True                                                                
>>> hist.is_a("IfcWall")                                                
>>> False                                                               
>>> exit()  

Get sample IFC file Slab.ifc.

Reference:
http://academy.ifcopenshell.org/using-the-parsing-functionality-of-ifcopenshell-interactively
http://www.buildingsmart-tech.org/ifc/IFC2x4/alpha/html/ifcstructuralelementsdomain/lexical/ifcreinforcingbar.htm

Unlocking Bootloader, Flashing TWRP recovery and Custom rom on Redmi Note 3

  1. Unlocking Bootloader:
    1. Official method: Go to the developer options (Setting>About phone>7 times taps MIUI version) and enable OEM unlocking and USB debugging. Send request on http://en.miui.com/unlock/ to get permission for unlocking bootloader. After 7-10 days from when you got permission, download Mi Unlock tool on Windows and connect mobile to PC/laptop and click on the unlocking button.
    2. Unofficial method: Flash miui rom from edl mode and after that go to fastboot mode and run fastboot oem unlock-go command. Also, you can check whether the bootloader is unlocked or not by run fastboot oem device-info in fastboot mode.
  2. For more detail:

  3. Flashing TWRP recovery:
    1. Backup your all internal storage data.
    2. Download the latest TWRP recovery (https://dl.twrp.me/kenzo/).
    3. Go to the fastboot mode.
    4. Check device is connected or not. (fastboot devices)
    5. Run command fastboot flash recovery <recovery_path>. This command will flash TWRP recovery on mobile.
    6. Also run fastboot format userdata. This command will actually remove all enycrpted/normal data in the internal storage which TWRP recovery cannot read it.
    7. Then run fastboot boot <recovery_path>. This command boot your device into twrp recovery.
  4. Flashing custom roms:
    1. Download LineageOS (https://download.lineageos.org/) for Redmi note 3 (kenzo) into internal storage.
    2. Boot into TWRP recovery by pressing power button and volume up simultaneously.
    3. Then go to wipe>advanced wipe>select Dalvik/ART Cache, Data and Cache>then Swipe to Wipe.
    4. After that go to Install>select custom rom.zip>then click on Install Image.
    5. Last again Wipe only Dalvik cache and then go to reboot>system reboot.
    6. Done