We have moved to https://dokuwiki.librecad.org/

Lots of content was already moved to the new wiki, but there is still work to do. If you want to contribute, please register a new account at https://dokuwiki.librecad.org/

This wiki will be kept for a while to keep search engine results valid. Moved sites may be deleted here in future.

A short manual for use from the command line

From LibreCAD wiki
Revision as of 12:44, 16 April 2012 by Stano Sitar (Talk | contribs)

Jump to: navigation, search

Written by Stano Sitar. WORK IN PROGRESS


Introduction

This is intended for AutoCAD veterans that are trained in using commandline and for people that want to draw by entering commands. This can be faster and/or more precise than drawing using exclusively mouse and icons.

LibreCAD is designed with emphasis on mouse-clicking input, and some options can be at the moment only selected by clicking, not by typing on commandline.

Where did I get material for writing this very short manual?

Well, I saw that there was no suitable material apart from the Qcad manual that is copyrighted and can't be used as a base for LibreCAD manual. So I have downloaded source code from http://librecad.org/cms/home/from-source/linux.html and found file rs_commands.cpp that listed all the commands. Then I proceed to try all the commands out in LibreCAD keeping notes. I have lots of experience with other CAD programs, especially with AutoCAD so I tried some obvious possibilities, like relative and angular coordinates.

Using the Commandline

For LibreCad ver. 1.x.y you have to press Ctrl+M to get to the commandline editing mode, in Version 2.x.y you can also press space.

You can also click on line next to Command: prompt at the bottom of the screen.

You press Escape key to leave commandline and another Escape to cancel what you have written on the commandline.

It is possible to enter partial command, like cir and press Tab to have the command completed to circle. If you type too short segment of command, such as c and press Tab, you get prompted ch, circle to show you that the command segment you typed in isn't unique and to show you what are possible completitions.

Many commands prompt you on commandline asking for further input. They tell you what input they expect - a point for example - and list other possibilities in the square bracket. For example if you type command polyline and draw at least two segments you get prompted Specify next point or [undo/close]. This means that the program is expecting a point (from commandline or by clicking on drawing area), or you can select Undo or Close option. You can do that by typing on commandline of by clicking on buttons on context toolbar called Tool Options.

When there is some value already set and valid, for example when you use command offset, the current value is in sharp brackets, like so: Specify distance <5> or select entity or [Through]. So you see that value for offset is 5 and you can either set a new value by typing it into commandline or using Tool Options toolbar or you can start drawing parallel entities.

Drawing entities

Drawing a point

You type point or po on the commandline. LibreCad prompts you to with "Specify Location".

The main toobar on the left changes to the snap selection where you can select icons for Free positioning, Snap to grid, Snap to Enpoints and so on.

After selecting apropriate snapping option on the main toolbar you can respond by clicking with the mouse on drawing area to enter points.

Or you can use commandline to select an option like sc - snap to center, sn - snap none, sg - snap grid and then proceed with clicking with the mouse on drawing area to enter points. See chapter Snapping for all the options that can be entered from the commandline.

Or you can enter points using following syntax

10,20[enter] - to place point at coordinates x=10, y=20 from the origin - point x=0, y=0

@30,40[enter] - to place point at coordinates that are at distance x=30, y=40 from the last drawn point. So when I draw two points 10,20 and then @30,40 the first point is locted at the x=10, y=20 and the second at x=10+30=40 and y=20+40=60.

50<45[enter] - to place point at the distance 50 from origin, at 45 angle degree. The positive x axis is at 0 degrees, the positive y axis is at 90 degrees. So degrees are measured at counter clockwise direction from horizontal.

@ 60<15[enter] - to place point at the distance 60 at 15 angle degree from the last drawn point.

Line from rs_commands.cpp: "point", RS2::ActionDrawPoint; "po", RS2::ActionDrawPoint;

Drawing a line

You type line or li or l on the commandline. LibreCad prompts you to with "Specify first point".

The main toobar on the left changes to the snap selection where you can select icons for Free positioning, Snap to grid, Snap to Enpoints and so on.

After selecting apropriate snapping option on the main toolbar you can respond by clicking with the mouse on drawing area to enter point.

Or you can use commandline to select an option like sc - snap to center, sn - snap none, sg - snap grid and then proceed with clicking with the mouse on drawing area to enter point. See chapter Snapping for all the options that can be entered from the commandline.

Or you can enter points from commandline using syntax described in "Drawing a point"

After you enter a point, LibreCAD propmts for "specify next point" and you finish drawing the first line in "chain" by entering a point by mouse or keyboard.

For the next point LibreCAD prompts you "specify next point or [undo]". Here you can continue to draw next segment of line, or undo the previous segment. When you type in undo or u LibreCAD un-does the last segment (and will complain "Unknown command: u" - which is clearly a bug.). You can also use Ctrl-z shortcut.

If there are at least two segments drawn, the prompt for line is specify next point or [undo/close] and you can "close" the line - draw a segment to the point where you started. To finish drawing lines you press [Esc]

Please notice, that line is different from polyline. They are drawn in a very similar manner, but when you want to edit a line - copy, delete or move, you have to select all segments of line one-by-one. Multiple segments are just individual lines. With polyline - all segments are one entity that can be selected with one click.

Line from rs_commands.cpp: "line", RS2::ActionDrawLine; "ln", RS2::ActionDrawLine; "l", RS2::ActionDrawLine;

Drawing a polyline

You type polyline on the commandline. LibreCad prompts you to with "Specify first point".

You draw polyline exactly as you would draw a line (see above). The only difference is that all the segments of polyline are a single entity.

Line from rs_commands.cpp: "polyline", RS2::ActionDrawPolyline;

Drawing a line or other entity with an offset

You type offset or o on the commandline. LibreCad prompts you to with "Specify distance <1> or select entity ot [Through]". You can enter number from commandline or using Tool Options toolbar, you can select Through option. The default action is to click near an entity, indicating what side you wish to place the offset on. Offset works on lines, polylines (but only on one segment), circles, arcs, polygons (but only on one segment). Offset doesn't work on ellipses, bezier curves (here it kinda-sorta works but not the way you might expect)

Line from rs_commands.cpp: "offset", RS2::ActionDrawLineParallel; "o", "offset", RS2::ActionDrawLineParallel;

Drawing parallel lines

You type parallel or par on the commandline.

This seems to be the same functionality as offset command.


Line from rs_commands.cpp: "parallel", RS2::ActionDrawLineParallel; "par", "parallel", RS2::ActionDrawLineParallel;


// Below is only code copied from rs_commands.cpp to work as reference for writing manual:

Line from rs_commands.cpp: "arc", RS2::ActionDrawArc3P; "a", RS2::ActionDrawArc3P;

Line from rs_commands.cpp: "circle", RS2::ActionDrawCircle; "ci", RS2::ActionDrawCircle;

Line from rs_commands.cpp: "rectangle", RS2::ActionDrawLineRectangle; "rec", RS2::ActionDrawLineRectangle; "rectang", RS2::ActionDrawLineRectangle;

Line from rs_commands.cpp: "polyline", RS2::ActionDrawPolyline;

Line from rs_commands.cpp: "text", RS2::ActionDrawText;


Chapter 2. Zooming // zoom: "regen", RS2::ActionZoomRedraw; "rg", "zoom - redraw", RS2::ActionZoomRedraw; "zr", "zoom - redraw", RS2::ActionZoomRedraw;

"zw", "zoom - window", RS2::ActionZoomWindow;

"za", "zoom - auto", RS2::ActionZoomAuto;

"zp", "zoom - pan", RS2::ActionZoomPan;

"zv", "zoom - previous", RS2::ActionZoomPrevious;

// edit: "kill", RS2::ActionEditKillAllActions; "k", RS2::ActionEditKillAllActions;

"undo", RS2::ActionEditUndo; "u", "undo", RS2::ActionEditUndo;

"redo", RS2::ActionEditRedo; "r", RS2::ActionEditRedo;

       // dimensions:

"da", "dimension - aligned", RS2::ActionDimAligned; "da", RS2::ActionDimAligned;

"dh", "dimension - horizontal", RS2::ActionDimLinearHor; "dh", RS2::ActionDimLinearHor;

"dr", "dimension - linear", RS2::ActionDimLinear; "dr", RS2::ActionDimLinear;

