Dev logs of Rebar Addon for FreeCAD - GSoC project

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
Site Admin
Posts: 11845
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby yorik » Mon Jun 19, 2017 2:35 pm

Ok I commented on IRC and on the PR.

Regarding adding your new features to Arch, I would suggest the following:

1) We add your repo to the the FreeCAD addons repo. You should fill the "description" field on your github repo so it appears on the addon manager
2) Your scripts (straightrebar, ushaperebar, etc) must become FreeCAD commands (a toolbar button and/or menu item). Making such a command is easy, it's basically a class like this:

Code: Select all

class MyTool:

    def GetResources(self):
        return {'Pixmap'  : ':/icons/someIcon.svg',
                'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Rebar_Straight", "My Tool"),
                'ToolTip' : QtCore.QT_TRANSLATE_NOOP(Arch_Rebar_Straight", "Explanantion of what my tool does")}
        # Arch_Rebar_Straight above must be the same name as used in "addCommand" below

    def IsActive():
        # this is optional but always good
        if FreeCADGui.ActiveDocument:
            return True
        else:
            return False

    def Activated(self):
        # this is executed when the tool has been invoked (toolbar button or menu item has been pressed)
        # ex.
        import StraightRebar
        StraightRebar.doSomeStuff()

FreeCADGui.addCommand('Arch_Rebar_Straight',MyTool())
3) I suggest you add all those GUI commands/tools in a separate file (ex. RebarTools.py)
4) That file should also have a function that returns all command names that the module adds, ex: ["Arch_Rebar_Straight","Arch_Rebar_UShape"]
5) Once you have that file, I'll add some code to Arch to try to import it (try: import RebarTools).
6) If the import succeeds, it means your stuff is present. Then the Arch module can grab a list of the new commands with the function from point 4)
7) Instead of the current rebar button, it will display a drop-down tool with all the different tools that you have

I think this will allow you to keep working without the hassle to submit pull requests all the time, and when you are ready for a big merge, there will be almost no modification needed to have your stuff merged in Arch.

What do you think?
User avatar
amrit3701
Posts: 278
Joined: Mon Jun 13, 2016 5:37 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby amrit3701 » Tue Jun 20, 2017 4:46 pm

yorik wrote:
Mon Jun 19, 2017 2:35 pm
I think this will allow you to keep working without the hassle to submit pull requests all the time, and when you are ready for a big merge, there will be almost no modification needed to have your stuff merged in Arch.

What do you think?
Thanks for the reply. :) Yes, sending PR to FreeCAD on a small change is also a bit difficult for me.

As I shared my TODO list in this thread (https://forum.freecadweb.org/viewtopic. ... 60#p176520) and I have completed all tasks (present in my TODO list). I think reinforcement of Straight and U-Shape rebar is almost completed and presently I am working on a task which you have shared in your previous post.

Here, you can also see my development logs: https://brlcad.org/wiki/User:Amritpal_singh/GSoC17/logs

Regards,
User avatar
yorik
Site Admin
Posts: 11845
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby yorik » Wed Jun 21, 2017 8:14 pm

Okay now Amritpal's module is available from the FreeCAD addons repo (it's called "Reinforcement"). When it is installed, the Arch WB will now detect it on load, and add its tool under the current Rebar tool (later on I think we can switch the order and leave the current one as the last one).

I just tested the 2 currently available tools, things begin to work very well, bars stay editable with the same dialogs after creation, etc. Congrats Amritpal, this is very good work so far.

One little detail: I would remove the OK button from your dialog, and instead use the built-in one from the task panel system. I think you just need to add the Ok button to your getStandardButtons function: return int(QtGui.QDialogButtonBox.Close+QtGui.QDialogButtonBox.Ok). I think there is nothing else to change in your code. Maybe you can use Cancel instead of Close too, seems more logical.

One small bug I found too, when creating a bar, everything works ok, but when editing it afterwards, the "ok" button doesn't do anything (the dialog is not closed and the rebar is not changed).
User avatar
amrit3701
Posts: 278
Joined: Mon Jun 13, 2016 5:37 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby amrit3701 » Thu Jun 22, 2017 12:27 pm

yorik wrote:
Wed Jun 21, 2017 8:14 pm
Okay now Amritpal's module is available from the FreeCAD addons repo (it's called "Reinforcement"). When it is installed, the Arch WB will now detect it on load, and add its tool under the current Rebar tool (later on I think we can switch the order and leave the current one as the last one).

I just tested the 2 currently available tools, things begin to work very well, bars stay editable with the same dialogs after creation, etc. Congrats Amritpal, this is very good work so far.
Thanks.
yorik wrote:
Wed Jun 21, 2017 8:14 pm
One little detail: I would remove the OK button from your dialog, and instead use the built-in one from the task panel system. I think you just need to add the Ok button to your getStandardButtons function: return int(QtGui.QDialogButtonBox.Close+QtGui.QDialogButtonBox.Ok). I think there is nothing else to change in your code. Maybe you can use Cancel instead of Close too, seems more logical.
Done.
yorik wrote:
Wed Jun 21, 2017 8:14 pm
One small bug I found too, when creating a bar, everything works ok, but when editing it afterwards, the "ok" button doesn't do anything (the dialog is not closed and the rebar is not changed).
Astonished. I have tested my scripts on different OS (Linux and Windows) and on both OS it works well. All functions working as desired. Can you tell output error of FreeCAD console?

Regards,
User avatar
yorik
Site Admin
Posts: 11845
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby yorik » Wed Jun 28, 2017 7:06 pm

I drew some icons for the two commands you have already, what do you think?
straight rebar.svg
(18.39 KiB) Downloaded 77 times
ushaped rebar.svg
(18.31 KiB) Downloaded 126 times
User avatar
chakkree
Posts: 289
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby chakkree » Thu Jun 29, 2017 5:00 am

Test create U-shape rebar add-on from dialog.
I've some question.
Can I create set of rebar by python script?

FootingRebar.png
FootingRebar.png (499.47 KiB) Viewed 705 times
-------------------
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11472 (Git)
Build type: Release
Branch: master
Hash: a32972ef2f62eaffe550cccc9d1a9ac7d000b4dd
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Attachments
TestRebarAddOn.FCStd
(29.64 KiB) Downloaded 19 times
User avatar
chakkree
Posts: 289
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby chakkree » Thu Jun 29, 2017 5:07 am

Some problem found.
The rebar can not move with the host.

TestTranslate.png
TestTranslate.png (514.52 KiB) Viewed 701 times
TestRotate.png
TestRotate.png (510.57 KiB) Viewed 701 times
---------------------
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11472 (Git)
Build type: Release
Branch: master
Hash: a32972ef2f62eaffe550cccc9d1a9ac7d000b4dd
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
User avatar
yorik
Site Admin
Posts: 11845
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby yorik » Thu Jun 29, 2017 4:15 pm

I think each of these tools has a corresponding make...() function that can be used from python.

About the rebar not moving with the host, this is part of a bigger issue, and there would be several ways to attack the problem. One way to attack the problem could be to add a function to every Arch object that if its Placement changes, all of its children placements change too.

But there might be problems with this idea, some of the object's children we might not want that they move (for ex. the base sketch of an object). One way to address that, is to move only the children that have a MoveWithHost property, and that property is set to True.

But there is a more interesting mechanism, which is that a sketch (or any other 2D object) stays attached to a face of its Support object. So there would be no need to change any placement. That could work for Rebars and Windows, for example. The problem is that this mechanism creates circular dependencies in Arch objects. But I thought of a way to get rid of the circular dependency entirely, which is: instead of having the host object keep the relationship to its children, let's have the children keep the relationship to which host it is part of. This would bring a little bit of hassle (a wall, for example, would need to "query" its children each time to find out which windows are included in it), but I think it's worth it. It would allow to use all kinds of attachment systems the FreeCAD has (external edges in sketches, etc) properly.

We could try that with Rebar and Window objects, I think at the moment those are the only two that have circular dependency problems.
ickby
Posts: 2959
Joined: Wed Oct 05, 2011 7:36 am

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby ickby » Thu Jun 29, 2017 5:54 pm

I have no idea about the problem at hand, just want to note that "moving things together" can also be achieved with making the parent a geofeaturegroup. This does not change the child's placement directly on move, but as it really contains the child's in its coordinate system it moves them still globally (like app part or body but without the origin objects). Maybe that's helpful.
User avatar
amrit3701
Posts: 278
Joined: Mon Jun 13, 2016 5:37 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby amrit3701 » Fri Jun 30, 2017 2:19 pm

yorik wrote:
Wed Jun 28, 2017 7:06 pm
I drew some icons for the two commands you have already, what do you think?
Thanks for that. I have embedded your icons in rebars drop-down list.

I have created stirrup(non-planar) with my script(https://github.com/amrit3701/FreeCAD-Re ... Stirrup.py). Here are the screenshots:
stirrup1.png
stirrup1.png (301.82 KiB) Viewed 627 times
stirrup2.png
stirrup2.png (178.88 KiB) Viewed 627 times
@all
Please try to test my code and give comments.

Regards,