Mapping a CAD Point
Moderators: SDS, support, admin
Mapping a CAD Point
Sergey,
I'm trying to convert a point from a specific layout to a display point. I'm not using TsgDrawingNavigator, but TDXFImage. First I'm using StretchDraw to draw the graphic on a canvas, then I iterate through the CAD entities. If I've found a specific element I want to convert it's TopLeft coord to the corresponding Canvas coordinate. I've tried GetPoint, but that gives me garbage. I've done some tests trying to convert (0,0), but that always returns the TopLeft hand corner, even though the Editor shows the origin to be in the center. I've also tried GetPointUCS, but to no avail. I'm sure I'm missing something obvious.
Kind regards,
Willo van der Merwe
I'm trying to convert a point from a specific layout to a display point. I'm not using TsgDrawingNavigator, but TDXFImage. First I'm using StretchDraw to draw the graphic on a canvas, then I iterate through the CAD entities. If I've found a specific element I want to convert it's TopLeft coord to the corresponding Canvas coordinate. I've tried GetPoint, but that gives me garbage. I've done some tests trying to convert (0,0), but that always returns the TopLeft hand corner, even though the Editor shows the origin to be in the center. I've also tried GetPointUCS, but to no avail. I'm sure I'm missing something obvious.
Kind regards,
Willo van der Merwe
Re: Mapping a CAD Point
Hello Willo,
We have sent you a demo with respective example.
Demo draws entities' boxes using:
procedure TsgDXFConverter.Iterate(Proc, FinishProc: TsgCADEntityProc; var Params: TsgCADIterate);
See it in:
procedure TfmCADDraw.tmrBoxesTimer(Sender: TObject);
protected method must be called before using Iterate:
procedure TsgCADImage.ApplyScale(const ARect: TRect);
Sergey.
We have sent you a demo with respective example.
Demo draws entities' boxes using:
procedure TsgDXFConverter.Iterate(Proc, FinishProc: TsgCADEntityProc; var Params: TsgCADIterate);
See it in:
procedure TfmCADDraw.tmrBoxesTimer(Sender: TObject);
protected method must be called before using Iterate:
procedure TsgCADImage.ApplyScale(const ARect: TRect);
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Mapping a CAD Point
I need a transformation methods to convert between Screen point and Cad point. I found GetRealPoint(int x, int y) which converts Screen point to Cad point. What is the opposite method to GetRealPoint(int x, int y) ?
Re: Mapping a CAD Point
Hello Bronek,
The following methods allow converting between Screen point and Cad point:
1. Screen point to Cad point
TsgDrawingNavigator.GetRealPoint
function GetRealPoint(X, Y: Integer; var PtInUCS: TFPoint): TFPoint;
2. Cad point to Screen point
TsgCADImage.GetPoint
function GetPoint(const P: TFPoint): TPoint;
Sergey.
The following methods allow converting between Screen point and Cad point:
1. Screen point to Cad point
TsgDrawingNavigator.GetRealPoint
function GetRealPoint(X, Y: Integer; var PtInUCS: TFPoint): TFPoint;
2. Cad point to Screen point
TsgCADImage.GetPoint
function GetPoint(const P: TFPoint): TPoint;
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Mapping a CAD Point
Thank for quick reply!
I'm using C# example: EditorDemo, so I found CADConst.GetRealPoint(int x, int y, CADImage img, RectangleF rect) method and CADImage cadImage.GetPoint(DPoint absPoint, RectangleF curRect).
They works as I expected!
I'm using C# example: EditorDemo, so I found CADConst.GetRealPoint(int x, int y, CADImage img, RectangleF rect) method and CADImage cadImage.GetPoint(DPoint absPoint, RectangleF curRect).
They works as I expected!
Re: Mapping a CAD Point
Bronek:
What values are you sending in for the RectangleF parameters?
What values are you sending in for the RectangleF parameters?
Re: Mapping a CAD Point
I used EditorDemo, so I used original RectangleF value from EditorDemo.
Re: Mapping a CAD Point
RectangleF is an inner parameter of the demo. It defines a rectangle of the whole image of the loaded file:
where:
Code: Select all
public RectangleF ImageRectangleF
{
get
{
return new RectangleF(pos.X, pos.Y, VisibleAreaSize.Width * ImageScale, VisibleAreaSize.Height * ImageScale);
}
}
- pos.X, pos.Y - left top corner
- VisibleAreaSize - this parameter is initialized by real dimentions of the loaded file
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support