Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by onekk »

Roy_043 wrote: Thu Oct 13, 2022 8:32 am
onekk wrote: Thu Oct 13, 2022 4:47 am I can't test the script to see if we could advise 0.19 as minir version were the script and the example should work.
The scripts do not work in V0.19 because the doc.clearDocument() method is missing in that version. I would personally just create a new document. I also would not save the document, but if you do you should prompt the user for a filename IMO.
Hi, thanks, for the advice.

Do you think that we could target 0.20 as minimun FC version or the problem with 0.19 is limited to the clearDocument() and we can find a workaround for it, and target 0.20.

Any other hints?

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by Roy_043 »

Your code is based on fixed object names, that is why you need doc.clearDocument(). Else the code cannot be run in the same document twice. I have already made a comment about that (https://forum.freecadweb.org/viewtopic.php?f=22&t=72207). I would not use this approach.

For V0.19 the line with clearDocument() and the 4 lines with pad_or_pocket.AlongSketchNormal must be commented out.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by onekk »

Roy_043 wrote: Thu Oct 13, 2022 3:21 pm Your code is based on fixed object names, that is why you need doc.clearDocument(). Else the code cannot be run in the same document twice. I have already made a comment about that (https://forum.freecadweb.org/viewtopic.php?f=22&t=72207). I would not use this approach.
...
Many thanks for the reply.

I've not found another way to create a predictable file name when running scripts other than "deleting all objects" present in a document, and reuse the empty file.

It is better to delete the file and recreate a new file with same name?

Or there are better methods?

TIA and Regards.

Carlo D:
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by onekk »

Roy_043 wrote: Thu Oct 13, 2022 3:21 pm For V0.19 the line with clearDocument() and the 4 lines with pad_or_pocket.AlongSketchNormal must be commented out.
For this problem, probably some other modification has to be done to make a proper results, other than delecting the lines?

TIA and Regards.

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by Roy_043 »

onekk wrote: Thu Oct 13, 2022 4:38 pm It is better to delete the file and recreate a new file with same name?
I would not save the document at all. To me it is only annoying when a program saves a document to a location that I am unaware of. Why not just create a new document and leave it to the user if, and where, they want to save it.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by Roy_043 »

onekk wrote: Thu Oct 13, 2022 4:39 pm For this problem, probably some other modification has to be done to make a proper results, other than delecting the lines?
Actually deleting the 5 lines works. But, as already indicated, without doc.clearDocument() the code cannot be run twice in the same document.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by onekk »

Roy_043 wrote: Thu Oct 13, 2022 7:17 pm I would not save the document at all.
Ok now it is more clear, I've been reusing a code, that replicate an Assembly4 tutorial that needs to save and reopen files.

I agree and delete the lines.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by onekk »

Roy_043 wrote: Thu Oct 13, 2022 7:20 pm Actually deleting the 5 lines works. But, as already indicated, without doc.clearDocument() the code cannot be run twice in the same document.
I will try to find and alternative.

Thanks and Regards.

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by onekk »

Roy_043 wrote: Thu Oct 13, 2022 7:20 pm Actually deleting the 5 lines works. But, as already indicated, without doc.clearDocument() the code cannot be run twice in the same document.
Hello, try this modified file.

Chagelog:
  • I have reused my "homemade" clear_doc
  • commented out the AlongSketchNormal lines
  • eliminated all the code to save the file and setting paths
Could you kindly test if it works correctly on 0.19?
20221013-pdtut-cv1.py
(9.37 KiB) Downloaded 52 times


TIA and Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Is "Basic Part Design Tutorial" in line with actual Part Design workflow?

Post by Roy_043 »

The new version (20221013-pdtut-cv1.py) works fine in V0.19 and can be executed multiple times in the same document.

Code: Select all

OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: Dutch/Netherlands (nl_NL)
Post Reply