Drawing Template Sets And Their Implementation In FreeCAD

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
jmaustpc
Posts: 8101
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby jmaustpc » Thu Jan 30, 2014 12:04 pm

Hi Luke
I tried to compile your branch drawing
https://github.com/mrlukeparry/FreeCAD_ ... ee/drawing

Are you interested in us testing this, or is it to early for testing, or is this the appropriate branch? :)

Kubuntu 12.04 64bit


Jim

if it is helpful here is the error message

[ 90%] Building CXX object src/Mod/Inspection/Gui/CMakeFiles/InspectionGui.dir/Workbench.cpp.o
Linking CXX shared library ../../../../Mod/Assembly/AssemblyGui.so
[ 90%] Built target AssemblyGui
[ 90%] Generating moc_TaskTetParameter.cpp
[ 91%] ViewProviderFemMeshPy.xml
Traceback (most recent call last):
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generate.py", line 96, in <module>
main()
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generate.py", line 92, in main
generate(filename,defaultPath)
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generate.py", line 35, in generate
GenerateModelInst = generateBase.generateModel_Module.parse(filename)
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generateBase/generateModel_Module.py", line 2282, in parse
doc = minidom.parse(inFileName)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1920, in parse
return expatbuilder.parse(file)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 924, in parse
result = builder.parseFile(fp)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 23, column 1
make[2]: *** [src/Mod/Fem/Gui/ViewProviderFemMeshPy.h] Error 1
make[1]: *** [src/Mod/Fem/Gui/CMakeFiles/FemGui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX shared library ../../../../Mod/Inspection/InspectionGui.so
[ 91%] Built target InspectionGui
make: *** [all] Error 2
mrlukeparry
Posts: 652
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby mrlukeparry » Thu Jan 30, 2014 6:31 pm

jmaustpc wrote:Hi Luke
I tried to compile your branch drawing
https://github.com/mrlukeparry/FreeCAD_ ... ee/drawing

Are you interested in us testing this, or is it to early for testing, or is this the appropriate branch? :)

Kubuntu 12.04 64bit


Jim

if it is helpful here is the error message

[ 90%] Building CXX object src/Mod/Inspection/Gui/CMakeFiles/InspectionGui.dir/Workbench.cpp.o
Linking CXX shared library ../../../../Mod/Assembly/AssemblyGui.so
[ 90%] Built target AssemblyGui
[ 90%] Generating moc_TaskTetParameter.cpp
[ 91%] ViewProviderFemMeshPy.xml
Traceback (most recent call last):
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generate.py", line 96, in <module>
main()
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generate.py", line 92, in main
generate(filename,defaultPath)
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generate.py", line 35, in generate
GenerateModelInst = generateBase.generateModel_Module.parse(filename)
File "/home/user/Downloads/cad/mystuff/bitbucket-freecad-clone-sf-master/clone2/lukeperry/code/src/Tools/generateBase/generateModel_Module.py", line 2282, in parse
doc = minidom.parse(inFileName)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1920, in parse
return expatbuilder.parse(file)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 924, in parse
result = builder.parseFile(fp)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 23, column 1
make[2]: *** [src/Mod/Fem/Gui/ViewProviderFemMeshPy.h] Error 1
make[1]: *** [src/Mod/Fem/Gui/CMakeFiles/FemGui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX shared library ../../../../Mod/Inspection/InspectionGui.so
[ 91%] Built target InspectionGui
make: *** [all] Error 2


The build is failing in the FEM module for some reason after merged from master with the pyside change and involved a lot of manual merge completion. I think that maybe GIT has done an incompatible auto-merge as it had conflicts in other modules I've never touched...

For now you can disable building FEM module in CMAKE and the drawing branch will compile.
jmaustpc
Posts: 8101
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby jmaustpc » Thu Jan 30, 2014 6:38 pm

Hi Luke
I noticed that it looked like it was not "in your area", so I made a new fresh git clone (to avoid any git or merge issues) and a new clean build, and then got the errors above. Master compiled for me, so I thought it seemed to be only in your branch. However as you said I can just turn FEM off for now.

Thanks for the feed back. :)

Jim
mrlukeparry
Posts: 652
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby mrlukeparry » Thu Jan 30, 2014 9:33 pm

Fixed that issue. Just copied over the Fem directory in master over to the drawing branch.
jmaustpc
Posts: 8101
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby jmaustpc » Fri Jan 31, 2014 9:43 am

mrlukeparry wrote:Fixed that issue. Just copied over the Fem directory in master over to the drawing branch.



Thanks Luke,

A quite note to say it now compiles fine for me. :-)

Jim
triplus
Posts: 5016
Joined: Mon Dec 12, 2011 4:45 pm

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby triplus » Sat Feb 08, 2014 4:05 pm

I read this today:

http://freecadamusements.blogspot.com/2 ... ython.html

As far as I'm aware it's not adopted by any Mechanical CAD Package. I won't get into the discussion, but the biggest problem with using this template format is that there is no easy way to translate this into other formats such as .dxf, .dwg (Autocad / Teigha) or even our own representation if we ever needed it.

Dealing with XML is not impossible, and can be quite easy to manipulate using DOM (Document Object Model) functionality built into Qt. However, interacting with it through QGraphicsView is not great even if we have QSvg - which is apparently now obsolete. The other original idea was to parse any text fields and turn these into editable text boxes, but this alone creates further impracticalities.

The other big problem that seemed to be happening was the size and variation between templates based primarily on the paper size and the standard used (ANSI, ISO, Arch). There is nothing stopping someone creating these but in the future if these maintained it creates a lot of duplication of work.

I decided that we might as well do it RFT (right first time) rather than wait after the maiden release of the new module, which could be later in the year now.


Basically the decision is already made to move away from using SVG as basis for Drawing Workbench but that does leave me one question. Will exporting to SVG (comparable quality compared to current situation) still be possible in the future? Or to leave (part of) the current code in FreeCAD just for SVG exporting purposes as it is done in current DW?

If the answer is YES then i guess there will still be the possibility to do everything that is possible ATM. For example edit the drawing in Inkscape and to be able to open it in any SVG viewer...

If the answer is NO than i guess this would represent a substantial loss to me concerning FreeCAD capabilities but i will not go into this because it is in the end up to developer to choose and as i see it it was already chosen to move away from SVG as the basis for Drawing Workbench but i am still wondering about the plans to support exporting to SVG in this new Drawing Workbench when it lands in FreeCAD?
Last edited by triplus on Sat Feb 08, 2014 4:47 pm, edited 2 times in total.
triplus
Posts: 5016
Joined: Mon Dec 12, 2011 4:45 pm

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby triplus » Sat Feb 08, 2014 4:42 pm

And what about custom templates? Currently it is possible to make one in for example Inskscape and individual text fields can be controlled from FreeCAD properties...

Would creating custom "dxf/dwg" templates still be possible or would that always be limited to default python scripts used for creating (parametric) templates? Because there would still have to be some directory custom templates would be located in and for example drop down menu in Drawing Workbench to select them?
arcol
Posts: 207
Joined: Sun Nov 10, 2013 9:02 am

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby arcol » Sun Feb 09, 2014 9:53 am

triplus wrote:And what about custom templates? Currently it is possible to make one in for example Inskscape and individual text fields can be controlled from FreeCAD properties...


Or custom graphics, eg. company's logo. The best if it is vector art, so scales fine.
Nothing fancy, but may involve some bezier lines here and there, which is pretty hard to redo it in pure python.

Or custom font, which is best to just convert to bezier curve (think of Coca-Cxxa),
it will never ever write an another string, so perfectly fine just to convert to vector art,
instead of trying to include the font inside freecad.

I do think everyone at a point *want* to include a logo.
Or even watermark, like: PREVIEW ONLY or CUSTOM SCALE or INSIDE USE ONLY or DO NOT COPY or whatever.

I try to list some usecases which may be too hard to do from scripting only.
For the same reason in freecad it is easier to model then in openscad.
User avatar
yorik
Site Admin
Posts: 8684
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby yorik » Sun Feb 09, 2014 3:00 pm

Sorry to enter this discussion so late, but I don't think templates should be discarded. Of course they have several problems, but they have several advantages too. The main one is to be extremely easy to create and manipulate. Besides, several parts of freecad are based on templates, such as the raytracing module, and it is interesting to have a unified way of handling those things.

Also, the SVG format, even if not widely used in technical CAD (yet), is very convenient and easy, it can contain bitmap images, it has powerful representation possibilities (linestyles, pattern-filling, transparency, blurring, gradients, etc), it can be created 100% graphically, it is open and human readable, and displays natively in web browsers. It is by far the best vector 2D format available, I think. The ease of use and the flexibility of templates, for the final user of freecad, is something that would be very hard to achieve with any other system. The idea, after all, is that users create their templates, not freecad developers. And they need to be able to use an easy tool like inkscape, otherwise they won't do it.

Don't get me wrong Luke, I totally see your point and agree about the advantages you described in your last blog post, and I think parametric templates are a very cool idea to implement, but I also think that the template system should stay there too.
mrlukeparry
Posts: 652
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Drawing Template Sets And Their Implementation In FreeCA

Postby mrlukeparry » Sun Feb 09, 2014 4:40 pm

Discussions are good and don't get me wrong I'm stuck on just one idea as everything evolves.

triplus wrote:If the answer is YES then i guess there will still be the possibility to do everything that is possible ATM. For example edit the drawing in Inkscape and to be able to open it in any SVG viewer...

If the answer is NO than i guess this would represent a substantial loss to me concerning FreeCAD capabilities but i will not go into this because it is in the end up to developer to choose and as i see it it was already chosen to move away from SVG as the basis for Drawing Workbench but i am still wondering about the plans to support exporting to SVG in this new Drawing Workbench when it lands in FreeCAD?


There will be support for exporting to SVG. The whole idea of this was to have a general representation so we can export between format. Whether it is just parts/views in a drawing or the whole drawing itself.

arcol wrote:Or custom graphics, eg. company's logo. The best if it is vector art, so scales fine.
Nothing fancy, but may involve some bezier lines here and there, which is pretty hard to redo it in pure python.

Or custom font, which is best to just convert to bezier curve (think of Coca-Cxxa),
it will never ever write an another string, so perfectly fine just to convert to vector art,
instead of trying to include the font inside freecad.

I do think everyone at a point *want* to include a logo.
Or even watermark, like: PREVIEW ONLY or CUSTOM SCALE or INSIDE USE ONLY or DO NOT COPY or whatever.

I try to list some usecases which may be too hard to do from scripting only.
For the same reason in freecad it is easier to model then in openscad.


The idea is to make the templates customisable to some degree through the script. So for example the user could change the font or change a set logo in the corner. The functionality I guess depends on the script I guess.

yorik wrote:Also, the SVG format, even if not widely used in technical CAD (yet), is very convenient and easy, it can contain bitmap images, it has powerful representation possibilities (linestyles, pattern-filling, transparency, blurring, gradients, etc), it can be created 100% graphically, it is open and human readable, and displays natively in web browsers. It is by far the best vector 2D format available, I think. The ease of use and the flexibility of templates, for the final user of freecad, is something that would be very hard to achieve with any other system. The idea, after all, is that users create their templates, not freecad developers. And they need to be able to use an easy tool like inkscape, otherwise they won't do it.


I know what you mean where SVG has the feature set and nice templates can be made through Inkscape. Personally, I wouldn't want to edit a template unless I really needed.

Having thought about this - there is a middle ground. I suppose there is nothing stopping the use of SVG templates or even using dwg/dxf templates. The template itself is a modelled as a Document Object and is linked to the page. What is possible is having the SVG template feature (extends a base template class) and this can be used instead of the script-able template. The caveats are that you can only export the full page to SVG and I don't think I can make these editable. I'd imagine the infrastructure changes would not be too bad.