.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WCS UCS Point Transformations

2 REPLIES 2
Reply
Message 1 of 3
SRSDS
2066 Views, 2 Replies

WCS UCS Point Transformations

I am using the following to transform coordinates

 

    Public Function TransformPointWCStoUCS(ByVal WCSPnt As Point3d) As Point3d
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim m As Matrix3d = ed.CurrentUserCoordinateSystem.Inverse()
        Return WCSPnt.TransformBy(m)
    End Function

    Public Function TransformPointUCStoWCS(ByVal UCSPnt As Point3d) As Point3d
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim m As Matrix3d = ed.CurrentUserCoordinateSystem
        Return UCSPnt.TransformBy(m)
    End Function

 

The WCS to UCS is returning a negative value for Y. Is there another version of these that I need to be using?

2 REPLIES 2
Message 2 of 3
AubelecBE
in reply to: SRSDS

here my code for one function :

 

  '-------------------------------------------------------------------------
    '------ Conversion d'un point vers le WCS (SCU général)-------------------
    '-------------------------------------------------------------------------
    'Entrée : 
    '   un point 3D
    '   Debug : si true alors affichage
    '
    'Sortie : Un point 3D
    '-------------------------------------------------------------------------

    Public Function TransformPointToWCS(ByRef point As Point3d, Optional ByVal Debug As Boolean = False) As Point3d
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim Db As Database = doc.Database
        Dim ret As Point3d

      
        'conversion vers le WCS (du point uniquement)
        Dim newMatrix As Matrix3d '= New Matrix3d()
        Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem
        Dim cs As CoordinateSystem3d = ucs.CoordinateSystem3d
        newMatrix = Matrix3d.AlignCoordinateSystem(
            Point3d.Origin, _
            Vector3d.XAxis, _
            Vector3d.YAxis, _
            Vector3d.ZAxis, _
            cs.Origin, _
            cs.Xaxis, _
            cs.Yaxis, _
            cs.Zaxis)

     
        ret = point.TransformBy(newMatrix)
        If Debug = True Then
            ed.writemessage(vbCrLf & "x : avant " & point.X & " apres : " & ret.X & _
                                     vbCrLf & "y : avant " & point.Y & " apres : " & ret.Y)
        End If
        Return ret
     
    End Function

 

Message 3 of 3
_gile
in reply to: SRSDS

Hi,

 

You can have a look at the Point3d.Trans() overloaded extension methods in the GemetryExtensions library and/or at a way to P/Invoke the acedTrans() ObjectARX method.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost