Creating a working drawing
Moderators: SDS, support, admin
Creating a working drawing
Hi,
1) All the examples I've rewiewed so far opens a Graphic file. How can I create a new working Graphic file.
2) How can I implement ACAD panning behaviour? You'll press the mouse whell and drag it the drawing starts to pan?
Thanks
Sabetay
1) All the examples I've rewiewed so far opens a Graphic file. How can I create a new working Graphic file.
2) How can I implement ACAD panning behaviour? You'll press the mouse whell and drag it the drawing starts to pan?
Thanks
Sabetay
Dear Sabetay,
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">1) All the examples I've rewiewed so far opens a Graphic file. How can I create a new working Graphic file.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Can you please describe in detail what task do you have and what do you mean under <b>Graphic file</b>?
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
2) How can I implement ACAD panning behaviour? You'll press the mouse whell and drag it the drawing starts to pan?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
All panning and zoomming by mouse is released on the <b>TsgDrawingNavigator</b> level. Component <b>TsgDrawingNavigator</b> is a main component which used for displaying files within <b>CAD Import VCL</b> applications. This component is used in all <b>CAD Import VCL</b> demos (find them in the ..\cadimportvcl\Delphi\Demos\.. folder of the package: http://www.cadsofttools.com/download/cadimportvcl.zip).
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">1) All the examples I've rewiewed so far opens a Graphic file. How can I create a new working Graphic file.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Can you please describe in detail what task do you have and what do you mean under <b>Graphic file</b>?
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
2) How can I implement ACAD panning behaviour? You'll press the mouse whell and drag it the drawing starts to pan?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
All panning and zoomming by mouse is released on the <b>TsgDrawingNavigator</b> level. Component <b>TsgDrawingNavigator</b> is a main component which used for displaying files within <b>CAD Import VCL</b> applications. This component is used in all <b>CAD Import VCL</b> demos (find them in the ..\cadimportvcl\Delphi\Demos\.. folder of the package: http://www.cadsofttools.com/download/cadimportvcl.zip).
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Dear Sabetay,
The folllowing example demonstrates how to create new CAD file, now to add Dimension entity and how to save result into AutoCAD DXF file format. <b>DXF Export VCL</b> (available at: http://www.cadsofttools.com/download/dxfexportvcl.zip) is used for conversion to DXF file format.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
The folllowing example demonstrates how to create new CAD file, now to add Dimension entity and how to save result into AutoCAD DXF file format. <b>DXF Export VCL</b> (available at: http://www.cadsofttools.com/download/dxfexportvcl.zip) is used for conversion to DXF file format.
Code: Select all
<b>uses</b>
... SGDrawingNavigator, sgConsts, DXFImage, DXFConv, CADtoDXF;
<b>type</b>
TForm1 = <b>class</b>(TForm)
pnlmage: TPanel;
NewCAD_AddDimension: TButton;
SaveDialog1: TSaveDialog;
<b>procedure</b> FormCreate(Sender: TObject);
<b>procedure</b> NewCAD_AddDimensionClick(Sender: TObject);
<b>private</b>
<i><font color="blue">{ Private declarations }</font id="blue"></i>
FsgPaintBox: TSGDrawingNavigator;
<b>public</b>
<i><font color="blue">{ Public declarations }</font id="blue"></i>
<b>property</b> sgPaintBox: TSGDrawingNavigator read FsgPaintBox;
...
<b>procedure</b> TForm1.FormCreate(Sender: TObject);
<b>begin</b>
FsgPaintBox := TSGDrawingNavigator.Create(pnlmage);
FsgPaintBox.Parent := pnlmage;
sgPaintBox.Align := alClient;
sgPaintBox.AutoFocus := True;
sgPaintBox.Anchors := [akLeft,akTop,akRight,akBottom];
<b>end</b>;
<b>procedure</b> TForm1.NewCAD_AddDimensionClick(Sender: TObject);
<b>var</b>
vDimension: TsgDXFDimension;
vExp: TsgCADtoDXF;
vCADFile: TsgDXFImage;
<b>begin
if not</b> SaveDialog1.Execute <b>or</b> (SaveDialog1.FileName = '') <b>then</b>
Exit;
vCADFile := TsgDXFImage.Create;
<b>try</b>
vCADFile.Converter.InitializeSections;
vDimension := TsgDXFDimension.Create;
vDimension.Flags := 1;
vDimension.LinDefPoint1 := MakeFPoint(<font color="blue">0</font id="blue">,<font color="blue">0</font id="blue">,<font color="blue">0</font id="blue">);
vDimension.LinDefPoint2 := MakeFPoint(<font color="blue">100</font id="blue">,<font color="blue">0</font id="blue">,<font color="blue">0</font id="blue">);
vDimension.DefPoint := MakeFPoint(<font color="blue">100</font id="blue">,<font color="blue">10</font id="blue">,<font color="blue">0</font id="blue">);
vDimension.ArrowSize := <font color="blue">2.5</font id="blue">;
vDimension.TextHeight := <font color="blue">2.5</font id="blue">;
vCADFile.Converter.Sections[csEntities].AddEntity(vDimension);
<b>if</b> Assigned(vCADFile.Converter.OnCreate) <b>then</b>
vCADFile.Converter.OnCreate(vDimension);
vCADFile.Converter.Loads(vDimension);
vCADFile.GetExtents;
sgPaintBox.Picture.Graphic := vCADFile;
sgPaintBox.Width := Round(vCADFile.AbsWidth);
sgPaintBox.Height := Round(vCADFile.AbsHeight);
sgPaintBox.Invalidate;
vExp := TsgCADtoDXF.Create(TsgDXFImage(sgPaintBox.Picture.Graphic));
vExp.SaveToFile(SaveDialog1.FileName);
vExp.Free;
<b>finally</b>
vCADFile.Free;
<b>end</b>;
<b>end</b>;
<b>end</b>.
Please post questions to the forum or write to support@cadsofttools.com