python API Power users hub

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: python API Power users hub

Post by vocx »

dulouie wrote: Thu Feb 07, 2019 6:18 pm Any progress for updated doc?
I've build my own doxygen doc with

Code: Select all

make DevDoc
but i need a clear python documentation.
How can i generate my own sphinx python doc?
It seems that there isn't enough Python documentation because Doxygen is not very good at displaying Python's docstrings. The Python source code isn't very well documented either. So the source code should be commented much better before trying to generate the documentation.

Previously, Yorik mentioned that at some point they attempted to use Sphinx, but since Doxygen works better for C++, that attempt was sort of abandoned. The Sphinx files are still in the source code https://github.com/FreeCAD/FreeCAD/tree ... Doc/sphinx You may wish to inspect these files to see what can be salvaged.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
shadybob
Posts: 18
Joined: Wed Jun 06, 2018 5:50 pm

Re: python API Power users hub

Post by shadybob »

It seems like lately everything is outdated on the power users hub. I'm trying to learn to write scripts, and I recently tried the example line drawing function found here: https://www.freecadweb.org/wiki/Line_drawing_function.

Followed all the directions as best I could (exactly as laid out), but when I do the import example, and then execute example.line() and click my mouse 2 times, I do get a shape in the tree view, but there is no line to be seen. After I hit enter on example.line(), I get this response before clicking any mouse button locations: <exercise.line object at 0x0000021E9473E668>, then I get
>>> # Gui.Selection.addSelection('Unnamed','Shape')
after cllicking the mouse twice. Can anyone tell me why this isn't working?

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19358 (Git)
Build type: Release
Branch: master
Hash: 9e736095187450812e16ff9b92b6839e578f5506
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: python API Power users hub

Post by Syres »

shadybob wrote: Tue Feb 11, 2020 9:36 pm after cllicking the mouse twice. Can anyone tell me why this isn't working?
Back in FreeCAD version 0.17 I believe the Part.Line command was changed to Part.LineSegment, therefor change line 17 in exercise.py from:

Code: Select all

                l = Part.Line(self.stack[0],self.stack[1])
to:

Code: Select all

                l = Part.LineSegment(self.stack[0],self.stack[1])
and it should appear on the screen!!

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19503 (Git)
Build type: Release
Branch: master
Hash: bb189d540cb958e63af44347a244188fae217e93
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
shadybob
Posts: 18
Joined: Wed Jun 06, 2018 5:50 pm

Re: python API Power users hub

Post by shadybob »

Syres wrote: Tue Feb 11, 2020 9:55 pm
shadybob wrote: Tue Feb 11, 2020 9:36 pm after cllicking the mouse twice. Can anyone tell me why this isn't working?
Back in FreeCAD version 0.17 I believe the Part.Line command was changed to Part.LineSegment, therefor change line 17 in exercise.py from:

Code: Select all

                l = Part.Line(self.stack[0],self.stack[1])
to:

Code: Select all

                l = Part.LineSegment(self.stack[0],self.stack[1])
and it should appear on the screen!!
Thank you! That did the trick! How do we update the wiki page?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: python API Power users hub

Post by vocx »

shadybob wrote: Tue Feb 11, 2020 10:38 pm Thank you! That did the trick! How do we update the wiki page?
Yes, the power user and developer documentation is quite outdated. How to learn? Follow the documentation, then look at the actual source code of the program. Read the forums, and read the code of macros and external workbenches. It's a messy process, really; there is no straight path to learn.

How to get wiki editing permissions
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply