Sketch from command line

Help
2008-07-12
2013-04-22
  • Now i'm using the sketch editor to build a new Sketch but
    which is the command from command line ?
    I tried with "make XXX sketch" but how can insert the vertexs in the empty created sketch ?
    I tried with "in XXX sketch" but the answer is "the sketch primitive is not supported by this command"
    Thanks, Federico.

     
    • Sean Morrison
      Sean Morrison
      2008-07-14

      Frederico,

      Hm, I'm not sure I can recall anyone actually ever asking for a way to create sketches on the command line... that said, it is possible using the low-level database I/O "get" and "put" commands.  It's what the GUI-based sketch editor uses under the hood.

      Since it's only documented in source code as far as I know, the best way to describe the format is with an example.  Here's such a case where I created a simple sketch named "sketch".  If you run the "get" command, you can see the overall structure:

      mged> get sketch
      sketch V {0 0 -4.999999999999999646464397e-40} A {1 0 0} B {0 1 0} VL { {0.59800664451827234557868 -4.674418604651163100527356} {2.501661129568105934595224 -1.833887043189368792894811} {6.259136212624585304808988 -3.109634551495016552280504} {2.581395348837209002823556 -3.209302325581395720632827} {5.830564784053156479615154 -5.571428571428572062984586} {5.521594684385382478808424 -1.764119601328903774728474} {2.531561461794019862736604 -0.9966777408637871316088308} {0.1594684385382059976787872 0.2691029900332225777148665} {-2.720930232558139483245441 -1.495016611295681085991305} {1.764119601328903774728474 -1.016611295681063120710519} {0.239202657807309121418271 -2.730897009966777755352041} {1.9634551495016612232547 -2.501661129568106378684433} {-1.265780730897009931368302 -2.611295681063122930964937} } SL { { line S 0 E 1 } { carc S 2 E 1 R -1 L 0 O 0 } { bezier D 3 P { 1 3 4 5 } } { carc S 5 E 6 R 1.644755298192071224505639 L 0 O 0 } { line S 6 E 7 } { bezier D 6 P { 7 8 9 10 11 12 0 } } }

      Most of that is floating point conversion goo of course, but it boils down to what is shown in following with a V position, AxB vectors to scale/orient the sketch, a VL list of 2D vertices, and then any number of SL segment lists for lines, arcs, and bezier curves:

      sketch
      V {0 0 -4.999999999999999646464397e-40}
      A {1 0 0}
      B {0 1 0}
      VL {
         {0.59800664451827234557868 -4.674418604651163100527356}
         {2.501661129568105934595224 -1.833887043189368792894811}
         {6.259136212624585304808988 -3.109634551495016552280504}
         {2.581395348837209002823556 -3.209302325581395720632827}
         {5.830564784053156479615154 -5.571428571428572062984586}
         {5.521594684385382478808424 -1.764119601328903774728474}
         {2.531561461794019862736604 -0.9966777408637871316088308}
         {0.1594684385382059976787872 0.2691029900332225777148665}
         {-2.720930232558139483245441 -1.495016611295681085991305}
         {1.764119601328903774728474 -1.016611295681063120710519}
         {0.239202657807309121418271 -2.730897009966777755352041}
         {1.9634551495016612232547 -2.501661129568106378684433}
         {-1.265780730897009931368302 -2.611295681063122930964937}
      }
      SL {
         { line S 0 E 1 }
         { carc S 2 E 1 R -1 L 0 O 0 }
         { bezier D 3 P { 1 3 4 5 } }
         { carc S 5 E 6 R 1.644755298192071224505639 L 0 O 0 }
         { line S 6 E 7 }
         { bezier D 6 P { 7 8 9 10 11 12 0 } }
      }

      You can create one by writing out the sketch as one long Tcl line but instead of "get", you'd use put to create/update a sketch.  Example box:

      mged> put sketch3 sketch V {0 0 0} A {1 0 0} B {0 1 0} VL { {0 0} {1 0} {1 1} {0 1} } SL { {line S 0 E 1} {line S 1 E 2} {line S 2 E 3} {line S 3 E 0} }

      Example box with big rounded edges (barbell shape:

      mged> put sketch2 sketch V {0 0 0} A {1 0 0} B {0 1 0} VL { {0 0} {1 0} {1 1} {0 1} } SL { {line S 0 E 1} {carc S 1 E 2 R 1 L 0 O 0} {line S 2 E 3} {carc S 3 E 0 R 1 L 0 O 0} }

      Hope that helps some -- at least until a proper 'in' interface and/or other sketch editing services get implemented.

      Cheers!
      Sean