Change UCS
Moderators: SDS, support, admin
-
- Posts: 4
- Joined: 08 Jan 2021, 00:26
Change UCS
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
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
Re: Change UCS
Hello Ana,
Could you please attach an example AutoCAD file which contains the UCS you want to rotate?
Mikhail
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
Chat support on Skype: cadsofttools.support
-
- Posts: 4
- Joined: 08 Jan 2021, 00:26
Re: Change UCS
Hello Mikhail,
Here's a simple example of an circle.
Thanks for your attention.
Ana
Here's a simple example of an circle.
Thanks for your attention.
Ana
- Attachments
-
- circle.zip
- (26.77 KiB) Downloaded 610 times
Re: Change UCS
Hello Ana,
It is possible to change the origin and axis directions for current UCS through the header variables:
The call will give you the attached result.
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;
Code: Select all
UpdateUCS(FCADFile.Converter, MakeFPoint(100, 100, 0), MakeFPoint(0, 0, 1), MakeFPoint(1, 0, 0));
- Attachments
-
- circle_ucs_yzx.zip
- (5.79 KiB) Downloaded 547 times
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 4
- Joined: 08 Jan 2021, 00:26
Re: Change UCS
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
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
Re: Change UCS
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
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
Chat support on Skype: cadsofttools.support
-
- Posts: 4
- Joined: 08 Jan 2021, 00:26
Re: Change UCS
ok, thank you very much.
I must have opened the previous file.
Best regards,
Ana
I must have opened the previous file.
Best regards,
Ana