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.