Drawing dimensioning workbench for FreeCAD v0.15

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Drawing dimensioning workbench for FreeCAD v0.15

Postby hamish » Wed Nov 12, 2014 8:47 am

Hi All,

I used FreeCAD v0.15 for a project I was involved with, and ended up writing a drawing dimensioning workbench as to add dimension functionality to the pages I created using the drawing workbench.
Firstly I must apologize, as time has not allowed for me to follow the workbench creation documentation on the FreeCAD wiki.
Nevertheless I am posting what I have so far, in case some else may find it useful.

Details:
- linear dimensioning, circular dimensioning, and placing text
- only works with FreeCAD v0.15 (tested on Ubuntu 14.04 but should work on other OSs as well)
- dimensions do NOT update with model updates
- dimensions and text can be deleted, but not moved.
- every time a dimension is placed the view zoom and scrolling is reset.
- slightly unstable, occasionally causes crashes, so save regularly

Github repository: https://github.com/hamish2014/FreeCAD_d ... mensioning

Installation instructions :README.md
Last edited by hamish on Wed Nov 19, 2014 1:41 pm, edited 1 time in total.
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby jmaustpc » Wed Nov 12, 2014 11:14 am

Hi Hamish, your first post, welcome
Thank you for the code, it sounds interesting. Its highly worth while talking to us first though, because someone has already substantially written an updated Drawing work bench that includes dimensions etc.., it needs updating to master and possibly still needs some work but may possibly have saved you a lot of work. Are you aware of the branch by "MrLukeParry"? It sounds like you have a similar functionality? I.e putting dimensions on the 2d drawings in Drawing WB? Or does your code put dimensions in the 3d model, something like the current Draft WB Dimension? Or something else?

By the way is it Python or C++ code?

Have you pushed your code to a git repository somewhere on line? e.g Bitbucket or GitHUb etc.? They have free accounts. Doing so allows us to have a look at the code online and "diff" to FreeCAD code, etc., without risking downloading code before we know what it does and make sure it has not viruses etc..

Please don't think I am being to negative. If you explain a bit more about how and what your wb does and post it to a git repository, I for one, will certainly have a look at it. :)

I have disabled your link until we know exactly what it is downloading. Anyone who thinks otherwise can copy paste the text into their browser but it can't be just clicked on and have unknown code downloaded.

Jim
slc55
Posts: 34
Joined: Thu Feb 07, 2013 7:27 pm

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby slc55 » Wed Nov 12, 2014 7:56 pm

I just tried this and while it is buggy, and crashed several times, it comes close to making Freecad a whole lot more brilliant and useful.
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby jmaustpc » Wed Nov 12, 2014 10:30 pm

slc55 wrote:I just tried this and while it is buggy, and crashed several times, it comes close to making Freecad a whole lot more brilliant and useful.
why post such an empty comment? How does it "make FreeCAD a whole lot better" ...I don't mean that it doesn't...but if you have tried it them why not say what it actually does, provide some information that might be useful to other people here. How is it better than what already exists? Is it Python? How does it relate/compare to the work Luke was working on?
slc55
Posts: 34
Joined: Thu Feb 07, 2013 7:27 pm

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby slc55 » Thu Nov 13, 2014 6:45 am

I don't consider it an empty comment, just information for anybody else that may be considering trying it that they will probably experience problems as well as seeing something that will improve the usefulness of Freecad

As I get more time to try it I can post more details about what it can do.

I could have kept quiet and waited for someone to post about how it had wrecked their drawing/part design or whatever, but now they have information from someone who has actually tried it.
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby hamish » Thu Nov 13, 2014 7:51 am

Glad you found the code useful sic55;
The main reason I created this post was to help FreeCAD v0.15 users (including myself) who want to add dimensions to their drawings.

The other reason for posting my drawing dimensioning workbench code, was that it may be helpful to the FreeCAD developers.
The workbench is for adding SVGs to the 2D pages created by the drawing working bench for the purposes of 2D dimensioning.
The code is written in Python not c++.
It must said that the code is rather crude.
Nevertheless maybe it will helpful to developers.

I appreciate that if I followed the proper process and posted it to git repository, it will easier for the developers.
And as jmaustpc says helpful for me too, i.e. MrLukeParry's branch.
We live we learn :)
User avatar
yorik
Site Admin
Posts: 11570
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby yorik » Thu Nov 13, 2014 9:11 pm

Very impressive work hamish!

This does, in a simple way (100% python!) the basics of what Luke's branch does, you can add dimensions graphically to a drawing sheet, by picking existing vertices. So far they are not editable nor associated with the base object, but that could certainly be worked further...

Well done anyway, lots of interesting things to learn in your code!
screenshot.jpg
screenshot.jpg (190.24 KiB) Viewed 21911 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby NormandC » Sat Nov 15, 2014 4:39 pm

I can't manage to create a single dimension.

How do you use this? I can't select vertices on a view before starting a dimensioning tool.

If I start a dimensioning tool, I get this error in the report view:

Code: Select all

Running the Python command 'linearDimension' failed:
Traceback (most recent call last):
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/crudeDebugger_output/linearDimension_crudeDebugging.py", line 278, in Activated
    moduleGlobals['dimensioningRect'].activate(**moduleGlobals)
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/crudeDebugger_output/linearDimension_crudeDebugging.py", line 74, in activate
    self.generateSnapPoints()
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/crudeDebugger_output/linearDimension_crudeDebugging.py", line 92, in generateSnapPoints
    points = points + svg.linearDimensioningSnapPoints()
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/XMLlib.py", line 214, in linearDimensioningSnapPoints
    allPoints = self.LSP_linearDimensioning + sum([c.linearDimensioningSnapPoints() for c in self.children], [])
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/XMLlib.py", line 214, in linearDimensioningSnapPoints
    allPoints = self.LSP_linearDimensioning + sum([c.linearDimensioningSnapPoints() for c in self.children], [])
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/XMLlib.py", line 213, in linearDimensioningSnapPoints
    self.calculate_local_snap_points()
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/XMLlib.py", line 186, in calculate_local_snap_points
    raise RuntimeError, 'unable to parse path "%s" with d parms %s' % (self.XML[self.pStart:self.pEnd], parms)

unable to parse path "<path d="M-23.0846,128.132 Q-22.824,128.132 -22.6152,127.994 " />" with d parms [u'M', u'-23.0846', u'128.132', u'Q-22.824', u'128.132', u'-22.6152', u'127.994']Traceback (most recent call last):
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/crudeDebugger_output/linearDimension_crudeDebugging.py", line 119, in mousePressEvent
    if self.findSnapPoint(x, y) <> None :
  File "/home/normand2/.FreeCAD/Mod/Dimensioning/dimensioning.py", line 61, in findSnapPoint
    D = ( x - self.snapX)**2 + (y - self.snapY)**2
AttributeError: 'DimensioningRect' object has no attribute 'snapX'
Thanks. My FreeCAD version details are below.

Installed from the Daily Builds PPA
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4189 (Git)
Branch: master
Hash: 18c0b3ba69ef8cb1192135b9580cdf5d4572cfa0
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.1
User avatar
yorik
Site Admin
Posts: 11570
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby yorik » Sun Nov 16, 2014 3:40 pm

I did like this:

1) place the Dimensioning folder into $HOME/.FreeCAD/Mod (obviously you did this already)
2) create a Part cube
3) create an A3 page
4) create a view of the cube on the page
5) switch to the dimensioning WB
6) press the linear dimension button

I don't get your error... Apparently you found a bug :)

This line puzzles me:

Code: Select all

unable to parse path "<path d="M-23.0846,128.132 Q-22.824,128.132 -22.6152,127.994 " />" with d parms [u'M', u'-23.0846', u'128.132', u'Q-22.824', u'128.132', u'-22.6152', u'127.994']Traceback (most recent call last):
I don't know why the pieces of that path are turned into unicode objects, but it seems to be the cause of the problem.
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Drawing dimensioning workbench for FreeCAD v0.15

Postby quick61 » Sun Nov 16, 2014 4:46 pm

Linear dimension works great, text works great, delete dimension works great, escape dimension works as expected. Circular dimension, not so much. Just selecting it caused a crash first time. After that, any movment into the drawing view with the mouse after selecting it dumps dozens of repeating error messages into the Report view. -

Code: Select all

Traceback (most recent call last):
  File "/home/mark/.FreeCAD/Mod/Dimensioning/crudeDebugger_output/circularDimension_crudeDebugging.py", line 222, in hoverMoveEvent
    snapPoint = self.findSnapPoint(x, y)
  File "/home/mark/.FreeCAD/Mod/Dimensioning/dimensioning.py", line 62, in findSnapPoint
    debugPrint(4, 'findSnapPoint minD/VRT_scale**2 : %f' % (D.min()/self.VRT_scale**2))
  File "/usr/lib/python2.7/dist-packages/numpy/core/_methods.py", line 21, in _amin
    out=out, keepdims=keepdims)
ValueError: zero-size array to reduction operation minimum which has no identity
Question - Is the Circular dimension diameter or radius? I would think that if it were to be one, it should be radius as that would be in line with the rest of FreeCAD.

Other than that, looks really good. Very easy to use. Keep at it. It's nice to see more plugin workbenches coming along for FreeCAD.

For those keeping track, we have the following plugin workbenches.
  • Bolts
  • EaglePCB_2_FreeCAD
  • Gears
  • FreeCAD-CuraEngine
  • Animation
  • Drawing Dimensioning
Did I miss any?

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?