CADImageDLL zoom extents in C#
Moderators: SDS, support, admin
CADImageDLL zoom extents in C#
Hello,
We are building an .dwg viewer for our company with the use of the CADImageDLL. Everything works great so far, however there is one function which we like to use but we can get to work properly. We want to crop the image in such a way that the white spaces around the borders of the drawing do not show. We asume the function GETExtendsCAD does this (in Autocad the term "extends" stands for this function) by returning a rectangle of the area where the actual drawing is. However, the function returns a rectangle with a heigth and width which does not relate to the actual width and height of this area if we measure it in Autocad.
We used the folowing C# code:
FRect fr = new FRect();
DLLwrap.GetExtentsCAD(this.CADFile, ref fr);
If we look at the difference between fr.Left and fr.Right, we get a value of something like 3.5 where in Autocad the width of the drawing is something like 400.
Are we correct in our thinking about the use of this function?
We are building an .dwg viewer for our company with the use of the CADImageDLL. Everything works great so far, however there is one function which we like to use but we can get to work properly. We want to crop the image in such a way that the white spaces around the borders of the drawing do not show. We asume the function GETExtendsCAD does this (in Autocad the term "extends" stands for this function) by returning a rectangle of the area where the actual drawing is. However, the function returns a rectangle with a heigth and width which does not relate to the actual width and height of this area if we measure it in Autocad.
We used the folowing C# code:
FRect fr = new FRect();
DLLwrap.GetExtentsCAD(this.CADFile, ref fr);
If we look at the difference between fr.Left and fr.Right, we get a value of something like 3.5 where in Autocad the width of the drawing is something like 400.
Are we correct in our thinking about the use of this function?
Hello!
It is necessary first to call function SetCADBorderSize with second parameter equal to zero.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
It is necessary first to call function SetCADBorderSize with second parameter equal to zero.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
This function is implemented in the CADImage.DLL package available at: http://www.cadsofttools.com/download/cadimagedll.zip
Here goes a description:
The SetCADBorderSize function sets width of the border around the loaded image.
Parameters:
hObject:
Identifies a CADImage object handle
BSize
Specifies width of the border.
Set BSize as integer value, if second parameter of SetCADBorderType is Global. In this case border width is defined in global units.
Set BSize as double value less '1', if second parameter of SetCADBorderType is Ratio. In this case border width is defined in percents respectively to the drawing's size.
The SetCADBorderType function sets type of the drawing's border: global points or ratio.
Parameters:
hObject
Identifies a CADImage object handle
BType
Specifies the border type:
If BType is equal '0' then border type is Global.
If BType is equal '1' then border type is Ratio.
If border type is Global, second parameter of SetCADBorderSize must contains integer value. It defines border width in global units.
If border type is Ratio, second parameter of SetCADBorderSize must contains double value less '1'. It defines border width in percents respectively to the drawing's size.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Here goes a description:
The SetCADBorderSize function sets width of the border around the loaded image.
Code: Select all
BOOL SetCADBorderSize(
HANDLE hObject,
int BSize
);
hObject:
Identifies a CADImage object handle
BSize
Specifies width of the border.
Set BSize as integer value, if second parameter of SetCADBorderType is Global. In this case border width is defined in global units.
Set BSize as double value less '1', if second parameter of SetCADBorderType is Ratio. In this case border width is defined in percents respectively to the drawing's size.
The SetCADBorderType function sets type of the drawing's border: global points or ratio.
Code: Select all
BOOL SetCADBorderType(
HANDLE hObject,
int BType
);
hObject
Identifies a CADImage object handle
BType
Specifies the border type:
If BType is equal '0' then border type is Global.
If BType is equal '1' then border type is Ratio.
If border type is Global, second parameter of SetCADBorderSize must contains integer value. It defines border width in global units.
If border type is Ratio, second parameter of SetCADBorderSize must contains double value less '1'. It defines border width in percents respectively to the drawing's size.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
-
- Posts: 4
- Joined: 07 Jul 2008, 10:36
Re: CADImageDLL zoom extents in C#
It has been a long time since the last post here, but recently i picked this matter up again and retried your sollution. However, it doesn't work as i hoped it would be. Let me begin by restating my problem:
In Autocad a drawing has a predefined drawable area which the Cadimagedll recognized as the full size of the drawing. However in my company we sometimes deal with drawings which are drawn over and outside this drawable area but the Cadimagedll still only recognized the drawable area as the maximum size. In my program i have a "zoom all" function which does the same as in your demo (demoVB.exe) when you set the scale to 100%. Both in my program as in the demo only a small corner of the drawing is shown of the size of the drawable area. If i set the scale to 50% for example, is see a larger part of the drawing. So it is viewable by the imagedll, but it can't recognize it.
In a previous post i mentioned the function GetExtentsCAD in the hope it would return the size of the entire drawing, but i believe now that it only returns the size of the drawable area.
So my question is:
How can i zoom in such a way i can see te entire picture drawn, even if it is drawn outside the normal drawable area (say the 100% zoom area).
In Autocad a drawing has a predefined drawable area which the Cadimagedll recognized as the full size of the drawing. However in my company we sometimes deal with drawings which are drawn over and outside this drawable area but the Cadimagedll still only recognized the drawable area as the maximum size. In my program i have a "zoom all" function which does the same as in your demo (demoVB.exe) when you set the scale to 100%. Both in my program as in the demo only a small corner of the drawing is shown of the size of the drawable area. If i set the scale to 50% for example, is see a larger part of the drawing. So it is viewable by the imagedll, but it can't recognize it.
In a previous post i mentioned the function GetExtentsCAD in the hope it would return the size of the entire drawing, but i believe now that it only returns the size of the drawable area.
So my question is:
How can i zoom in such a way i can see te entire picture drawn, even if it is drawn outside the normal drawable area (say the 100% zoom area).
Re: CADImageDLL zoom extents in C#
Hello!
We recommend to use SetDrawingBoxCAD function.
The SetDrawingBoxCAD function sets a rectangular 3D CAD drawing area (defined in CAD coordinates) which will be displayed.
Syntax
Parameters
hObject
Identifies a CADImage object handle
ABox
Specifies rectangular area of the drawing, which will be dispayed.
Sergey.
We recommend to use SetDrawingBoxCAD function.
The SetDrawingBoxCAD function sets a rectangular 3D CAD drawing area (defined in CAD coordinates) which will be displayed.
Syntax
Code: Select all
int SetDrawingBoxCAD(
HANDLE hObject,
LPFRECT ABox
);
hObject
Identifies a CADImage object handle
ABox
Specifies rectangular area of the drawing, which will be dispayed.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 4
- Joined: 07 Jul 2008, 10:36
Re: CADImageDLL zoom extents in C#
Thank you for your reaction,
However this is only half of the solution. In order to set SetDrawingBoxCAD, i first have to know the size of the area where the actual drawing is (whether it is in or outside the standard drawable area). How can i do this?
However this is only half of the solution. In order to set SetDrawingBoxCAD, i first have to know the size of the area where the actual drawing is (whether it is in or outside the standard drawable area). How can i do this?
Re: CADImageDLL zoom extents in C#
Hello!
Do your files have any marks which allow to define programmatically the area where the actual drawing is?
Sergey.
Do your files have any marks which allow to define programmatically the area where the actual drawing is?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 4
- Joined: 07 Jul 2008, 10:36
Re: CADImageDLL zoom extents in C#
Yes, around the drawings there is a black rectangle by which this could be achieved. Your idea is to somehow find the four edges and calculate the drawingbox using that information? In what way can i detect those four edges?
Re: CADImageDLL zoom extents in C#
Can you get somehow (CADImage.DLL can't be used for this purpose) CAD coordinates of the bounding rectangle?
Sergey.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 4
- Joined: 07 Jul 2008, 10:36
Re: CADImageDLL zoom extents in C#
One solution i was thinking about is to get the value of a each pixel from the four edges and work my way inwards until i get to a black pixel and thus find the four edges of de bounding rectangle. Is this something that could work (either finding the pixel using the dll or finding it in the image retrieved from the form on which the dll draws)?
Re: CADImageDLL zoom extents in C#
Function GetCADCoords could be helpful in this question:
The GetCADCoords function returns coordinates of point on the drawing in Coord.
Syntax
Parameters
hObject
Identifies a CADImage object handle.
AXScaled
Defines ratio in percents between X coordinate of desired point on the drawing and its width.
AYScaled
Defines ratio in percents between Y coordinate of desired point on the drawing and its heigth.
Coord
Contains desired point on the drawing.
Sergey.
The GetCADCoords function returns coordinates of point on the drawing in Coord.
Syntax
Code: Select all
int GetCADCoords(
HANDLE hObject,
float *AXScaled,
float *AYScaled,
LPFPOINT Coord
);
hObject
Identifies a CADImage object handle.
AXScaled
Defines ratio in percents between X coordinate of desired point on the drawing and its width.
AYScaled
Defines ratio in percents between Y coordinate of desired point on the drawing and its heigth.
Coord
Contains desired point on the drawing.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support