Demonstrating coding abilities

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Demonstrating coding abilities

Post by yorik »

amrit3701 wrote:Tell me if any improvement will require in the UI. :)
A further improvement could be to use the special InputField widget from FreeCAD instead of QLineEdits. That widget manages units automatically, so it's handy (the user can enter for ex. '10 in' or '254 cm'

I have actually never used InputFields directly in an ui file, not sure how that works on python side. In any case, you'll need to compile the special FreeCAD widgets to be able to use them in QDesigner: https://www.freecadweb.org/wiki/Compile ... ner_plugin
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Demonstrating coding abilities

Post by amrit3701 »

yorik wrote: I have actually never used InputFields directly in an ui file, not sure how that works on python side. In any case, you'll need to compile the special FreeCAD widgets to be able to use them in QDesigner: https://www.freecadweb.org/wiki/Compile ... ner_plugin
I have made a simple prototype which will show the workflow of my proposed proposal.

1. Input values given to dialog box in the task panel.
step1.png
step1.png (214.18 KiB) Viewed 1867 times
2. After filling the user inputs values, then clicking the OK button which will produce the given below output.
step2.png
step2.png (241.13 KiB) Viewed 1867 times
Installation:
1. Download the files present in the link (https://github.com/amrit3701/FreeCAD-Reinforcement).
2. After download, open the TaskPanelStraightRebar.py file and set the path of the UI file in line number 6.
3. Create the structural element. Copy and paste the below code to create structure element.

Code: Select all

import Arch
s = Arch.makeStructure(length=1000.0,width=800.0,height=200.0)
s.Placement.Base = FreeCAD.Vector(0.0,0.0,0.0)
FreeCAD.ActiveDocument.recompute()
4. Then select the structural element, copy and paste the code present in the TaskPanelStraightRebar.py file.

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Demonstrating coding abilities

Post by amrit3701 »

yorik wrote:Ok this looks good to me...
This script touches most of what you'll need during the GSOC project
Now, I have written a program which will create U-Shape reinforcing bar by taking inputs values from the user through a dialog box.

Given below are a few screenshots of executing a program:
1. Input values are given to the dialog box present in a task panel.
ushape1.png
ushape1.png (203.89 KiB) Viewed 1798 times
2. Output produced after clicking on "Ok" button in the dialog box.
ushape2.png
ushape2.png (252.3 KiB) Viewed 1798 times
To run this program, please follow all the installation steps which I have shared in my previous email.
https://forum.freecadweb.org/viewtopic. ... 10#p169571

Source code:
https://github.com/amrit3701/FreeCAD-Reinforcement

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Demonstrating coding abilities

Post by bernd »

Is this script intended to run with FreeCAD 0.17.x ?
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Demonstrating coding abilities

Post by bernd »

If I do reinforcement for a column foundation I would use more rebars right under the column. How would I input such rebars with your task panel?
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Demonstrating coding abilities

Post by amrit3701 »

bernd wrote:Is this script intended to run with FreeCAD 0.17.x ?
Yes, all the above scripts are intended to run with FreeCAD 0.17.x.

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Demonstrating coding abilities

Post by amrit3701 »

bernd wrote:If I do reinforcement for a column foundation I would use more rebars right under the column. How would I input such rebars with your task panel?
Are you talking about reinforcement in a pedestal?

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Demonstrating coding abilities

Post by amrit3701 »

yorik wrote:Ok this looks good to me...
This script touches most of what you'll need during the GSOC project
The current reinforcement system in FreeCAD uses sketch (which is in 2D) and from sketch we will create any planar rebar. I have read the given below thread, in which there is a way to creating a square helical shape (non-planar) rebar using part workbench.
https://forum.freecadweb.org/viewtopic.php?t=6688

Is there any way to create non-planar rebars (i.e stirrups) from sketch directly?

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Demonstrating coding abilities

Post by yorik »

Not from sketches, because sketches can only be strictly planar. But rebars can also be made from any kind of wire, and wires don't need to be planar.
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Demonstrating coding abilities

Post by amrit3701 »

yorik wrote:Not from sketches, because sketches can only be strictly planar. But rebars can also be made from any kind of wire, and wires don't need to be planar.
Yes, any wire can become a rebar. The _Rebar class and my scripted object (https://forum.freecadweb.org/viewtopic. ... 62#p167910) use the same approach. I tried makeRebar() function for reinforcing non-planar rebars and this works fine. First, I defined the shape of the wire (like Draft.makeLine(FreeCAD.Vector(x1,y1,z1),FreeCAD.Vector(x2,y2,z2))) and then pass this object and the structural element to makeRebar() function which will create reinforcement in the structural element.

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
Post Reply