# Bug ZwCAD2017 COM intefrace for TranslateCoordinates

Janusz8660

Assistant Engineer

posts: 14

Registered: 2016-1-11

Message 1 of 10

Bug ZwCAD2017 COM intefrace for TranslateCoordinates
12-03-2017 11:34 . pm   |   View his/her posts only
Hello again,
I found error in COM/VBA method TranslateCoordinates when try converting coordinates OCS -> WCS:

pOcs=Poly2d.Coordinate(0)
pOcs(2)=Poly2d.Elevation

point3d=ActiveDocument.Utility.TranslateCoordinates(pOcs,zcOcs,zcUcs,1,Poly2d.Normal);
returned var is undefined:

Probably error exist only in context OCS->WCS.
I checked conversion coordinates UCS->WCS and all is ok:

point3d=ActiveDocument.Utility.TranslateCoordinates(pOcs,zcOcs,zcUcs,1,nil);
returned var is correct

- check this error/bug and anticipate solving time.
- suggest alternate method to get WCS coordinates for LwPolyline points when normal isn't 0/0/1 and UCSORG is other than (0,0,0)

J.

withje8478

posts: 572

Registered: 2015-6-9

Message 2 of 10

13-03-2017 12:02 . pm   |   View his/her posts only

Hello, we check the TranslateCoordinates by the following example from, and it works OK. Could you provide a test example for us to check? Thanks.

Sub TestTranslateCoordinates()
' Create a polyline in model space.
Dim points(0 To 14) As Double

' Define the 2D polyline points
points(0) = 0: points(1) = 1: points(2) = 1
points(3) = 0: points(4) = 2: points(5) = 1
points(6) = 0: points(7) = 2: points(8) = 2
points(9) = 0: points(10) = 2: points(11) = 3
points(12) = 0: points(13) = 4: points(14) = 4

' Create a light weight Polyline object in model space

' Find the X and Y coordinates of the
' first vertex of the polyline
Dim firstVertex As Variant
firstVertex = plineObj.Coordinate(0)

' Find the Z coordinate for the polyline
' using the elevation property
firstVertex(2) = plineObj.Elevation

' Change the normal for the pline so that the
' difference between the coordinate systems
' is obvious.
Dim plineNormal(0 To 2) As Double
plineNormal(0) = 0#
plineNormal(1) = 1#
plineNormal(2) = 2#
plineObj.Normal = plineNormal

' Translate the OCS coordinate into WCS
Dim coordinateWCS As Variant
coordinateWCS = ThisDrawing.Utility.TranslateCoordinates _
(firstVertex, acOCS, acWorld, 1, plineNormal)

' Display the coordinates of the point
MsgBox "The first vertex has the following coordinates:" _
& vbCrLf & "OCS: " & firstVertex(0) & ", " & _
firstVertex(1) & ", " & firstVertex(2) & vbCrLf & _
"WCS: " & coordinateWCS(0) & ", " & _
coordinateWCS(1) & ", " & coordinateWCS(2)
End Sub

Janusz8660

Assistant Engineer

posts: 14

Registered: 2016-1-11

Message 3 of 10

13-03-2017 05:38 . pm   |   View his/her posts only

Please check results for cases :

1. OCSvertex2d=[3,1]
Elevation=1.5
planeNormal=[0,0,-1]

ZwCAD return WCS: [3.0 ,1.0, 1.5] ' ERROR!
Acad return WCS: [-3.0,1.0,-1.5] ' OK!

2. OCSvertex2d=[3,1]
Elevation=1.5
planeNormal=[0,-1,0]

ZwCAD return WCS: [3.0 ,1.0, 1.5] ' ERROR!
Acad return WCS: [3.0,-1.5, 1.0] ' OK!

J.

Janusz8660

Assistant Engineer

posts: 14

Registered: 2016-1-11

Message 4 of 10

