Page 1 of 1

example for adding inserts

Posted: 27 Jan 2020, 18:31
by pavel.grigoryev
In AddEntities example there is a code, that shows how to insert a block. But it uses only attributes.

In real draws more common situation is, when there is a set of line/polylines or other entities in a block. How to set scale and rotation for them, and separately from attributes?
I want to do several insertions of a icon in a draw. Scale is the same for them, rotations are variate, subscriptions are look alike.

Thanks.

Re: example for adding inserts

Posted: 27 Jan 2020, 20:35
by support
Hello Pavel,

Scale and rotation can be easily set for a block reference (TsgDXFInsert) through Scale and Angle properties, respectively. To apply scaling/rotation to a particular entity in the block, you will need to multiply each point of the entity by coordinate transformation matrix using an FPointXMat function (sgFunction.pas):

Code: Select all

function FPointXMat(const APoint: TFPoint; const AMatrix: TFMatrix): TFPoint;
To get a scaling matrix by a given scale value, you may use an FMatByScale function (sgFunction.pas):

Code: Select all

function FMatByScale(const Scale: Double): TFMatrix;
To get a rotation matrix by a given angle, you may use an FMatByAngle function (sgFunction.pas):

Code: Select all

function FMatByAngle(const Angle: Double): TFMatrix;
Mikhail