Page 1 of 1
Mapping a CAD Point
Posted: 21 Apr 2008, 19:50
by willo
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
Re: Mapping a CAD Point
Posted: 07 May 2008, 15:21
by support
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.
Re: Mapping a CAD Point
Posted: 10 Jun 2008, 18:34
by Bronek
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
Posted: 11 Jun 2008, 09:30
by support
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.
Re: Mapping a CAD Point
Posted: 11 Jun 2008, 12:33
by Bronek
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!
Re: Mapping a CAD Point
Posted: 30 Jul 2008, 02:47
by michael
Bronek:
What values are you sending in for the RectangleF parameters?
Re: Mapping a CAD Point
Posted: 30 Jul 2008, 11:01
by Bronek
I used EditorDemo, so I used original RectangleF value from EditorDemo.
Re: Mapping a CAD Point
Posted: 30 Jul 2008, 11:02
by support
RectangleF is an inner parameter of the demo. It defines a rectangle of the whole image of the loaded file:
Code: Select all
public RectangleF ImageRectangleF
{
get
{
return new RectangleF(pos.X, pos.Y, VisibleAreaSize.Width * ImageScale, VisibleAreaSize.Height * ImageScale);
}
}
where:
- pos.X, pos.Y - left top corner
- VisibleAreaSize - this parameter is initialized by real dimentions of the loaded file
Sergey.