CAD/CAM discussion forum > CAD > Bug ZwCAD2017 COM intefrace for TranslateCoordinates

Bug ZwCAD2017 COM intefrace for TranslateCoordinates

    
  Subscribe Topic

Rank: 2

Janusz8660

Assistant Engineer

posts: 10

Registered: 2016-1-11

Message 1 of 3

 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:
(ZWCAD 2017 vernum=13656)

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


Please Zwsoft team to:
- 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)

Thanks in advance
J.

Rank: 5Rank: 5

Jeffrey_ZWCAD

posts: 384

Registered: 2015-6-9

Message 2 of 3

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


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 plineObj As ZcadPolyline
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
Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)

' 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

Rank: 2

Janusz8660

Assistant Engineer

posts: 10

Registered: 2016-1-11

Message 3 of 3

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

I use your script.
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!


ZwCAD probably not use planeNormal

J.
See also
X