RasterImage properties different from ACProperties

RasterImage properties different from ACProperties

Anonymous
Not applicable
667 Views
4 Replies
Message 1 of 5

RasterImage properties different from ACProperties

Anonymous
Not applicable

Hi,

 

I read out some RasterImage properties using c#. Here are some of the values I got back:

 

ImageWidth -height: 38589 , 35855
ImageOrientation: ((0,0,0),(38589,0,0),(0,35855,0),(0,0,1383608595))
ImagePosition: (38589,35855,0)
ImageRotation: 0

 

Now, when I look at the image properties in AC Property window the insertion point is given as 2691452.531, 1256066.998. These value look familiar to me and are what I would have expected to see as well when suing the API.

 

I'm not using a UCS.

 

Can anyone shed some light one this? How to interpret the values I got back when getting properties per API?

 

Thank you, Rob

 

0 Likes
Accepted solutions (1)
668 Views
4 Replies
Replies (4)
Message 2 of 5

SENL1362
Advisor
Advisor
2691452/38589=~70 . 1Point==70dots/inch
As i remember correctly in the image properties you can find the units of the image.
Other well known units are 400DPI
0 Likes
Message 3 of 5

Anonymous
Not applicable
Accepted solution

Hi,

 

I started again from scratch and  now I get results I comprehend. Can't say what is different now as I used the code sample from ADSK .net developer docs.

 

I need to replace an image which has been inserted into roughly 1000 drawings. It is georeferenced and has been inserted using AutoCAD Map command "mapiinsert". There is no API equivalent for mapiinsert in Map API and the command cannot be run in command line only.


My first idea was to insert the replacement image (georeferenced) into a new drawing using "mapiinsert" again, then read out the insertion/scale/size settings in order to reapply them within a batch routine to replace the existing image file in the drawing collection. But when I inserted the image using mapiinsert, imageattach or my plugin I got different results mainly for "Scale".


It took same time to get the settings right - although I haven't completely understood why the ones I have choosen are ok. As I have only one specific use case I don't mind that much. In case someone has a similar task - here are my settings so far (drawing units are Meter as well):

 

...
acRasterDef.Load();
// 0.3125 --> parameter given in world file (contains the georeference information)
acRasterDef.ResolutionMMPerPixel = new Vector2d(312.5, 312.5);
acRasterDef.ResolutionUnits = Unit.Meter;

//insertion point - easy : just the insertion point
Point3d insPt = new Point3d(2690000.95, 1255499.79, 0.0);
...
// size (width/height)
// 0.3125 --> parameter given in world file (contains the georeference information)
Vector3d u = new Vector3d(acRaster.ImageWidth  * 0.3125, 0, 0);
Vector3d v = new Vector3d(0, acRaster.ImageHeight  * 0.3125, 0);
acRaster.Orientation = new CoordinateSystem3d(insPt, u,v);


..

The image will be inserted with Scale = 1, exactly as if it were inserted using "mapiinsert".

 


Rob

 

 

0 Likes
Message 4 of 5

SENL1362
Advisor
Advisor

Have you checked youre DWGUNITS?

Default is FEET (equals 0.3 Mtrs)

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

just to add some further information about choosen values - I didn't see it - its just conversion Meter to Millimeter:

- world file first line:
0.31250000000000 = pixel size in the x-direction in map units/pixel
- map (image) and drawing units are both "Meter"
- acRasterDefNew.ResolutionMMPerPixel = new Vector2d(312.5, 312.5);
MillimeterPerPixel = 0.3125 (meter) * 1000 = 312.5
-Vector3d u = new Vector3d(acRaster.ImageWidth * 0.3125, 0, 0);
-Vector3d v = new Vector3d(0, acRaster.ImageHeight * 0.3125, 0);
image size = width/height * pixel size in x/y-direction  (0.3125m)

0 Likes