27-03-2017 05:50 . am   |   View his/her posts only
Post Last Edit by Janusz8660 at 2017-3-27 06:02

Jeffrey, any progress in checking this data?

I prepare script for checking case 1 :

Sub TestTranslateCoordinates()
' Create a polyline in model space.
Dim points(0 To 14) As Double

' Define the 2D polyline points
points(0) = 3: points(1) = 1: points(2) = 1
points(3) = 0: points(4) = 2: points(5) = 1
points(6) = 0: points(7) = 2: points(8) = 2
points(9) = 0: points(10) = 2: points(11) = 3
points(12) = 0: points(13) = 4: points(14) = 4

' Create a light weight Polyline object in model space

plineObj.Elevation = 1.5

' Find the X and Y coordinates of the
' first vertex of the polyline
Dim firstVertex As Variant
firstVertex = plineObj.Coordinate(0)

' Find the Z coordinate for the polyline
' using the elevation property
firstVertex(2) = plineObj.Elevation

' Change the normal for the pline so that the
' difference between the coordinate systems
' is obvious.
Dim plineNormal(0 To 2) As Double
plineNormal(0) = 0#
plineNormal(1) = 0#
plineNormal(2) = -1#
plineObj.Normal = plineNormal

' Translate the OCS coordinate into WCS
Dim coordinateWCS As Variant
coordinateWCS = ThisDrawing.Utility.TranslateCoordinates _
(firstVertex, acOCS, acWorld, 1, plineNormal)

' Display the coordinates of the point
MsgBox "The first vertex has the following coordinates:" & vbCrLf & _
"OCS: " & firstVertex(0) & ", " & firstVertex(1) & " + Elevation:" & firstVertex(2) & vbCrLf & _
"PlaneNormal: " & plineNormal(0) & ", " & plineNormal(1) & ", " & plineNormal(2) & vbCrLf & _
"OCS->WCS: " & coordinateWCS(0) & ", " & coordinateWCS(1) & ", " & coordinateWCS(2)
End Sub

Janusz8660

Assistant Engineer

posts: 14

Registered: 2016-1-11

Message 5 of 10

27-03-2017 06:00 . am   |   View his/her posts only
Post Last Edit by Janusz8660 at 2017-3-27 06:04

ZWCAD return 3 ,1 , 1.5

Should -3.0,1.0,-1.5

withje8478

posts: 572

Registered: 2015-6-9

Message 6 of 10

29-03-2017 02:09 . pm   |   View his/her posts only

Hi, the issue is confirmed as bug ID T13536. We will fix it ASAP.

Thank you.

Janusz8660

Assistant Engineer

posts: 14

Registered: 2016-1-11

Message 7 of 10

31-07-2017 10:46 . pm   |   View his/her posts only
Hello ZwSOFT.
Any chance in ZWCAD 2018 ?

It is very common bug in ZWCAD 2017 API - blocking official way for translations 2D->3D space

withje8478

posts: 572

Registered: 2015-6-9

Message 8 of 10

01-08-2017 08:44 . am   |   View his/her posts only

Janusz,

We will try to push issue ID T13536 to be solved ASAP in ZWCAD 2018. Thanks.

posts: 141

Registered: 2016-4-14

Message 9 of 10

11-10-2017 03:52 . pm   |   View his/her posts only

Hi,
This issue is fixed in a special package of ZWCAD 2018, you can get the package from our local Poland partner, please contact them via their website <https://www.zwcad.pl/>;. After you get the package, you also need to modify your code: "acOCS" and "acWorld" cannot be recognized in ZWCAD, need to change them to "zcOCS" and "zcWorld".

Janusz8660

Assistant Engineer

posts: 14

Registered: 2016-1-11

Message 10 of 10

11-10-2017 05:40 . pm   |   View his/her posts only
Hi,
I confirm,
Zwcad 2018 vernum 21849 (PLK) solve this issue.

Thanks,
Janusz