Page 1 of 1

how to get real coordinates for Insertion of a block

Posted: 05 Jul 2019, 13:48
by pavel.grigoryev
There is a lot of insertions of one block in a CADImage. Block contains some set of lines.
How to calculate real coordinates for a specific insertion?
Didn't found example in Demos.

Thanks

Re: how to get real coordinates for Insertion of a block

Posted: 05 Jul 2019, 20:55
by support
Hello Pavel,

Real coordinates of block entities for a specific insertion (TsgDXFInsert object) are calculated relatively to the insertion point (TsgDXFInsert.Point). You need to add the insertion point coordinates and coordinates of TsgDXFLine (or any other entity) in the block using an AddFPoint function which is implemented in sgFunction.pas. For example:

Code: Select all

var
  vStartPoint, vEndPoint: TFPoint;
  vDXFInsert: TsgDXFInsert;
...

vStartPoint := AddFPoint(vDXFInsert.Point, TsgDXFLine(vDXFInsert.Block.Entities[I]).Point);
vEndPoint := AddFPoint(vDXFInsert.Point, TsgDXFLine(vDXFInsert.Block.Entities[I]).Point1);
Mikhail

Re: how to get real coordinates for Insertion of a block

Posted: 08 Jul 2019, 19:04
by pavel.grigoryev
Thanks for reply.

I've looked in source of the AddFPoint function. There is nothing about such Insertion parameters as Scale and Angle. May be I need some function that use Matrix property?
Block object also has property Offset. Should it be involved in calculations too?

Code: Select all

Block #1 (24 lines): 
Offset: X=0,00 Y=0,00; Box: L=811330,54 T=717214,55 R=811363,28 B=717188,29

Insert:
Angle: 0,00;   Scale: X=-1,00 Y=1,00; Point: X=810463,56  Y:-716702,68
Angle: 7,49;   Scale: X=1,00 Y=1,00;  Point: X=-709634,02 Y:-816594,83
Angle: 101,27; Scale: X=1,00 Y=1,00;  Point: X=863204,19  Y:-655433,75

Block #2 (340 lines): 
Offset: X=0,00 Y=0,00; Box: L=-188,51 T=184,80 R=175,03 B=-150,13

Insert:
Angle: 0,00; Scale: X=0,49 Y=0,49; Point: X=-465,40 Y:533,48
Angle: 0,00; Scale: X=0,49 Y=0,49; Point: X=-789,31 Y:533,48

Re: how to get real coordinates for Insertion of a block

Posted: 09 Jul 2019, 15:43
by pavel.grigoryev
better solution - using FPointXMat function.

Code: Select all

var
  i: integer;
  aMatrix: TFMatrix;
  vStartPoint, vEndPoint: TFPoint;
  vDXFInsert: TsgDXFInsert;
...  
aMatrix := vDXFInsert.GetMatrix;
for i := 0  to vDXFInsert.Block.Count-1 do
begin
  vStartPoint := FPointXMat(TsgDXFLine(vDXFInsert.Block.Entities[i]).Point, aMatrix);
  vEndPoint := FPointXMat(TsgDXFLine(vDXFInsert.Block.Entities[i]).Point1, aMatrix);
...
end;