example for adding inserts

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

Moderators: SDS, support, admin

Post Reply
pavel.grigoryev
Posts: 4
Joined: 05 Jul 2019, 13:35

example for adding inserts

Post by pavel.grigoryev » 27 Jan 2020, 18:31

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.

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

Re: example for adding inserts

Post by support » 27 Jan 2020, 20:35

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply