DoScale2D sample

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

Moderators: support, SDS, admin

Post Reply
tf_2010
Posts: 6
Joined: 18 Mar 2016, 15:12

DoScale2D sample

Post by tf_2010 » 25 May 2016, 19:44

I need a sample with DoScale2D procedure explaining Scaling and Rotation operations with all the entities during the Iteration.
You know we can get the text log of all the entities in the demo SimpleImport - "How to get entities properties".
But all the logged coords of entities are flipped vertical :cry:
So how can I get non flipped projection of my CAD objects?

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

Re: DoScale2D sample

Post by support » 26 May 2016, 12:08

Hello,

Could you give us more information about this problem? For example, what entities (all the entities or certain types) have flipped coordinates and what CAD VCL version you are using.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

tf_2010
Posts: 6
Joined: 18 Mar 2016, 15:12

Re: DoScale2D sample

Post by tf_2010 » 30 May 2016, 01:52

support wrote:Hello,

Could you give us more information about this problem? For example, what entities (all the entities or certain types) have flipped coordinates and what CAD VCL version you are using.


Mikhail
All the entities except text have flipped coordinates in VCL version 10.0

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

Re: DoScale2D sample

Post by support » 30 May 2016, 16:23

Hello,

Could you send your drawing file to the Technical Support e-mail? We will examine the problem with coordinates.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

tf_2010
Posts: 6
Joined: 18 Mar 2016, 15:12

Re: DoScale2D sample

Post by tf_2010 » 01 Jun 2016, 22:37

support wrote:Hello,
Could you send your drawing file to the Technical Support e-mail? We will examine the problem with coordinates.
Mikhail
I did several SVG images in InkScape and got such issue :|
Just try this with any SVG image made in InkScape :D

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

Re: DoScale2D sample

Post by support » 02 Jun 2016, 21:03

Hello,

Thank you for the information. We used DXF files for testing, the entities coordinates are imported correctly from this file format. As for the SVG format, a FPointXMat function used in the SimpleImport demo project transforms and reflects SVG coordinates in the x-axis (Y coordinate values change a sign from the + to a - sign).

Let's say, you draw a line in Inkscape and save it to an .svg file. In the saved .svg file this line will be defined as follows:

Code: Select all

<path
    d="M 720.94214,22.944193 614.33009,94.601473"
    id="path2989"
    style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
Note: Inkscape actually is not reporting the SVG coordinates, but flipping the y-axis instead: the Y coordinate value is increasing as the mouse cursor goes upwards.

The <path/> element is imported as ceLWPolyline entity, so you should use an ImportPolyLine procedure in the demo project to obtain point coordinates. Let's take a look at the code which calculates coordinates of LWPolyline vertices:

Code: Select all

P := FPointXMat(Vertex.Point, FCADParams.Matrix);
If you step over this line with debugger, Vertex.Point will contain the following coordinates:

(720,94213867, 22,944192886, 0)
(614,33007812, 94,601470947, 0)

But FCADParams.Matrix.M will be ((1,811689539, 0, 0), (0, -1,811689539, 0), (0, 0, 1,811689539), (0, 0, 0)) that means the image scaling and reflection in relation to the x-axis. The reflection is applied to compensate a difference in the y-axis direction of SVG and DWG/DXF formats. In SVG files the initial coordinate system has the origin at the top/left with the x-axis pointing to the right and the y-axis pointing down, while in AutoCAD files the y-axis is upward. So, if you try to use the SVG coordinates to generate an AutoCAD DWG/DXF file, the output drawing will be flipped when viewing in AutoCAD. To get the nontransformed SVG coordinates, you should omit usage of the FPointXMat function.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply