couple of questions

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: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: couple of questions

Post by yorik »

jriegel wrote:We inteded the macro recording for people which use FreeCAD and for them a macro recording
is a good tool to get here feet wet in python and FreeCAD programming.
Yes, exactly!
The idea I had is that, if I could decide what to record, for example: I have a tool in the Draft module to draw a line. But it's complex, full of interactions, etc. It wouldn't be practical to record everything that command does. The ideal would be, at the end of the Line command, a simple one-line command would be recorded in the macro, such as "Draft.Line((x,y,z),(x,y,z))" or something like that. A user could easily define custom objects with macros... Imagine that one could even make a tutorial with a macro, a bit like the "instructor" in sketchup, or like in games ("now try selecting all your units! Excellent! You are now ready for the battle!") that would be sensible to what the user does! Really, I liked much. Very powerful mechanism.

Yorik
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: couple of questions

Post by yorik »

jriegel wrote:you think of something and Werner has already implemented it!
I wonder if it wouldn't be safer to hide Werner, before Autodesk comes and hires him for some billions of dollars and a house on a pacific island...
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: couple of questions

Post by jriegel »

;)
Hopfully not! But maybe its like in my case. Working for FOSS is so much more fun!

Cheers Jürgen
Stop whining - start coding!
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

About macro recording

Post by yorik »

Hi there!

I noticed that the macro system changed, it now records every python command issued.
Unfortunately it breaks a bit the draft module... I made all drawing tools subclasses of a same generic drawing tool, it optimized much the code. But that parent class is not found anymore when executing the tool... (Just try drawing something with the draft module). I could solve that inporting * from Draft I think, but that wouldn't be very elegant... Any other idea?

Another thing I'm thinking of: Recording every python command will in fact recreate the tool inside the macro. Which is not what you would want in most of the cases. For example you have a tool to create some complex shape. What you want to record in the macro is the complex shape made with the tool, not to redo all the steps needed to recreate the shape everytime you run the macro, what do you guys think?

What about having a way for a tool to decide what will be stored as macro? A bit like the transaction system: You open the transaction, define what will be stored, and commit. What if we had some Document.doMacroCommand() that we could give a string to, that would be saved if a macro is being recorded? Of course, someone could store a string that wouldn't execute correctly, but that's always a problem with python...

Then you could let's say record a macro, draw a line from point 1 to point 2, then stop macro recording, and then, next time you execute it, it would draw a line from p1 to p2, not ask you to draw a new line. What do you think?

Yorik
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: couple of questions

Post by wmayer »

Hi Yorik,

this was more or less only an experiment to see whether it's possible to record all the Python commands. It was not intended causing more problems than solving :)

I see it's a general problem to record only the Python code from inside the Activated method because it often depends on certain circumstances like imported modules, parent classes, ... This often makes the recorded code nearly unusable.

Moreover I'm not sure any more whether it makes sense to record Python code at all because the code is explicitely written somewhere in a Python file and everybody is able to have a look on the code. Thus, it's a little bit absurd to record that code again.

For the moment it's best to deactivate this feature again.

Cheers,
Werner
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: couple of questions

Post by wmayer »

For the moment it's best to deactivate this feature again.
Said and done ;-)
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: couple of questions

Post by yorik »

You know, I think the macro system is very useful, even if, from a programmers point of view, it is double use. It is true that why would you record a macro if you can write a script yourself, or copy from somewhere. But I think of several points:
- most people who come here and look at freecad don't know how to script
- most of them don't see very well the full potential of freecad
- what freecad is mostly lacking is end-user tools
- creating a tool with a macro is incredibly easy, and 100% GUI, with, icons, etc... Perfect for users! Maybe with a bit more doc on the wiki (with examples), people would start making some simple tools...
- this makes the whole freecad more interesting... Like if it existed a fourth zone, between user and power user, which would be the zone of the "customizer"... This is really something (else) excellent about freecad I think, if you think that one of the main characteristics of professional CAD programs is their complexity, then that complexity is basically "supported" in freecad. There are already several ways to obtain a same result, it's great!
I hope you all will be impressed by my professional argumentation!
Cheers
Yorik
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: couple of questions

Post by jriegel »

Very impressed!!! ;)

Your totally right, I think also the script API will the main source of new features in the future of FreeCAD.
I thought also a lot about how to transport that to the people! Werner did this fantastic thing with pythonDoc
to access the inline help of python and our types in FreeCAD. Maybe we need some HowTo articles. Or
an python programmer guide....

But the best documentation was always for me your Draft module. There you do nearly everything one could do
with FreeCAD and Python!

Jürgen
Stop whining - start coding!
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

Re: couple of questions

Post by malinand »

Hello,

I would like to jump into this discussion, if you don't mind ;)

I am evaluating FreeCAD for few weeks and very impressed by the concept. It looks like I'm goint to use it for long time. Set of tools (OpenCascade and Open Inventor in one package with Python scripting) is exactly what I was looking for.

I would like to support Yorik and emphasize some points;
- lack of end-user tools is natural for the open source CAD or CAE. So scripting and macro possibilities are very important for end users to interface with tools they already have
-Python interpreter with interactive help is extremely useful. Duplicating script command in interpreter window is perfect learning tool.
-Implementing Draft workbench as Python script is perfect way to show expansion possibilities.

What I was missing as the user:
-Highlight of selected lines. This is significant limiting factor of Draft tool usage.
-switching between documents using tabs work, but clicking on documents in the tree window doesn't produce any result. This may sound as the small detail but this was the first "imperfection" I noticed
-I didn't find example project. Few (relatively complex) example designs which done in FreeCAD and available for download will promote tool by itself


Andrey
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: couple of questions

Post by jriegel »

Hi,
thanks for the replay.

The Highlighting is a problem of Coin. The Coin node doesent highlight lines! We have to implement our own
Invontor node in order to do this. Its on the list, but the list is long :(

Switching document by tree is a must. Your right.

I collecting some sample data allready and will release it with the 0.9 release series.

Cheers Jürgen
Stop whining - start coding!
Post Reply