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?
the block has its own transform
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