• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Drawing arcs with ESTK ...

Community Expert ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

Dear friends,

Next step after lines and polylines: I want to draw arcs (with a constant radius) and encounter a similar problem as with the lines in the different quadrants.

The blue lines are what I want to achieve. The outer three are correct, their starting angle is ≥ 0. The inner ones have starting angles -90, -60 and -30 degrees, which converted to 270, 300 and 330 respectively - because negative values are not allowed (they are interpreted as 0).

Arcs01.png

I do not see how to force the Arc object to draw what I want. Drawing with UI is not easier: To get the desired angles is quite simple, but to get the arc in correct position after rotation …

It seems that I need a comparable approach to the Line function (a multitude of transformations).

#target framemaker

main();

function main () {

var j, oDoc, oFrame, x0, y0, r, th0, thf, aArcs = [];

    CM = 1857713, PT = 65536, DEGREE = 65536, pi = Math.PI;

  oDoc = app.ActiveDoc;

  oFrame = oDoc.FirstSelectedGraphicInDoc;

  if (!oFrame.ObjectValid()) {

    Alert("Select an anchored frame and try again.", Constants.FF_ALERT_CONTINUE_WARN);

    return;

  }

  for (j= 0; j < 6; j++) {                       // FM-coordinate systemin cm

    r = 2 + j*0.5;                               //  2, 2.5, 3.0, ...

    th0 = -90 + j* 30;                           // -30, 0, 30, ...

    thf = th0 + 90;

    aArcs = DrawArc(oDoc, oFrame, 5, 5, r, th0, thf);

    aArcs.BorderWidth = 0.05*CM;

    aArcs.Color = oDoc.GetNamedColor("Magenta");

    aArcs.HeadArrow = 1;                      // default arrows

  }

} //--- end main

function DrawArc(oDoc, oFrame, x0, y0, r, th0, thf) { // === Draw an arc ==========================

// Arguments  x0/y0  coordinates of center point [CM] FM coord system

//            r      radius of circular arc

//            th0    Angle (degrees) of start-point

//            thf    Angle (degrees) of end-point

// Returns    object (e.g. for grouping)

var oArc, th1,

    CM = 1857713, PT = 65536, DEGREE = 65536, pi = Math.PI;

  oArc = oDoc.NewArc(oFrame);

  oArc.Width = r * CM;

  oArc.Height= r * CM;                            // let's start with a square 90° arc

  oArc.LocX = x0 * CM;

  oArc.LocY = (y0 - r) * CM;

  if (th0 < 0) {th0 = th0 + 360;}

  oArc.Theta  = th0 * DEGREE;

  oArc.DTheta = (th0 - thf)* DEGREE;

  oArc.Theta  = th0 * DEGREE;

  oArc.DTheta = (thf - th0)* DEGREE;

  return oArc;

} //--- end DrawArc

TOPICS
Scripting

Views

441

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 05, 2019 Jan 05, 2019

Well, after much fiddling around and expeiments with various angles etc. I have this insight:

  • Angle is the rotation angle relative to the original object
  • Theta and DTheta exist only for object Arc
  • Trying to work in a mathematical/geometrical space for drawing requires some transformation.
  • The solution I found is documented in https://daube.ch/zz_tests/FM-graphics.pdf see page 29 of current issue

But:

There is a very strange thing with rotation. Any object rotated (by UI or by script) reflect the rotat

...

Votes

Translate

Translate
Community Expert ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

Copied

Modifying line 42 to

  if (th0 < 0) {

    th0 = th0 + 360;

    thf = thf + 360;

  }

did the trick at least for this set of angles...

Arcs00.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2019 Jan 05, 2019

Copy link to clipboard

Copied

LATEST

Well, after much fiddling around and expeiments with various angles etc. I have this insight:

  • Angle is the rotation angle relative to the original object
  • Theta and DTheta exist only for object Arc
  • Trying to work in a mathematical/geometrical space for drawing requires some transformation.
  • The solution I found is documented in https://daube.ch/zz_tests/FM-graphics.pdf see page 29 of current issue

But:

There is a very strange thing with rotation. Any object rotated (by UI or by script) reflect the rotation in property Ange - but not so for Line. This object always displays 0 for the rotation angle!

See the experiment describe on pages 30-31 of the mentioned pdf.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines