Angle of SimpleImport circular arc

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
Beginner98x
Posts: 4
Joined: 25 Apr 2006, 11:01
Location: Japan

Angle of SimpleImport circular arc

Post by Beginner98x » 12 May 2006, 13:54

Hi,

There is a case where the angle of the Insert circular arc of SimpleImport reverses.

Code: Select all

<b>procedure</b> TForm1.ReadCADEntities(Entity: TsgDXFEntity);
<b>var</b>
.....
<b>begin</b>
  C := EntColor(Entity, FCADParams.Insert);
  L := EntStyle(Entity);
  
  <b>if</b> Entity <b>is</b> TsgDXFArc <b>then
    begin</b>
      P := PtXMat(TsgDXFArc(Entity).Point, FCADParams.Matrix);
      sa := TsgDXFArc(Entity).StartAngle;
      ea := TsgDXFArc(Entity).EndAngle;

      <b>if</b> FCADParams.Insert <> <b>nil then
        if</b> FCADParams.Insert.Angle <> 0.0 <b>then
          begin</b>
            sa := sa + FCADParams.Insert.Angle;
            ea := ea + FCADParams.Insert.Angle;
          <b>end</b>;

      <b>while</b> sa > ea <b>do</b> sa:=sa-360.0;

      DB_AddArc(P.X, P.Y, TsgDXFArc(Entity).Radius, DegToRad(sa), DegToRad(ea), L, C);
    <b>end</b>;
<b>end</b>;
What is the problem?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 18 May 2006, 19:40

Hello,

If an ARC entity is located inside a block or has an extrusion, then this ARC can't be represented in planar view if it had not earlier been converted into polyline.
All CAD systems can draw an ARC as a polyline. So what you need to do is:
1) to get the transformation matrix (FCADParams.Matrix),
2) to brake the ARC into linear sections (defined by a set of points):
{ ConvertsEllipticArcToPolyline
AStart, AEnd angles in radians (AStart=0, AEnd=2*Pi for circle)
A, B - big and small radiuses (A=B for circle)
ASin, ACos - parameters that determine a tilt angle of major semiaxis of the ellipse
( - for TsgDXFEllipse object: ASin= TsgDXFEllipse.RadPt.Y/TsgDXFEllipse.Radius and ACos= TsgDXFEllipse.RadPt.X/TsgDXFEllipse.Radius;
- ASin=0, ACos=1 for circle. )

Returns list of points. Please clear this TList after using. }

Code: Select all

<b>function</b> ConvertsEllipticArcToPolyline(Arc: TsgDXFCircle; A, B, ASin, ACos, AStart, AEnd: Double): TList;
<b>const</b>
  cnstNumberPartsInCircle = 36;
<b>var</b>
  X, Y, Delta: Double;
  S, C: Extended;
  I: Integer;
  vPPoint: PFPoint;  
<b>begin</b>
  Result := TList.Create;
  Params(A, B, AStart, AEnd, ASin, ACos);  
  Delta := (AEnd - AStart) / cnstNumberPartsInCircle;
  <b>for</b> I := 0 <b>to</b> cnstNumberPartsInCircle <b>do
  begin</b>
    SinCos(AStart, S, C);
    New(vPPoint);
    X := A * C;
    Y := B * S;
    vPPoint^.X := Point.X + X * ACos - Y * ASin;
    vPPoint^.Y := Point.Y + X * ASin + Y * ACos;
    vPPoint^.Z := Point.Z;
    Result.Add(vPPoint);
    AStart := AStart + Delta;
  <b>end</b>;
<b>end</b>;
3) Do for each point from ConvertsEllipticArcToPolyline list:
vRealPoint := PtXMat(listpoint, FCADParams.Matrix);

Sergey.

please post questions to the forum or write to support@cadsofttools.com

Beginner98x
Posts: 4
Joined: 25 Apr 2006, 11:01
Location: Japan

Post by Beginner98x » 23 May 2006, 13:35

Thank you for answering.

However, the angle is necessary for me.
I want to know whether the direction of drawing is clockwise or opposite, too.

best regards.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 24 May 2006, 12:30

Hello,

Commonly this is impossible to get angle. EntArc works correctly only for some private cases and it always sets direction for ARC clockwise (otherwise, it just changes places StartPoint and EndPoint).

Sergey.

please post questions to the forum or write to support@cadsofttools.com

Post Reply