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

BlockReference position and View coordinate system problem.

2 REPLIES 2
Reply
Message 1 of 3
GrzesiekGP
362 Views, 2 Replies

BlockReference position and View coordinate system problem.

Hello,

 

I have some problem. I have rotated my view about 15 degress (just for this example).

Now I prompt user to select the point, which is also an insertion point of the block.

 

So we have:

- selected point: X=0, Y=294, Z=0;

- insertion point of the block: X=0, Y=294, Z=0

(this is what I have in properties list or when I execute LIST command).

 

Now in my code:

 ed.WriteMessage("\nBase X: " + basePoint.X.ToString());
                                ed.WriteMessage("\nBase Y: " + basePoint.Y.ToString());
                                ed.WriteMessage("\nBlock X: " + blkRef.Position.X.ToString());
                                ed.WriteMessage("\nBlock Y: " + blkRef.Position.Y.ToString());

 This gives me:

 

Base X: -2.89976376244283E-14 - OK
Base Y: 294.058394637539 - OK
Block X: -76.1079129044681 - BAD
Block Y: 284.038597817502 - BAD

 

My question - why blockReference position is different that it should be?

 

 

2 REPLIES 2
Message 2 of 3
fenton.webb
in reply to: GrzesiekGP

the block has its own transform




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 3
AubelecBE
in reply to: GrzesiekGP

you have to convert you point cliked by the user on World CS.

 

so this point gave it to your block

 

 

here a simple sub for do that.

  '-------------------------------------------------------------------------
    '------ 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) 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)
      
        Return ret
       
    End Function

 

 

 

 

 

 

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