Dimensions

Bug #170018 reported by Jlpatte2
14
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Alexandre Prokoudine
Nominated for 0.47.x by doo
Nominated for 0.48.x by doo
Nominated for Old by doo

Bug Description

Adding a feature that allows you to do cad style
dimensions would be really cool.

I have found this feature really useful in Corel and it is
missing in most other vector graphics packages.

Tags: other
Revision history for this message
Kees Cook (kees) wrote :

Can you provide some more details on what this feature looks
like/how it works?

Revision history for this message
Bug Importer (bug-importer) wrote :

It is a simple feature, in Corel it has 3 modes, a
horizontal specific, a vertical specific, and a "any angle"

When you click once it sets the first position, then when
you click a second time it sets the second, In horizontal
only mode, it ONLY uses the x position of the second click,
and in vertical only it only uses the y position of the
second click.

Then It draws a line from each point perpendicular to the
line between points/horizontal or vertical (for those modes)
out to where you move your cursor, once you click a 3rd time
it then draws a line between the two lines with the
dimension on it.

This is a fairly standard CAD style functionality.

Revision history for this message
Tnikkila (tnikkila) wrote :

I'd like dimensions very much too, they would make Inkscape
a great technical sketching tool together with a couple of
other features. For them to be really useful you would need
a unit/scale preferences though.

The other features I miss are related to exact positioning
of points, for instance snap to endpoints and so on.

Revision history for this message
Loehrerl-users (loehrerl-users) wrote :

For me, CAD-like dimensions are a very important feature
too. The amount of dimensions support available in
"Openoffice Draw" would be more than enough. By
"dimensions", I mean something like this:

 | 30mm |
 |<------------------------------>|

Of course, the orientation could also be vertical or in any
direction.

Revision history for this message
Tnikkila (tnikkila) wrote :

I have put a sample picture showing some dimensions here:
http://www.hut.fi/~tnikkila/dimensions.png

Revision history for this message
Xtronics (xtronics) wrote :

I also need this feature!

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

It shouldn't be too hard to implement this as an effect. The "Visualize Path/Measure path" already does a similar job.

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

I have written a simple script that just puts two lines just outside the selection's bounding box.

By using "Visualize Path/Measure path" on those lines and adding markers, guide lines etc, a fairly nice dimensioning effect results.

Is this functionality too simple, or should I submit it?

Changed in inkscape:
status: New → Incomplete
Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

This is a demonstration of the effect as of today. I've added a few more features to it.

Revision history for this message
Bryce Harrington (bryce) wrote :

Peter, can you work this into a patch for inclusion? There might be time to get this in for 0.46 if it can be done asap.

Changed in inkscape:
importance: Undecided → Wishlist
milestone: none → 0.46
status: Incomplete → In Progress
Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

I'm on it.

I'm not familiar with the patch submission procedure, however. Do I just attach the .py and .inx files to this page?

Also, I've taken a couple of short cuts in my script. One is probably OK: I've imported a couple of existing scripts (inkex and pathmodifier) to re-use existing functionality. If any of those are deprecated, I need to change that. Another is a kludge: I hard-coded the data for the ArrowL1start and -end markers into the script instead of fetching them from markers.svg. This shouldn't cause any trouble, but if I have time I'd like to rewrite it to do it correctly.

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

I think I'm done for the moment, but there is probably room for improvement.

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

The previous version had a problem with Rectangle and Text Objects. I've added an exception catcher to fail more gracefully.

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

I've looked deeper into this and found that the function that supposedly calculates the bounding box of the path actually calculates the convex hull instead. The bounding box and the convex hull are mostly the same for many of the paths that one would expect in a CAD-style drawing, but they are very dissimilar for severely deformed bezier curves.

Possible solutions:
1. Get the selection's bounding box as calculated by Inkscape
 a) by calling Inkscape on the command line with -query-* parameters. That's 4 calls per selected object!
 b) in some other manner (anyone?)

2. Calculate an approximate curve in the script and hope that the bounding box is close enough. Could be slow and it's still uncertain if the result will be correct.

3. Change the way the script interacts with the user
 a) instead of selecting objects and calling the filter, the user would lay out and select two lines along the selected objects, and the script would pick those up to work from.
 b) the user would manually copy the selection's x/y/w/h parameters from the toolbar to the script interface dialog.

or

4) Keep it as it is now and let the user modify the lines afterwards in case they are incorrect.

I'm inclined to go with 4), since the effect will be well-behaved in most realistic cases.

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

So, what's new? Are you still aiming for 0.46? ;-)

Revision history for this message
Bryce Harrington (bryce) wrote :

Should we go ahead and commit this for 0.46? We need to make a final decision on it pretty soon. I'd love to include this if it's considered stable enough.

Revision history for this message
Bryce Harrington (bryce) wrote :

Removing milestone; this feature is not imperative for this release and/or there is insufficient time remaining to implement it.

nightrow (jb-benoit)
Changed in inkscape:
milestone: 0.46 → none
Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

Sorry, I've been AFK over the holidays, and I'm still catching up on the mail backlog.

As for the filter: since no one has complained about it, I've considered it done as of 2007-12-13 (the version uploaded 2007-12-08).

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

Um, I suppose I should have set this? I thought it was up to the maintainers to do that, so I left it at "In progress".

Changed in inkscape:
status: In Progress → Fix Committed
Revision history for this message
khiraly (khiraly123) wrote :

I tried to launch your extension on a windows dev build (20080116), and the script produces this error message:
No matching node for expression: /svg//defs

Traceback (most recent call last):
  File "share\extensions\dimension.py", line 137, in <module>
    e.affect()
  File "C:\Documents and Settings\Fjne\Asztal\minden\programok\inkscape\share\extensions\inkex.py", line 154, in affect
    self.effect()
  File "share\extensions\dimension.py", line 92, in effect
    self.addMarker('Arrow1Lstart', False)
  File "share\extensions\dimension.py", line 52, in addMarker
    defs = self.document.createElement('svg:defs')
AttributeError: 'etree._ElementTree' object has no attribute 'createElement'

Revision history for this message
khiraly (khiraly123) wrote :

Is it possible, that you have written this extension with the old python xml library and not with the new (lxml)?

I try digging a bit more to this error message, maybe I can find something;)

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

Yes, I wasn't aware that the base library had changed, I thought it was safe to use inkex.py methods :)

Could you please try this new version?

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :
Revision history for this message
khiraly (khiraly123) wrote :

Sorry for the late reply (I would like really see this extension in inkscape 0.46).

So here is the quick test:
Traceback (most recent call last):
  File "/home/khiraly/.inkscape/extensions/dimension.py", line 141, in <module>
    e.affect()
  File "/home/khiraly/.inkscape/extensions/inkex.py", line 153, in affect
    self.effect()
  File "/home/khiraly/.inkscape/extensions/dimension.py", line 90, in effect
    self.bbox = self.computeBBox(self.selected)
  File "/home/khiraly/.inkscape/extensions/pathmodifier.py", line 139, in computeBBox
    if node.tagName == 'path':
AttributeError: 'etree._Element' object has no attribute 'tagName'

Oh, and would be nice to integrate into this extension the Visualize path-> measure path extension.

Thank you for this extension!

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

Thank you for alerting me to the problems!

It could be that you have an obsolete version of pathmodifier.py. In the 20080120 version (if not earlier) the relevant code has been updated (I'm just borrowing a function from it, I'm not involved in the development of that script).

I originally contemplated adding "measure path" functionality into dimensions, but decided not to do so, since it would 1) increase the complexity and fragility of this extension, 2) necessitate synchronization with the development of the "measure path" extension. I believe it is workable to apply dimension to an object and then apply "measure path" to the dimension lines.

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

Trying that on current trunk and it fails:

Traceback (most recent call last):
  File "/home/avp/.inkscape/extensions/dimension.py", line 35, in <module>
    import sys, inkex, pathmodifier
ImportError: No module named inkex

What is missing?

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

The inkex.py module is the basis for most (50 out of 77) Python extensions. Do the other extensions (e.g. "Add Nodes") work correctly?

I can't reproduce the bug on Inkscape0801211941 or Inkscape0801221552.

Revision history for this message
Bryce Harrington (bryce) wrote :

Hi, I notice the extension is still not committed to SVN - what work remains before we can commit this to svn?

Changed in inkscape:
status: Fix Committed → In Progress
Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