"dv", "dimension - vertical", RS2::ActionDimLinearVer; "dv", RS2::ActionDimLinearVer;

"ld", "dimension - leader", RS2::ActionDimLeader; "ld", RS2::ActionDimLeader;

// tools: "dimregen", RS2::ActionToolRegenerateDimensions;

       // modify:

"tm", "modify - multi trim (extend", RS2::ActionModifyTrim2; "tm", RS2::ActionModifyTrim2;

"xt", "modify - trim (extend", RS2::ActionModifyTrim; "xt", RS2::ActionModifyTrim;

"rm", "modify - trim", RS2::ActionModifyTrim; "rm", RS2::ActionModifyTrim;

"mv", "modify - move", RS2::ActionModifyMove; "mv", RS2::ActionModifyMove;

"ch", "modify - bevel (chamfer", RS2::ActionModifyBevel; "ch", RS2::ActionModifyBevel;

"mi", "modify - mirror", RS2::ActionModifyMirror; "mi", RS2::ActionModifyMirror;

"ro", "modify - rotate", RS2::ActionModifyRotate; "ro", RS2::ActionModifyRotate;

"sz", "modify - scale", RS2::ActionModifyMove; "sz", RS2::ActionModifyMove;

"ss", "modify - stretch", RS2::ActionModifyStretch; "ss", RS2::ActionModifyStretch;

"er", "modify - delete (erase", RS2::ActionModifyDelete; "er", RS2::ActionModifyDelete;

"oo", "modify - undo (oops", RS2::ActionEditUndo; "oo", RS2::ActionEditUndo;

"uu", "modify - redo", RS2::ActionEditRedo; "uu", RS2::ActionEditRedo;

"xp", "modify - explode", RS2::ActionBlocksExplode; "xp", RS2::ActionBlocksExplode;

       // snap:

"os", "snap - none", RS2::ActionSnapFree; "os", RS2::ActionSnapFree;

"sc", "snap - center", RS2::ActionSnapCenter; "sc", RS2::ActionSnapCenter;

"sd", "snap - distance", RS2::ActionSnapDist; "sd", RS2::ActionSnapDist;

"se", "snap - end", RS2::ActionSnapEndpoint; "se", RS2::ActionSnapEndpoint;

"sf", "snap - free", RS2::ActionSnapFree; "sf", RS2::ActionSnapFree;

"sg", "snap - grid", RS2::ActionSnapGrid; "sg", RS2::ActionSnapGrid;

"si", "snap - intersection", RS2::ActionSnapIntersection; "si", RS2::ActionSnapIntersection;

"sm", "snap - middle", RS2::ActionSnapMiddle; "sm", RS2::ActionSnapMiddle;

"sn", "snap - nearest", RS2::ActionSnapOnEntity; "sn", RS2::ActionSnapOnEntity;

"np", "snap - nearest point", RS2::ActionSnapOnEntity; "np", RS2::ActionSnapOnEntity;

       // selection:

"sa", "Select all", RS2::ActionSelectAll; "sa", RS2::ActionSelectAll;

"tn", "Deselect all", RS2::ActionDeselectAll; "tn", RS2::ActionDeselectAll;



   // draw:
   if (c==tr("po", "point")) {
       ret = RS2::ActionDrawPoint;
   } else if (c==tr("li", "line")) {
       ret = RS2::ActionDrawLine;
   } else if (c==tr("pa", "parallel")) {
       ret = RS2::ActionDrawLine;
   } else if (c==tr("re", "rectangle")) {
       ret = RS2::ActionDrawLineRectangle;
   } else if (c==tr("rp", "regular polygon")) {
       ret = RS2::ActionDrawLinePolygon;
   } else if (c==tr("ci", "circle")) {
       ret = RS2::ActionDrawCircle;
   } else if (c==tr("c2", "2 point circle")) {
       ret = RS2::ActionDrawCircle2P;
   } else if (c==tr("c3", "3 point circle")) {
       ret = RS2::ActionDrawCircle3P;
   } else if (c==tr("ar", "arc")) {
       ret = RS2::ActionDrawArc;
   } else if (c==tr("a3", "3 point arc")) {
       ret = RS2::ActionDrawArc3P;
   } else if (c==tr("ep", "ellipse")) {
       ret = RS2::ActionDrawEllipseAxis;
   } else if (c==tr("tx", "text") || c==tr("mt", "text")) {
       ret = RS2::ActionDrawText;
   }

// dimensions:

   else if (c==tr("da", "dimension - aligned")) {
       ret = RS2::ActionDimAligned;
   } else if (c==tr("dh", "dimension - horizontal")) {
       ret = RS2::ActionDimLinearHor;
   } else if (c==tr("dv", "dimension - vertical")) {
       ret = RS2::ActionDimLinearVer;
   } else if (c==tr("dr", "dimension - linear")) {
       ret = RS2::ActionDimLinear;
   } else if (c==tr("ld", "dimension - leader")) {
       ret = RS2::ActionDimLeader;

}

   // zoom:
   else if (c==tr("rd", "redraw")) {
       ret = RS2::ActionZoomRedraw;
   } else if (c==tr("zw", "zoom - window")) {
       ret = RS2::ActionZoomWindow;
   } else if (c==tr("za", "zoom - auto")) {
       ret = RS2::ActionZoomAuto;
   } else if (c==tr("zi", "zoom - in")) {
       ret = RS2::ActionZoomIn;
   } else if (c==tr("zo", "zoom - out")) {
       ret = RS2::ActionZoomOut;
   } else if (c==tr("zp", "zoom - pan")) {
       ret = RS2::ActionZoomPan;
   } else if (c==tr("zv", "zoom - previous")) {
       ret = RS2::ActionZoomPrevious;
   }

// snap: else if (c==tr("os", "snap - none")) { ret = RS2::ActionSnapFree;

   } else if (c==tr("sc", "snap - center")) {
       ret = RS2::ActionSnapCenter;
   } else if (c==tr("se", "snap - end")) {
       ret = RS2::ActionSnapEndpoint;
   }else if (c==tr("sf", "snap - free")) {
       ret = RS2::ActionSnapFree;
   } else if (c==tr("sg", "snap - grid")) {

ret = RS2::ActionSnapGrid; } else if (c==tr("si", "snap - intersection")) { ret = RS2::ActionSnapIntersection; } else if (c==tr("sm", "snap - middle")) { ret = RS2::ActionSnapMiddle;

   } else if (c==tr("sn", "snap - nearest")) {
       ret = RS2::ActionSnapOnEntity;
   } else if (c==tr("np", "snap - nearest point")) {

ret = RS2::ActionSnapOnEntity; }

// layer: else if (c==tr("fr*", "layers - freeze all")) { ret = RS2::ActionLayersFreezeAll; } else if (c==tr("th*", "layers - defreeze all")) { ret = RS2::ActionLayersDefreezeAll; }

// selection: else if (c==tr("tn", "Deselect all")) { ret = RS2::ActionDeselectAll; }

