User
 Forgot password?
 Register
Search
Forum ZWCAD CAD Content
Post time 2017-3-12 23:34:39
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.
Post time 2017-3-13 12:02:33
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
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.
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 plineObj As ZcadPolyline
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
Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)

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
Post Last Edit by Janusz8660 at 2017-3-27 06:04

ZWCAD return   3 ,1   , 1.5

       Should -3.0,1.0,-1.5
Post time 2017-3-29 14:09:49
Reply 5# Janusz8660


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

   Thank you.
Hello ZwSOFT.
Zwcad 2017 is out.
Any chance in ZWCAD 2018 ?

It is very common bug in ZWCAD 2017 API - blocking official way for translations 2D->3D space
Post time 2017-8-1 08:44:36
Reply 7# Janusz8660


   Janusz,

   We will try to push issue ID T13536 to be solved ASAP in ZWCAD 2018. Thanks.
Post time 2017-10-11 15:52:20
Reply 7# Janusz8660


   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/&gt;. 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".
Hi,
I confirm,
Zwcad 2018 vernum 21849 (PLK) solve this issue.

Thanks,
Janusz
New
You have to log in before you can reply Login | Register