Mapping a CAD Point

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
willo
Posts: 1
Joined: 21 Apr 2008, 19:30

Mapping a CAD Point

Post by willo » 21 Apr 2008, 19:50

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

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mapping a CAD Point

Post by support » 07 May 2008, 15:21

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Bronek
Posts: 3
Joined: 10 Jun 2008, 16:50

Re: Mapping a CAD Point

Post by Bronek » 10 Jun 2008, 18:34

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) ?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mapping a CAD Point

Post by support » 11 Jun 2008, 09:30

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Bronek
Posts: 3
Joined: 10 Jun 2008, 16:50

Re: Mapping a CAD Point

Post by Bronek » 11 Jun 2008, 12:33

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!

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Re: Mapping a CAD Point

Post by michael » 30 Jul 2008, 02:47

Bronek:

What values are you sending in for the RectangleF parameters?

Bronek
Posts: 3
Joined: 10 Jun 2008, 16:50

Re: Mapping a CAD Point

Post by Bronek » 30 Jul 2008, 11:01

I used EditorDemo, so I used original RectangleF value from EditorDemo.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mapping a CAD Point

Post by support » 30 Jul 2008, 11:02

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply