Can Inkscape calculate the area of an object? How?

Asked by David M

If it can't, does anyone have any ideas or links?

Thanks!

Question information

Language:
English Edit question
Status:
Expired
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
jazzynico (jazzynico) said :
#1

Hello,

Try Extensions>Visualize Path>Measure Path, and then select "Area" in the Measurement type list.

Please note that the object must be a path. If you want to measure a circle, rectangle, etc. you must convert it to a path first (Path>Object to Path).

Regards.

Revision history for this message
David M (babelon) said :
#2

Thanks, but there's no "area" subfolder in "Measure path", just linear with inch, mm, cm and numerical options.

Am I just missing an extension? Or do you know of some sort of script and how to set it up?

Appreciate getting to the bottom of this!

Revision history for this message
jazzynico (jazzynico) said :
#3

Oops, I forgot that area measurement is a new 0.48 feature, which is not yet out...
It's just a question of days or weeks, but you can download a snapshot at http://inkscape.modevia.com/win32/?M=D if you want to try it now.

Regards.

Revision history for this message
David M (babelon) said :
#4

I'm running Inkscape on a Mac OS 10.4... will that work?

Revision history for this message
jazzynico (jazzynico) said :
#5

The OSX snapshots are in http://inkscape.modevia.com/macosx-snap/?C=M;O=D.
But I'm not a Mac expert, and thus I really don't know if it works on 10.4.

Revision history for this message
su_v (suv-lp) said :
#6

Unfortunately there are no snapshot builds available for Mac OS X 10.4 Tiger. The packages on modevia work on Leopard (PPC, Intel) and Snow Leopard (Intel) only.

Revision history for this message
su_v (suv-lp) said :
#7

You can however download the extension files and put a copy of them into either the user extension folder ('~/.config/inkscape/extensions' [1] - don't forget to remove it when 0.48 is out) or overwrite the one inside the application bundle of Inkscape 0.47 ('/Applications/Inkscape.app/Contents/Resources/extensions' [2]).

Download links:
extension definition file 'measure.inx':
<http://bazaar.launchpad.net/~inkscape.dev/inkscape/RELEASE_0_48_BRANCH/download/head:/measure.inx-20091128124040-aej0x7yhxng1m6ly-7563/measure.inx>
python script 'measure.py':
<http://bazaar.launchpad.net/~inkscape.dev/inkscape/RELEASE_0_48_BRANCH/download/head:/measure.py-20091128124040-aej0x7yhxng1m6ly-7564/measure.py>

[1] to access so-called dot-folders (hidden folders), use the 'Go > Go to Folder…' ('Shift+Cmd+G') feature of the Finder and enter the path (without quotes) into the dialog box:
'~/.config/inkscape/extensions'

[2] to access a folder inside an application bundle, browse to the application in the Finder, right-click (or control-click) the application icon and choose 'Show Package Contents' from the context menu.

@JazzyNico - hmm, does measure.py depend on other updated extension files (compared to 0.47)?

Revision history for this message
David M (babelon) said :
#8

Thanks,

I'll let you know!

Revision history for this message
David M (babelon) said :
#9

Well... inserted the ext, the window popped up, opted for "area" and got the following message...

Traceback (most recent call last):
  File "Contents/Resources/extensions/measure.py", line 34, in ?
    locale.setlocale(locale.LC_ALL, '')
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/locale.py", line 381, in setlocale
locale.Error: unsupported locale setting

Which is similar to what I got when I tried measuring the length of the path with the original ext.

I'm no programmer, so I'm not up-to-date on whether this means kiss it off or keep on trying to wiggle something?

Revision history for this message
su_v (suv-lp) said :
#10

There's a patch attached as temporary workaround for this issue (seems specific to using the system python on osx) to Bug #406662 in Inkscape: “measure path command has major problems on my drawings” <https://bugs.launchpad.net/inkscape/+bug/406662>

See Comment #7 for details (change tested on 10.5 Leopard only).

Revision history for this message
jazzynico (jazzynico) said :
#11
Revision history for this message
David M (babelon) said :
#12

Just to be sure...

where do I cache these files?
In the Extensions folder? ...Python folder? Or elsewhere?

Appreciate all the feedback!

Revision history for this message
jazzynico (jazzynico) said :
#13

> where do I cache these files? In the Extensions folder?

Yes! All extension files are in the extension folder.

Revision history for this message
su_v (suv-lp) said :
#14

I think copying all 5 files into the extensions folder inside the application bundle is best:
'/Applications/Inkscape.app/Contents/Resources/extensions'

Before overwriting (replacing) the existing files, it might be advisable to make a backup copy of the 'extensions' folder so you can restore it just in case it doesn't work.

Revision history for this message
David M (babelon) said :
#15

No, I'm still getting the same error message as above.

Maybe it's the osx.4.

Also tried the suv's patch, but the link explanation
<https://bugs.launchpad.net/inkscape/+bug/406662/comments/7>
wasn't clear enough for my limited programming experience.

There was no existing "inkscape-orig.sh" so I tried creating a new txt, pasting the patch and labelling accordingly... but...
$cd, $cp and $ patch mean nothing to me. It didn't work.

Hmmph!

Revision history for this message
su_v (suv-lp) said :
#16
Revision history for this message
David M (babelon) said :
#17

I'm over my head.

Don't know enough about Terminal or Unix pr anu programming for that matter.

But I appreciate the effort...

Revision history for this message
dave m. (z-launchpad-mersenne-com) said :
#18

This is an old question, but the extension didn't work for me on 0.48. It gave some error about the XML being too deeply nested to parse. After poking around a little, I fixed it by adding a parser flag to /usr/share/inkscape/extensions/inkex.py. Patch follows:

*** inkex.py.orig 2012-12-29 14:03:29.000000000 -0800
--- inkex.py 2013-08-27 15:06:39.339886770 -0700
***************
*** 136,142 ****
                  stream = open(self.svg_file,'r')
          except:
              stream = sys.stdin
! self.document = etree.parse(stream)
          stream.close()

      def getposinlayer(self):
--- 136,143 ----
                  stream = open(self.svg_file,'r')
          except:
              stream = sys.stdin
! p = etree.XMLParser(huge_tree=True)
! self.document = etree.parse(stream,parser=p)
          stream.close()

      def getposinlayer(self):

Revision history for this message
David M (babelon) said :
#19

Hmm. Thanks are in order I suppose even if the answer is (for me) more
enigmatic than Sphinx riddles or Turing codes.

The oldness of the question could be indicative of the need for a more
precise solution.

Could you clue me in to just what am I supposed to do with said patch?
Like where on virtual earth does it live?

Thanks! Again!

On 8/28/13 12:26 AM, dave m. wrote:
> Your question #117450 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/117450
>
> dave m. posted a new comment:
> This is an old question, but the extension didn't work for me on 0.48.
> It gave some error about the XML being too deeply nested to parse.
> After poking around a little, I fixed it by adding a parser flag to
> /usr/share/inkscape/extensions/inkex.py. Patch follows:
>
> *** inkex.py.orig 2012-12-29 14:03:29.000000000 -0800
> --- inkex.py 2013-08-27 15:06:39.339886770 -0700
> ***************
> *** 136,142 ****
> stream = open(self.svg_file,'r')
> except:
> stream = sys.stdin
> ! self.document = etree.parse(stream)
> stream.close()
>
> def getposinlayer(self):
> --- 136,143 ----
> stream = open(self.svg_file,'r')
> except:
> stream = sys.stdin
> ! p = etree.XMLParser(huge_tree=True)
> ! self.document = etree.parse(stream,parser=p)
> stream.close()
>
> def getposinlayer(self):
>

Revision history for this message
su_v (suv-lp) said :
#20

@David M - the patch posted by dave m. is not related to your question earlier (i.e. it does not address the known issue with $LANG with the OS X package of Inkscape 0.48.2).

dave m. meanwhile has committed his patch in the bug tracker (where it really belongs, and will be taken care of by Inkscape developers):
- Bug #1217602 'Measure Path fails with "XML too deep" error'
  <https://bugs.launchpad.net/inkscape/+bug/1217602>

Revision history for this message
David M (babelon) said :
#21

Just in case you guys fix the area issue, let me pose another question:
what would it take to calculate the central point (in terms of balance -
assuming uniform thickness) of a shape?

Maybe this has already been done somewhere somehow... but it's beyond me....

Thanks and good luck!

On 9/5/13 10:41 AM, ~suv wrote:
> Your question #117450 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/117450
>
> ~suv posted a new comment:
> @David M - the patch posted by dave m. is not related to your question
> earlier (i.e. it does not address the known issue with $LANG with the OS
> X package of Inkscape 0.48.2).
>
> dave m. meanwhile has committed his patch in the bug tracker (where it really belongs, and will be taken care of by Inkscape developers):
> - Bug #1217602 'Measure Path fails with "XML too deep" error'
> <https://bugs.launchpad.net/inkscape/+bug/1217602>
>

Revision history for this message
Launchpad Janitor (janitor) said :
#22

This question was expired because it remained in the 'Open' state without activity for the last 15 days.