Well, it's supposed to be ready for inclusion, but:

1. Apparently, someone needs to clue me in to the commitment process. I haven't been able to find any description in the docs or on the wiki. From what I read about the SVN system, it seemed to apply to the actual Inkscape source code (and not extension script code), so I assumed that it would be enough to upload it here and mark it committed.

2. The implementation has a quick-and-dirty character (as hinted at above). I was under the impression that it was necessary to submit it soonest, so I went for the "good enough -- hands off" approach.

3. I did work on an improved implementation, only using Ruby instead. Then I was unexpectedly employed, and now most of my time and energy is used up writing course materials for the local college. The Ruby implementation is therefore on hold. I'd like to back port some of my ideas to Python and Aaron's inkex module some day, but it won't be before 0.46 is released. I'd also like to try the SVN system some day, but I simply don't have the time to do it right now.

4. I just tested the current code with Inkscape0801301416, and there is some kind of problem. I'll try to fix it and upload a new version this evening or early tomorrow.

Basically, if someone with SVN access and know-how wants to commit it, feel free to do so (preferably after my next upload).

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

The previous version had a problem with the usage of the computeBBox method borrowed from simpletransform.py. After some minor edits, the extension is working again on WinXP.

Changed in inkscape:
assignee: nobody → vermeil
Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

I can commit the extension into trunk, if I have green lights from Bryce :)

Regarding SVN, do you have commit access? If no, is it your first "patch", Peter?

Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

I don't have any SVN tools installed, nor do I have any kind of SVN access that I know of.

It is my first patch for the Inkscape project and for the Launchpad system. I have worked with other projects, for instance on Sourceforge, and before that on FTN development infrastructures. That was a long time ago though, and it seems things aren't as simple as they used to be.

Revision history for this message
Bryce Harrington (bryce) wrote :

Yes, please go ahead with uploading it.

If significant bugs show up with it prior to the release, we should revert and postpone inclusion until 0.47.

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

Latest uploaded versions of both .inx and .py are committed to trunk.

Please note that the .inx file should be fixed to have name of the extensions contextually separated from same messages ("Dimensions") in SVG Filters GUI (or the other way round).

Changed in inkscape:
assignee: vermeil → alexandre-prokoudine
milestone: none → 0.46
status: In Progress → Fix Released
Revision history for this message
Peter Lewerin (vermeil-deactivatedaccount) wrote :

Alexandre: Since you've taken over as assignee, I suppose you will be handling that?

I've been testing the extension against the latest snapshots for the last weeks to catch any bugs that might show up. Would you like me to keep doing that and submit patches for your approval?

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

Sure, I can commit updates.

Several notes on the current version:

1. No matter how hard I tried I couldn't make it create captions above arrows.

2. Measure path has a very useful option to define scale (like 1:4000). I'd really love to see it :)

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

Oh well, I should have taken a look at the screenshot again :)

But still, is it possible to reuse Measure path effect?

Revision history for this message
David Rankin (drankinatty) wrote :

Hey, Guys,

    What is the status of dimensioning in inkscape? I've built 0.47 pre1, and I didn't see anything. Every technical illustration package needs the ability to provide dimensions for the vector objects and a scale setting so the dimensions can actually be the right size. It's been a while, but the simple dimensioning included in the old MicroGrafx Designer 6.0 was more than adequate for the type of dimensioning necessary in an illustration package.

    I like what I see in 0.47 and I hope to see dimensioning in inkscape in the future. It is really a great package. Thanks

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

David, nothing has changed since the last update. The extension is committed, but isn't as functional as I would love it to be.

Revision history for this message
G. Steel (germsteel) wrote :

Hello,

I am using 0.47 on Mac OS X 10.6.2 and have drawn a map of vegetable fields; a dimension / scale function would be great.

Feature set:

Document properties >> PAGE tab > General
under default units
Scale: 1:100 or 1:1

Explanation: 1 inch (default unit) is 100" in real life.
OR 1 inch is 1 mile
OR 1 cm is 1 km

Object properties >>
enter dimensions default units:
x x y (rectangle) inches
scaled units
100x x 100y inches

=================

Cheers,

  --G. Steel

Note:
I am downloading py26-lxml now to try the dimension under Visualize.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.