[SOLVED] pyrate Installed but Does Not Show up as WB Option

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
triplus
Posts: 8786
Joined: Mon Dec 12, 2011 4:45 pm

Re: pyrate Installed but Does Not Show up as WB Option

Postby triplus » Sun Dec 23, 2018 12:57 am

looo wrote:
Thu Dec 13, 2018 8:35 pm
triplus wrote:
Thu Dec 13, 2018 11:05 am
I get that message too, but is still works. This module is using the new import style and the produced message is therefore normal. Inside .FreeCAD/Mod folder, there should be a pyrate folder, containing some files and folders.
I wondered how this can work as this wasn't by design. But it seems the new-style fully works with the addon-manager and this is why:
1. The old way to load modules adds every directory in .FreeCAD/Mod to the sys.path
2. Now that the base-directory is added to sys.path everything in the .FreeCAD/Mod/<module>/freecad is accessible as a namespace-package and is initialized by the new way to load workbenches/modules.

So the addon-manager should fully work for new-style modules. Feature or bug?
Indeed. Maybe it's trying to suggest all FreeCAD modules still belong in the Mod directory? ;) Addon manager therefore to continue to work just fine. And pip approach being useful as an additional option/way to get modules/dependencies. Especially for modules relying on dependencies not provided by default.
The problem seems to be that only one name-space-package installed with the add-on-manager works.
Out of all the possible problems a namespace issue. Argh. ;)
Ok, I found the problem. Please add this to all freecad/__init__.py files in ~/.FreeCAD/Mod:
More advance capabilities and i guess more in-depth knowledge needed!
joha2
Posts: 243
Joined: Tue Oct 11, 2016 9:48 pm

Re: pyrate Installed but Does Not Show up as WB Option

Postby joha2 » Sat Dec 29, 2018 4:19 pm

Hey guys,

sorry for my long response time! I added the patch from looo to my master branch and submitted a PR to mess42 master branch. Therefore I hope the fix will be soon be integrated. Thanks looo for your efforts!

Best wishes
Johannes
joha2
Posts: 243
Joined: Tue Oct 11, 2016 9:48 pm

Re: pyrate Installed but Does Not Show up as WB Option

Postby joha2 » Thu Jan 03, 2019 7:46 am

Happy new year!

The PR was accepted by mess42, so the behaviour should be fixed now.

Best wishes
Johannes
cflin
Posts: 50
Joined: Sun May 14, 2017 10:21 pm

Re: pyrate Installed but Does Not Show up as WB Option

Postby cflin » Sat Jan 19, 2019 6:53 am

@yoha2: Thank you. I saw a posting on the github page for pyrate, mentioning the same issue. Somebody suggested that the 'ruamel.yaml' module be installed via pip. I did that and the problem went away. I cannot find that posting now.

What puzzles me is that there was no problem around the middle of December and then the problem recurred. But, whatever. It is working now. I wish the documentation were better. Anyway, I will correct the initial title to mark this issue as resolved.
looo
Posts: 2948
Joined: Mon Nov 11, 2013 5:29 pm

Re: [SOLVED] pyrate Installed but Does Not Show up as WB Option

Postby looo » Sun Feb 10, 2019 11:01 am

joha2 wrote:
Thu Jan 03, 2019 7:46 am
Happy new year!
Hello joha2, finally I have installed your workbench in freecad environment with all the necessary deps. Now I wanted to make some test, but have no idea how to begin. Do you have a simple example or a short guide how to start?

In the long run it would be nice to have a conda-package of pyrate, as pyrate has quite some difficult dependencies... I created one and uploaded to the freecad channel.

Please see here for more information:
https://github.com/mess42/pyrate/pull/121
please help with my conda-packaging efforts: https://liberapay.com/looooo/
cflin
Posts: 50
Joined: Sun May 14, 2017 10:21 pm

Re: [SOLVED] pyrate Installed but Does Not Show up as WB Option

Postby cflin » Sun Feb 10, 2019 6:46 pm

Now I wanted to make some test, but have no idea how to begin. Do you have a simple example or a short guide how to start?
I second that. Some examples would be really helpful.

@looo: I am a bit confused. If pyrate installs on FC18, that means it is dependent on Python 2.7, doesn't it? So, shouldn't the conda package also depend on Python 2.7? Therefore, when you create a conda environment for pyrate (or any Python virtual environment), shouldn't you also declare the interpreter to be Python 2.7?

Thank you for your work!
looo
Posts: 2948
Joined: Mon Nov 11, 2013 5:29 pm

Re: [SOLVED] pyrate Installed but Does Not Show up as WB Option

Postby looo » Mon Feb 11, 2019 9:21 am

cflin wrote:
Sun Feb 10, 2019 6:46 pm
Now I wanted to make some test, but have no idea how to begin. Do you have a simple example or a short guide how to start?
I second that. Some examples would be really helpful.

@looo: I am a bit confused. If pyrate installs on FC18, that means it is dependent on Python 2.7, doesn't it? So, shouldn't the conda package also depend on Python 2.7? Therefore, when you create a conda environment for pyrate (or any Python virtual environment), shouldn't you also declare the interpreter to be Python 2.7?

Thank you for your work!
Yes sometimes the python world is confusing :D
Currently we are working on getting FreeCAD ready with python3. Actually we are providing already builds for python3 for quite some time. So FreeCAD does not depend on python2.7 anymore.

We are also providing builds of freecad via conda. These builds are done weekly for osx64, win64, linux64. The package can be installed like any other conda-package into a virtual-env. This way it's possible to run different FreeCAD versions side by side in different environments.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
joha2
Posts: 243
Joined: Tue Oct 11, 2016 9:48 pm

Re: [SOLVED] pyrate Installed but Does Not Show up as WB Option

Postby joha2 » Thu Mar 21, 2019 8:38 pm

cflin wrote:
Sun Feb 10, 2019 6:46 pm
Now I wanted to make some test, but have no idea how to begin. Do you have a simple example or a short guide how to start?
Sorry for my late reply! There exist some simple examples in the demos sub directory of the pyrate repo. Although the Gui interface is broken since the last refactor.Therefore there is no fc guide to pyrate. We're developing some more or less general interface to communicate with the core classes, but we're still at the beginning and every help with their design would be greatly appreciated.

Best regards
Johannes
joha2
Posts: 243
Joined: Tue Oct 11, 2016 9:48 pm

Re: [SOLVED] pyrate Installed but Does Not Show up as WB Option

Postby joha2 » Fri Mar 22, 2019 7:46 am

cflin wrote: I second that. Some examples would be really helpful.
looo wrote: Do you have a simple example or a short guide how to start?
One of the easiest examples to set up an optical system is:

Code: Select all

from pyrateoptics import build_rotationally_symmetric_optical_system
from pyrateoptics import draw
from pyrateoptics import raytrace
components = [(100, 0, 20, 1.5, "lens1front", {"is_stop": True}),
                          (-100, 0, 5, None, "lens1back", {}),
                          (0, 0, 100, None, "image", {})]
# (radius, cc, thickness, material, name, options)
(s, seq) = build_rotationally_symmetric_optical_system(components, name="my_opticalsystem")
r = raytrace(s, seq, 11, {"radius": 9.0})
draw(s, r) # show system + rays
It is stolen from the README.md and provides a lens with a refractive index of 1.5 with front and backside curvature radius of 100 mm. (As you can see in the components definition.) Further it generates the optical system, performs a raytrace of 11 rays in an xy fan and draws system together with the rays. The drawing function needs Matplotlib which is a good compromise if you don't want to use a GUI like FreeCAD.

In s there are several variables which provide access to the lens data. For e.g. modifying the tilt of on surface in comparison to another, just use:

Code: Select all

s.elements["stdelem"].surfaces["lens1front"].rootcoordinatesystem.tiltx.setvalue(0.1) # tilt first surface
s.rootcoordinatesystem.update() # update all coordinate systems
r = raytrace(s, seq, 21, {"radius": 9.0}) # trace again
draw(s, r) # show system + rays
I am not sure whether this code can be executed from the FreeCAD console, but on a plain python2.7 and python3.x console it should work.

Hope this helps for a first insight.

Best wishes
Johannes

(PS: Notice that the raytracing works, but some details are not tested and ready for production use, therefore do not rely too much on the results.)
cflin
Posts: 50
Joined: Sun May 14, 2017 10:21 pm

Re: [SOLVED] pyrate Installed but Does Not Show up as WB Option

Postby cflin » Wed Apr 17, 2019 5:27 am

@joha2: Thank you for the examples! I installed pyrate on my anaconda distribution and ran the first example just fine. I want to be Zeemax-free!

Anyway, I have some naïve questions: The conda channel which holds pyrate is 'freecad'. Conda's 'freecad' channel also shows FreeCAD itself available! How does conda's FreeCAD differ from FreeCAD18 I install through the apt-get repository for Ubuntu? You have been saying that pyrate's GUI is currently not operational, yet your pyrate example I ran in conda displayed the graphics (optical schematic of the intended system) just fine and, since it was run from inside conda, I doubt pyrate knew anything about my FreeCAD18 and 17 that have been installed via apt-get. I love the conda environment because it takes care of a gazillion compatibility issues between the many different libraries I use. Is there any advantage to using anaconda's version of FreeCAD as far as pyrate is concerned?

FreeCAD18 (and 17, I guess) is, unfortunately, still based on Python2, but anaconda's pyrate is Python3, isn't it? If so,then how can pyrate run inside the FreeCAD environment?