// modify: else if (c==tr("ch", "modify - bevel (chamfer)")) { ret = RS2::ActionModifyBevel; } else if (c==tr("tm", "modify - multi trim (extend)")) { ret = RS2::ActionModifyTrim2; } else if (c==tr("xt", "modify - trim (extend)")) { ret = RS2::ActionModifyTrim; } else if (c==tr("rm", "modify - trim")) { ret = RS2::ActionModifyTrim; } else if (c==tr("mv", "modify - move")) { ret = RS2::ActionModifyMove; } else if (c==tr("mi", "modify - mirror")) { ret = RS2::ActionModifyMirror; } else if (c==tr("ro", "modify - rotate")) { ret = RS2::ActionModifyRotate; } else if (c==tr("sz", "modify - scale")) { ret = RS2::ActionModifyMove; } else if (c==tr("ss", "modify - stretch")) { ret = RS2::ActionModifyStretch; } else if (c==tr("er", "modify - delete (erase)")) { ret = RS2::ActionModifyDelete; } else if (c==tr("oo", "modify - undo (oops)")) { ret = RS2::ActionEditUndo; } else if (c==tr("uu", "modify - redo")) { ret = RS2::ActionEditRedo; } else if (c==tr("xp", "modify - explode") || c==tr("ex", "modify - explode")) { ret = RS2::ActionBlocksExplode; }


   if (cmd=="angle") {
       return tr("angle");
   } else if (cmd=="close") {
       return tr("close");
   } else if (cmd=="chord length") {
       return tr("chord length");
   } else if (cmd=="columns") {
       return tr("columns");
   } else if (cmd=="columnspacing") {
       return tr("columnspacing");
   } else if (cmd=="factor") {
       return tr("factor");
   } else if (cmd=="length") {
       return tr("length");
   } else if (cmd=="length1") {
       return tr("length1");
   } else if (cmd=="length2") {
       return tr("length2");
   } else if (cmd=="number") {
       return tr("number");
   } else if (cmd=="radius") {
       return tr("radius");
   } else if (cmd=="rows") {
       return tr("rows");
   } else if (cmd=="rowspacing") {
       return tr("rowspacing");
   } else if (cmd=="text") {
       return tr("text");
   } else if (cmd=="through") {
       return tr("through");
   } else if (cmd=="trim") {
       return tr("trim");
   } else if (cmd=="undo") {
       return tr("undo");
   } else if (cmd=="back") {
       return tr("back");
   }


   if (cmd=="angle") {
       if (strl==tr("angle") || strl==tr("ang", "angle") ||
               strl==tr("a", "angle")) {
           return true;
       }
   } else if (cmd=="center") {
       if (strl==tr("center") || strl==tr("cen", "center") ||
               strl==tr("c", "center")) {
           return true;
       }
   } else if (cmd=="chord length") {
       if (strl==tr("length", "chord length") ||
               strl==tr("l", "chord length")) {
           return true;
       }
   } else if (cmd=="close") {
       if (strl==tr("close") ||
               strl==tr("c", "close")) {
           return true;
       }
   } else if (cmd=="columns") {
       if (strl==tr("columns") || strl==tr("cols", "columns") ||
               strl==tr("c", "columns")) {
           return true;
       }
   } else if (cmd=="columnspacing") {
       if (strl==tr("columnspacing", "columnspacing for inserts") ||
               strl==tr("colspacing", "columnspacing for inserts") ||
               strl==tr("cs", "columnspacing for inserts")) {
           return true;
       }
   } else if (cmd=="factor") {
       if (strl==tr("factor") || strl==tr("fact", "factor") ||
               strl==tr("f", "factor")) {
           return true;
       }
   } else if (cmd=="help") {
       if (strl==tr("help") || strl==tr("?", "help")) {
           return true;
       }
   } else if (cmd=="length") {
       if (strl==tr("length", "length") ||
               strl==tr("len", "length") ||
               strl==tr("l", "length")) {
           return true;
       }
   } else if (cmd=="length1") {
       if (strl==tr("length1", "length1") ||
               strl==tr("len1", "length1") ||
               strl==tr("l1", "length1")) {
           return true;
       }
   } else if (cmd=="length2") {
       if (strl==tr("length2", "length2") ||
               strl==tr("len2", "length2") ||
               strl==tr("l2", "length2")) {
           return true;
       }
   } else if (cmd=="number") {
       if (strl==tr("number") ||
               strl==tr("num", "number") ||
               strl==tr("n", "number")) {
           return true;
       }
   } else if (cmd=="radius") {
       if (strl==tr("radius") ||
               strl==tr("r", "radius")) {
           return true;
       }
   } else if (cmd=="reversed") {
       if (strl==tr("reversed", "reversed arc") ||
               strl==tr("rev", "reversed arc") ||
               strl==tr("r", "reversed arc")) {
           return true;
       }
   } else if (cmd=="rows") {
       if (strl==tr("rows") || strl==tr("r", "rows")) {
           return true;
       }
   } else if (cmd=="rowspacing") {
       if (strl==tr("rowspacing", "rowspacing for inserts") ||
               strl==tr("rs", "rowspacing for inserts")) {
           return true;
       }
   } else if (cmd=="text") {
       if (strl==tr("text") ||
               strl==tr("t", "text")) {
           return true;
       }
   } else if (cmd=="through") {
       if (strl==tr("through") ||
               strl==tr("t", "through")) {
           return true;
       }
   } else if (cmd=="undo") {
       if (strl==tr("undo") ||
               strl==tr("u", "undo")) {
           return true;
       }
   } else if (cmd=="back") {
       if (strl==tr("back") ||
               strl==tr("b", "back")) {
           return true;
       }
   }