Page 1 of 1

Creating a drawing by lines & points

Posted: 25 Feb 2011, 07:01
by Khyati
Hello,

I found CAD Import VCL interesting.

How to create a canvas / picture box and then draw some shapes lines / points on it?
Could you please post example in delphi?

i tried one of your reference code, but i stuck at " Im := TsgCADImage(sgPaintBox.Picture.Graphic);" point.
There is error of "undeclared identifier" for MakeFPoint and AddEntity functions. Do i need to add any library?
I don't want to use any of demo code straight away.

Re: Creating a drawing by lines & points

Posted: 28 Feb 2011, 17:17
by support
Hello Khyati.
CAD Import VCL library structure is similar to CAD Import .NET. You need create TsgCADImage object, add entities to it and visualize. CAD Import VCL provides TsgDrawingNavigator class that can be used for displaying TsgCADImage object:

Code: Select all

type
  TfmMain = class(TForm)
     ......
  private
     FsgPaintBox: TsgDrawingNavigator;

.....

var
  vImg: TsgCADImage;
begin
  FsgPaintBox := TSGDrawingNavigator.Create(Self);
  FsgPaintBox.Parent := Self;
  FsgPaintBox.Align := alClient;

  vImg := TsgCADImage.Create;
  try
    vImg.Converter.InitializeSections;
    vImg.CurrentLayout := vImg.Layouts[0];
    FsgPaintBox.Picture.Graphic := vImg;
  finally
    vImg.Free;
  end;
end;

MakeFPoint method declared in sgConsts unit. Please include it in uses clause of your application. AddEntity is the local procedure of demo application and can't be called from your application. Please see AddNewEntities demo for details.

Alexander.

Re: Creating a drawing by lines & points

Posted: 04 Mar 2011, 04:20
by Khyati
Thanks! It was useful code.

Are there mouse down / mouse click / mouse double click events included with CADImport VCL?
How to trigger them? (in Delphi 2010?)

Re: Creating a drawing by lines & points

Posted: 07 Mar 2011, 17:57
by support
Hello.
TsgDrawingNavigator class inherits most of its events from TCustomControl (Delphi class). You can modify any such event by redefining event handler. Please see any demo source for example.

Alexander.