Author Topic: INTEROP 2012 Utility.TranslateCoordinates  (Read 2963 times)

0 Members and 1 Guest are viewing this topic.

zeppeldep

  • Guest
INTEROP 2012 Utility.TranslateCoordinates
« on: July 24, 2012, 02:01:34 AM »
Hi Swamp People ... I am in need of HELP! Again..
Using .. C# 2010 to develop stand alone stuff (OUTSIDE/EXTERNAL) using the interop that works with AutoCAD version 2012.
..
I have hot another snag.
This time it's TranslateCoordinates.
Long ago I used VBA code to translate coordinates from paper space to model space. The code used the paper space viewport xdata to get the display coordinates of the viewport centre, then the code used TranslateCoordinates to translate the display coordinates to UCS like this..
viewport xdata .. read codes 1040 to get center X an Y in display coords , say P1 ... then ..
This Drawing.Utility.TranslateCoordinates(P1, acDisplayDCS , acUCS, false)

I am  trying this again in C# but it is not translating the coordinates ??? What did I miss?
This:
double[] Pnt = doc1.Utility.TranslateCoordinates(P1, AcCoordinateSystem.acDisplayDCS,
    AcCoordinateSystem.acUCS, 0);
is not providing the model space coordinates of the viewport centre - why?

Thx for your help and patience ..
Kevin.



zeppeldep

  • Guest
Re: INTEROP 2012 Utility.TranslateCoordinates
« Reply #1 on: July 24, 2012, 02:33:06 AM »
here is an example ... (attached)
need to get model space coords of the ps viewport in Layout1 using TranslateCoordinates from the ps viewport ACAD xdata..
... correct result should be about .. 78620 , -2904290

zeppeldep

  • Guest
Re: INTEROP 2012 Utility.TranslateCoordinates
« Reply #2 on: July 24, 2012, 02:53:26 AM »
the WCS model space coords is available as the Target Property of the ps viewport...
I used translate to quickly take care of rotation at the same time...
I am now looking at twist angle with target as an alternative to xdata ..


zeppeldep

  • Guest
Re: INTEROP 2012 Utility.TranslateCoordinates
« Reply #3 on: July 24, 2012, 02:57:17 AM »
... this post ... is not just to get the vp centre in ms wcs ... it is to find the method to translate ps vp points to ms wcs points in the viewport ...

zeppeldep

  • Guest
Re: INTEROP 2012 Utility.TranslateCoordinates
« Reply #4 on: July 24, 2012, 03:53:10 AM »
I have a temporary 'hack' solution .. to translate twice, switching space ..

But there must be a better way ..

double[] result1 = new double[8];
object oMin;
object oMax;
vp.GetBoundingBox(out oMin, out oMax);
double[] Min = (double[])oMin;
double[] Max = (double[])oMax;
doc1.MSpace = true;
double[] ll = doc1.Utility.TranslateCoordinates(Min, AcCoordinateSystem.acPaperSpaceDCS, AcCoordinateSystem.acDisplayDCS, 0);
double[] lr = doc1.Utility.TranslateCoordinates(new double[] { Max[0] , Min[1] , 0 },
    AcCoordinateSystem.acPaperSpaceDCS, AcCoordinateSystem.acDisplayDCS, 0);
double[] ur = doc1.Utility.TranslateCoordinates(Max, AcCoordinateSystem.acPaperSpaceDCS, AcCoordinateSystem.acDisplayDCS, 0);
double[] ul = doc1.Utility.TranslateCoordinates(new double[] { Min[0], Max[1], 0 },
        AcCoordinateSystem.acPaperSpaceDCS, AcCoordinateSystem.acDisplayDCS, 0);

ll = doc1.Utility.TranslateCoordinates(ll, AcCoordinateSystem.acDisplayDCS, AcCoordinateSystem.acUCS, 0);
lr = doc1.Utility.TranslateCoordinates(lr, AcCoordinateSystem.acDisplayDCS, AcCoordinateSystem.acUCS, 0);
ur = doc1.Utility.TranslateCoordinates(ur, AcCoordinateSystem.acDisplayDCS, AcCoordinateSystem.acUCS, 0);
ul = doc1.Utility.TranslateCoordinates(ul, AcCoordinateSystem.acDisplayDCS, AcCoordinateSystem.acUCS, 0);

result1[0] = ll[0];
result1[1] = ll[1];
result1[2] = lr[0];
result1[3] = lr[1];
result1[4] = ur[0];
result1[5] = ur[1];
result1[6] = ul[0];
result1[7] = ul[1];
doc1.MSpace = false;
return result1;

Bryco

  • Water Moccasin
  • Posts: 1883