Change UCS
Posted: 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
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