Civil engineering feature implementation (Transportation Engineering)

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
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

HakanSeven12 wrote: Tue Apr 09, 2019 7:10 pm During initialization the error module 'Resources' has no attribute '__file__' occurred in C:\Users\Hakan\Desktop\FreeCAD 0.19\Mod\Transportation\InitGui.py
Ok, I think requires more Python expertise than I possess. StackOverflow wasn't any help, anyway. :)

I noticed you have '__path__' available. On my system, it's the same value as '__file__' - it points to the local path of the Resources directory. Does that point to the correct file location? If so, I'll use that instead (and hope it doesn't break for anyone else).
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

triplus wrote: Wed Apr 10, 2019 10:22 pm P.S. As for the new import style modules. Initially the plan was to put them in Ext folder. But somehow they still ended up working, when located in Mod folder and installed through an Addon manager. Therefore think of it you are still a pioneer, going down that road. ;) Likely it depends, on the complexity of the module. If there is a rather small amount of .py files involved and all dependencies are provided in standard Linux, macOS and Windows FreeCAD binaries. For that i don't feel you need new import style module. Unless we decide at some point and depreciate the current (i guess the old) way of doing things.
I'm going to use the new style since I'm refactoring everything anyway. Besides, there's non-standard dependencies.

Plus, I really like the new style - It provides some strong, clear guidance on the basic structure of a workbench and I really think it ought to be the default. I really think it would be more helpful, though, to articulate what files should go where. For example, I see in some of the 'new-style' workbenches that there are files / folders outside of the freecad folder, whereas in the two you linked to, everything is within it. I can sort some of that out myself, but it would be better to have guidance.

Also, I tried a local 'pip install' of my workbench from a separate path well outside of the FreeCAD local application paths. Using a basic setup.py, pip seemed to install it quite happily, though I've no idea where.

Anyway, I'm going to try to sort out how setup.py / setuptools works, but a fully working example of how to make a workbench 'pip installable' would be useful as well. I really like the idea of being able to manage FreeCAD modules via pip, though I wonder if that may prove difficult to manage with our current addon manager scheme.

Anyway, I don't expect you to have all the answers, and I certainly have no clue, myself. But just thought I'd add my comments. :)
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
HakanSeven12
Veteran
Posts: 1481
Joined: Wed Feb 06, 2019 10:30 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by HakanSeven12 »

Code: Select all

During initialization the error module 'Resources' has no attribute '__file__' occurred in C:\Users\Hakan\Desktop\FreeCAD 0.19\Mod\Transportation\InitGui.py
Please look into the log file for further information
I fix it. In "freecad-transportation-wb/Project/Commands/NewProjectCmd.py" changed this

Code: Select all

class NewProject():

    icon_path = os.path.dirname(Resources.__file__)

    resources = {
'Pixmap' : icon_path + '/icons/workbench.svg',
to this

Code: Select all

class NewProject():

    icon_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

    resources = {
        'Pixmap'  : icon_path + '/Resources/icons/workbench.svg',
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

HakanSeven12 wrote: Sun Apr 14, 2019 7:39 pm I fix it. In "freecad-transportation-wb/Project/Commands/NewProjectCmd.py"
I've actually been rewriting things a bit, so if you want to try the latest, clone https://www.github.com/joelgraff/freecad.trails into your Mod directory. I don't think it quite works because I forgot to push my latest changes... so it won't be until tomorrow that it'll likely be good.

Anyway, I'd like to see if that makes a difference. In any case, I think using the __path__ attribute instead of __file__ is what hould be done - that should work for you as well.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

HakanSeven12 wrote: Sun Apr 14, 2019 7:39 pm I fix it. In "freecad-transportation-wb/Project/Commands/NewProjectCmd.py" changed this
I fixed issues in freecad.trails. Try cloning the workbench into your Mod folder and give it a try. It'll show up in FreeCAD with a "T" in a red box as an icon.

As a test for importing LandXML, I suggest the following:

1. Open the Mod/freecad.trails/freecad/trails/resources/data/alignments folder (I have to move that up a few levels!)
2. Open the file "SugarGroveRd.FCStd". You should see an aerial map with a horizontal alignment overlaid on it.
3. Switch to the "Trails" workbench and type "CTRL+Shift+A" to start the alignment importer task.
4. Click on the ellipsis "..." button to import an XML. Hopefully, it will open to the same data folder from above.
5. Select "SugarGroveRd.xml" as the file. It should populate the form with data from the file. You can use the drop down to view the data of different alignments (there should be three)
6. Click "OK". It should import the three alignments and they ought to match closely to what's already in the document.

You can also try saving and re-opening it, since I'm now serializing the LandXML data directly in the FCStd, rather than storing it as properties of objects. This will make it much easier to add new types of data (profiles, surfaces, etc) as well as export LandXML for use in other applications.

Anyway, I expect you'll have problems, but I'd really appreciate it if you gave this a shot and let me know how it went.

EDIT: I should also mention, I'm maintaining a 'dev' and 'master' branch. Right now, they're both in sync, but you'll want to pull from 'dev' for my latest changes. That said, I occasionally push broken code to 'dev', so beware. :)
Last edited by Joel_graff on Mon Apr 15, 2019 1:10 pm, edited 1 time in total.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by kisolre »

Joel_graff wrote: Sun Apr 14, 2019 7:43 pm
HakanSeven12 wrote: Sun Apr 14, 2019 7:39 pm I fix it. In "freecad-transportation-wb/Project/Commands/NewProjectCmd.py"
I've actually been rewriting things a bit, so if you want to try the latest, clone https://www.github.com/joelgraff/freecad.trails into your Mod directory. I don't think it quite works because I forgot to push my latest changes... so it won't be until tomorrow that it'll likely be good.

Anyway, I'd like to see if that makes a difference. In any case, I think using the __path__ attribute instead of __file__ is what hould be done - that should work for you as well.
You should add the Git link to your first post to be easy to find.
Also with

Code: Select all

OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16474 (Git)
Build type: Release
Branch: master
Hash: 746997e48411f22a150b95b6fdbb9b02cbe741d5
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Bulgarian/Bulgaria (bg_BG)
I get the following error:

Code: Select all

Init: Initializing freecad.trails
During initialization the error No module named 'freecad.trails.project.xml' occurred in freecad.trails
--------------------------------------------------------------------------------
Traceback (most recent call last):
  File "<string>", line 145, in InitApplications
  File "E:\New Download\FreeCAD\_FreeCAD_Conda\bin\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\init_gui.py", line 30, in <module>
    from .project.commands \
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\project\commands\import_alignment_cmd.py", line 29, in <module>
    from ..tasks.alignment.import_alignment_task import ImportAlignmentTask
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\project\tasks\alignment\import_alignment_task.py", line 35, in <module>
    from . import import_xml_subtask #, ImportCsvSubtask
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\project\tasks\alignment\import_xml_subtask.py", line 28, in <module>
    from ...xml.alignment_importer import AlignmentImporter
ModuleNotFoundError: No module named 'freecad.trails.project.xml'
and with

Code: Select all

OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16474 (Git)
Build type: Release
Branch: master
Hash: 746997e48411f22a150b95b6fdbb9b02cbe741d5
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Bulgarian/Bulgaria (bg_BG)
I get

Code: Select all

During initialization the error No module named xml.alignment_importer occurred in freecad.trails
--------------------------------------------------------------------------------
Traceback (most recent call last):
  File "<string>", line 145, in InitApplications
  File "E:\New Download\FreeCAD\_FreeCAD_x64\bin\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\init_gui.py", line 30, in <module>
    from .project.commands \
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\project\commands\import_alignment_cmd.py", line 29, in <module>
    from ..tasks.alignment.import_alignment_task import ImportAlignmentTask
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\project\tasks\alignment\import_alignment_task.py", line 35, in <module>
    from . import import_xml_subtask #, ImportCsvSubtask
  File "C:\Users\Wivern\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\project\tasks\alignment\import_xml_subtask.py", line 28, in <module>
    from ...xml.alignment_importer import AlignmentImporter
ImportError: No module named xml.alignment_importer
Last edited by kisolre on Mon Apr 15, 2019 1:19 pm, edited 1 time in total.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

kisolre wrote: Mon Apr 15, 2019 1:10 pm You should add the Git link to your first post to be easy to find.
Noted and updated. Good idea. :)
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by kisolre »

Joel_graff wrote: Mon Apr 15, 2019 1:14 pm Noted and updated. Good idea.
Just noticed that you actually have that in your signature... not easy to spot.
Also check my previous post... I edited it with some errors parallel to your reply.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

kisolre wrote: Mon Apr 15, 2019 1:22 pm Just noticed that you actually have that in your signature... not easy to spot.
Also check my previous post... I edited it with some errors parallel to your reply.
It wasn't easy to spot because I just added it to my signature - it wasn't there before. :)

Also, I should note that I'm only developing for Python3. Given that Py2 is gone with the next release I'm not going to spend time developing for it. Thus, your Py2.7 install is simply not going to work.

As for the Conda build, that's really odd.

The path is correct - freecad.trails.project.xml. I'm sure you'll find it if you go looking. The __init__.py file is there, too.

It might be something obvious - I'm no expert in python modules and imports. But I've also never run a Conda build, so it might be something related to that (though it shouldn't be).

I'll try to test a Conda build and see what happens.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

kisolre wrote: Mon Apr 15, 2019 1:10 pmAlso with
I just tested the latest 0.19 Win Conda build on a Win7 machine. It seems to work fine - I cannot reproduce your error.

Try pulling the latest from my github - master or dev branch is fine as they're both in sync atm.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Post Reply