Difference between revisions of "SpecCommandLineDrawing"

From Inkscape Wiki
Jump to navigation Jump to search
(New page: ==Outline== At the moment, Inkscape does not allow users to enter commands to Inkscape in a text-based format. This specification proposed to add that functionality, both at the command l...)
 
Line 2: Line 2:
  
 
At the moment, Inkscape does not allow users to enter commands to Inkscape in a text-based format. This specification proposed to add that functionality, both at the command line and internally, possibly using a command-line box similar to Rhino's. In this way, a user will be able to directly enter precise instruction to Inkscape with minimal effort. For example, a command such as "circle r:50" could be entered and Inkscpae will produce a circle of radius 50px, with all other attributes set to default values. In this way, technical drawing becomes easier, and the interface to Inkscape from external programs is vastly increased.
 
At the moment, Inkscape does not allow users to enter commands to Inkscape in a text-based format. This specification proposed to add that functionality, both at the command line and internally, possibly using a command-line box similar to Rhino's. In this way, a user will be able to directly enter precise instruction to Inkscape with minimal effort. For example, a command such as "circle r:50" could be entered and Inkscpae will produce a circle of radius 50px, with all other attributes set to default values. In this way, technical drawing becomes easier, and the interface to Inkscape from external programs is vastly increased.
 +
 +
==UI Changes==
 +
 +
The only UI integration this proposal needs is a commnd line text box and an "Enter" button. Rhino has an advanced text entry system, using a long text box under the toolbars. Eagle, a piece of CAD software also has this system.
 +
 +
In Inkscape, I anticipate this being located under the context toolbar, but above the ruler and drawing area. Ideally, a button would be provided on the main toolbar to allow this command entry box to be toggled on or off to save space for those who don't need this feature.
 +
 +
==Functionality Overview==
 +
 +
This proposal would add following functionality:
 +
*Creation of SVG items in Inkscape using just text input. Defuakt options should be supplied so that properties not important to a user can be lefto ut of the command, but still be taken care of.
 +
*Manipulation of existing objects (scaling, duplication, deletion, etc)
 +
*Allow the request of document information by external applications (eg. request document size or the properties of a given object etc)
 +
*Increasing document manipulation by textual means (page size, exporting etc)
 +
*Allow extensions and 3d party applications to have a simple way of editing Inkscape documents. All they would have to do is supply the command string, rather than as they do now, mess around with inkex helper modules, etc.
 +
 +
==Basic Command Structure==
 +
 +
This section is extremely preliminary and is mostly based on a Python mockup rather than practical reasons. Hopefully, at some point a formal grammar will be established.
 +
 +
More than one command can be entered at once. These are separated by a semicolon. The last command should not need a semicolon.
 +
 +
cmd1; cmd2; cmd3
 +
 +
Each command is made up of a command header and a zero or more of parameters, separated by spaces:
 +
 +
cmd 1
 +
cmd2 param2
 +
cmd3 param31 param32
 +
 +
Each parameter is made up of one or more arguments, separated by colons:
 +
 +
cmd1 p1:arg1
 +
cmd2 p21:arg211 p22:arg221:arg222
 +
 +
If an argument represents an item that needs more than one value (such as coordinates), these are separated by commas:
 +
 +
cmd1 p1:arg11,arg12 p2:arg2
 +
 +
For example, a circle with a radius of 50px and centre (500,400)px could be entered as:
 +
circle r:50 c:500,400
 +
 +
It should also be possible to enter an expression. In this way:
 +
circle r:25/2
 +
should end up as a circle with a radius of 12.5px. This would dramically reduce the time spend moving data between calculator apps and Inkscape in the case especially of technical drawing.
 +
 +
Different units should be easily used, so that one may easily use Inkscape software for engineering purposes.
 +
circle r:10mm
 +
should be automatically translated into px and render as a circle 10mm across.
 +
 +
==Error Handling==
 +
 +
The parser for these commands should catch errors wherever possible, and be able to give detailed reasons why it failed. This will help third parties develop an understanding of Inkscape's command structure (useful for encourage its use as a technical drawing aid) and allow easy debugging of external code.
 +
 +
For example the entry (say)
 +
circle er:45
 +
should fail with the reason that 'er' is not a known command header.
 +
 +
The same goes for incorrect numbers of arguments or subarguments, incorrect units (eg one should not be able to specify 'px' for a colour)
 +
 +
==Documentation==
 +
 +
The Inkscape command structure should have a detailed and thourough explanation on the Inkscape wiki or elsewhere. Ideally, one should be able to summon the help for a function using a command such as
 +
 +
help:circle
 +
 +
Which will link to the relevant online resource.
 +
 +
==Extensibility==
 +
 +
The command structure should be easily extended to new functions and commands. Perhaps an XML-based list of commands and available parameters can be provided to allow quick integration of new functions, as well as providing brief help if needed.
 +
 +
Here, accesibility is the aim of the game, as we want new capabilities to the command line tool to be easy to produce and implement.

Revision as of 07:11, 8 October 2008

Outline

At the moment, Inkscape does not allow users to enter commands to Inkscape in a text-based format. This specification proposed to add that functionality, both at the command line and internally, possibly using a command-line box similar to Rhino's. In this way, a user will be able to directly enter precise instruction to Inkscape with minimal effort. For example, a command such as "circle r:50" could be entered and Inkscpae will produce a circle of radius 50px, with all other attributes set to default values. In this way, technical drawing becomes easier, and the interface to Inkscape from external programs is vastly increased.

UI Changes

The only UI integration this proposal needs is a commnd line text box and an "Enter" button. Rhino has an advanced text entry system, using a long text box under the toolbars. Eagle, a piece of CAD software also has this system.

In Inkscape, I anticipate this being located under the context toolbar, but above the ruler and drawing area. Ideally, a button would be provided on the main toolbar to allow this command entry box to be toggled on or off to save space for those who don't need this feature.

Functionality Overview

This proposal would add following functionality:

  • Creation of SVG items in Inkscape using just text input. Defuakt options should be supplied so that properties not important to a user can be lefto ut of the command, but still be taken care of.
  • Manipulation of existing objects (scaling, duplication, deletion, etc)
  • Allow the request of document information by external applications (eg. request document size or the properties of a given object etc)
  • Increasing document manipulation by textual means (page size, exporting etc)
  • Allow extensions and 3d party applications to have a simple way of editing Inkscape documents. All they would have to do is supply the command string, rather than as they do now, mess around with inkex helper modules, etc.

Basic Command Structure

This section is extremely preliminary and is mostly based on a Python mockup rather than practical reasons. Hopefully, at some point a formal grammar will be established.

More than one command can be entered at once. These are separated by a semicolon. The last command should not need a semicolon.

cmd1; cmd2; cmd3

Each command is made up of a command header and a zero or more of parameters, separated by spaces:

cmd 1
cmd2 param2
cmd3 param31 param32

Each parameter is made up of one or more arguments, separated by colons:

cmd1 p1:arg1
cmd2 p21:arg211 p22:arg221:arg222

If an argument represents an item that needs more than one value (such as coordinates), these are separated by commas:

cmd1 p1:arg11,arg12 p2:arg2

For example, a circle with a radius of 50px and centre (500,400)px could be entered as:

circle r:50 c:500,400

It should also be possible to enter an expression. In this way:

circle r:25/2

should end up as a circle with a radius of 12.5px. This would dramically reduce the time spend moving data between calculator apps and Inkscape in the case especially of technical drawing.

Different units should be easily used, so that one may easily use Inkscape software for engineering purposes.

circle r:10mm

should be automatically translated into px and render as a circle 10mm across.

Error Handling

The parser for these commands should catch errors wherever possible, and be able to give detailed reasons why it failed. This will help third parties develop an understanding of Inkscape's command structure (useful for encourage its use as a technical drawing aid) and allow easy debugging of external code.

For example the entry (say)

circle er:45

should fail with the reason that 'er' is not a known command header.

The same goes for incorrect numbers of arguments or subarguments, incorrect units (eg one should not be able to specify 'px' for a colour)

Documentation

The Inkscape command structure should have a detailed and thourough explanation on the Inkscape wiki or elsewhere. Ideally, one should be able to summon the help for a function using a command such as

help:circle

Which will link to the relevant online resource.

Extensibility

The command structure should be easily extended to new functions and commands. Perhaps an XML-based list of commands and available parameters can be provided to allow quick integration of new functions, as well as providing brief help if needed.

Here, accesibility is the aim of the game, as we want new capabilities to the command line tool to be easy to produce and implement.