Change UCS

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

Moderators: SDS, support, admin

Post Reply
AnaCoutinho
Posts: 4
Joined: 08 Jan 2021, 00:26

Change UCS

Post by AnaCoutinho » 11 Jan 2021, 18:32

Hi CAD VCL forum,

I've been trying to change an entity UCS in Delphi, but it doesn't seem to do what I want.

Before and after changing the UCS I use this command to see if the result changes:
iMatrix := FCADFile.Converter.GetUCS(v2Layout);

For example, changing X direction to Z direction, using the layout:
v2Layout.UCSOrigin := MakeFPoint(0, 0, 0);
v2Layout.UCSXDir := MakeFPoint(0, 0, 1);
v2Layout.UCSYDir := MakeFPoint(1, 0, 0);

When I open the file in AutoCAD the layout is still in WCS.
Since this does not change the directions, I have tried to change de Head vars by:
sgConsts.cnstSGHeadVarStruct.UCSORG := v2Layout.UCSOrigin;
sgConsts.cnstSGHeadVarStruct.UCSXDir := v2Layout.UCSXDir;
sgConsts.cnstSGHeadVarStruct.UCSYDir := v2Layout.UCSYDir;

Another way:
FHeadVarStruct: TsgHeadVarStruct;
FHeadVarStruct.UCSORG := v2Layout.UCSOrigin;
FHeadVarStruct.UCSXDir := v2Layout.UCSXDir;
FHeadVarStruct.UCSYDir := v2Layout.UCSYDir;

Using the rotation matrix:
rMatrix := v2Layout.RotMatrix;
rMatrix.V1[0] := 0;
rMatrix.V1[1] := 0;
rMatrix.V1[2] := 1;
rMatrix.V2[0] := 1;
rMatrix.V2[1] := 0;
rMatrix.V2[2] := 0;
rMatrix.V3[0] := 0;
rMatrix.V3[1] := 1;
rMatrix.V3[2] := 0;
v2Layout.SetRotMatrix(rMatrix);

This rotates the layout, but how can I rotate the UCS?

Thanks for your attention,
Ana

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

Re: Change UCS

Post by support » 13 Jan 2021, 23:15

Hello Ana,

Could you please attach an example AutoCAD file which contains the UCS you want to rotate?

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

AnaCoutinho
Posts: 4
Joined: 08 Jan 2021, 00:26

Re: Change UCS

Post by AnaCoutinho » 14 Jan 2021, 21:34

Hello Mikhail,

Here's a simple example of an circle.

Thanks for your attention.
Ana
Attachments
circle.zip
(26.77 KiB) Downloaded 610 times

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

Re: Change UCS

Post by support » 26 Jan 2021, 06:50

Hello Ana,

It is possible to change the origin and axis directions for current UCS through the header variables:

Code: Select all

procedure UpdateUCS(AConverter: TsgDXFConverter; AUCSOrg, AUCSXDir, AUCSYDir: TFPoint);
var
  vHeadVarStruct: TsgHeadVarStruct;
begin
  vHeadVarStruct := AConverter.HeadVarStruct;
  vHeadVarStruct.UCSORG := AUCSOrg;
  vHeadVarStruct.UCSXDir := AUCSXDir;
  vHeadVarStruct.UCSYDir := AUCSYDir;
  AConverter.HeadVarStruct := vHeadVarStruct;
end;
The call

Code: Select all

UpdateUCS(FCADFile.Converter, MakeFPoint(100, 100, 0), MakeFPoint(0, 0, 1), MakeFPoint(1, 0, 0));
will give you the attached result.
Attachments
circle_ucs_yzx.zip
(5.79 KiB) Downloaded 547 times
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

AnaCoutinho
Posts: 4
Joined: 08 Jan 2021, 00:26

Re: Change UCS

Post by AnaCoutinho » 26 Jan 2021, 22:32

Hello Mikhail,

Thank you for your response.

Is the resulted circle still in the XY plane after calling UpdateUCS?
Is it possible to rotate to another plane?

I'm very grateful for your example.
Best regards,
Ana Coutinho

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

Re: Change UCS

Post by support » 27 Jan 2021, 03:35

Hello Ana,

The circle in your DWG file is not in the XY plane initially, its center has coordinates (25, 25, -1). After calling UpdateUCS coordinates of the center change to (-1, -75, -75). If you open the resulting file in AutoCAD, you will see that the Y axis has X direction and the Z axis has Y direction, thus the current UCS is YZX.

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

AnaCoutinho
Posts: 4
Joined: 08 Jan 2021, 00:26

Re: Change UCS

Post by AnaCoutinho » 27 Jan 2021, 21:56

ok, thank you very much.
I must have opened the previous file.

Best regards,
Ana

Post Reply