Way to draw a specific portion of model view
Moderators: SDS, support, admin
Way to draw a specific portion of model view
Is there a way to select a particular region of the Model view of my dwg files?
I know, for instance, that one type of drawing always has content located in a region with UpperLeft corner = 12.581,14.547 and a
LowerRight of 20.144, 4.185.
How would I select this area draw and then print this specific area of a drawing, with the on screen and printed forms both maintaining the correct size? ( The drawing above is in inches ).
I know, for instance, that one type of drawing always has content located in a region with UpperLeft corner = 12.581,14.547 and a
LowerRight of 20.144, 4.185.
How would I select this area draw and then print this specific area of a drawing, with the on screen and printed forms both maintaining the correct size? ( The drawing above is in inches ).
Dear Michael,
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">How would I select this area draw and then print this specific area of a drawing,<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We recommend to use property TsgDXFImage.DrawingBox. It is necessary to set TFRect (as an input parameter) within drawing's extents returned by property TsgDXFImage.CurrentLayout.Box. Please see code below:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">with the on screen and printed forms both maintaining the correct size? ( The drawing above is in inches ).<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
AutoCAD views drawings basing on global coordinates of the drawing itself. Is a drawing in millimeters or in inches it matters when AutoCAD prepares it for printing.
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">How would I select this area draw and then print this specific area of a drawing,<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We recommend to use property TsgDXFImage.DrawingBox. It is necessary to set TFRect (as an input parameter) within drawing's extents returned by property TsgDXFImage.CurrentLayout.Box. Please see code below:
Code: Select all
<b>uses</b>
... SGDrawingNavigator, sgConsts, DXFImage, DXFConv;
<b>type</b>
TForm1 = <b>class</b>(TForm)
pnlmage: TPanel;
btnOpen: TButton;
OpenDialog1: TOpenDialog;
btnPrintVisiblePart: TButton;
btnPrintPart: TButton;
<b>procedure</b> FormCreate(Sender: TObject);
<b>procedure</b> btnOpenClick(Sender: TObject);
<b>procedure</b> btnPrintPartClick(Sender: TObject);
<b>private</b>
<i><font color="blue">{ Private declarations }</i></font id="blue">
FsgPaintBox: TSGDrawingNavigator;
FImg: TsgDXFImage;
<b>public</b>
<i><font color="blue">{ Public declarations }</i></font id="blue">
<b>property</b> sgPaintBox: TSGDrawingNavigator <b>read</b> 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.btnOpenClick(Sender: TObject);
<b>begin
if not</b> OpenDialog1.Execute <b>then</b>
Exit;
sgPaintBox.LoadFromFile(OpenDialog1.FileName);
sgPaintBox.Color := clCream;
<b>if</b> sgPaintBox.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
FImg := TsgDXFImage(sgPaintBox.Picture.Graphic)
<b>else</b>
FImg := <b>nil</b>;
<b>end</b>;
<b>procedure</b> TForm1.btnPrintPartClick(Sender: TObject);
<b>var</b>
vGraphic: TGraphic;
W, H: double;
PW, PH: Integer;
vDrBox: TFRect;
<b>function</b> GetActualGraphic: TGraphic;
<b>var</b>
vCoeffW, vCoeffH, BX, BY: Double;
vClipRect, vExts: TFRect;
vNewImg: TsgDXFImage;
R: TRect;
<b>begin
if</b> FImg <> <b>nil then
begin</b>
Result := TGraphicClass(sgPaintBox.Picture.Graphic.ClassType).Create;
vNewImg := TsgDXFImage(Result);
vNewImg.Assign(FImg);
R := sgPaintBox.Parent.ClientRect;
vNewImg.IsWithoutBorder := True;
vExts := FImg.Extents;
// Borders
BX := <font color="blue">0.5</font id="blue"> * (vExts.Right - vExts.Left - vNewImg.Extents.Right + vNewImg.Extents.Left);
BY := <font color="blue">0.5</font id="blue"> * (vExts.Top - vExts.Bottom - vNewImg.Extents.Top + vNewImg.Extents.Bottom);
// Scaling coefficients
vCoeffW := (vExts.Right - vExts.Left)/ (sgPaintBox.PictureRect.Right - sgPaintBox.PictureRect.Left);
vCoeffH := (vExts.Top - vExts.Bottom)/ (sgPaintBox.PictureRect.Bottom - sgPaintBox.PictureRect.Top);
// Clipping rectangle (ignoring Z-coordinate)
vClipRect.Left := (R.Left - sgPaintBox.PictureRect.Left)* vCoeffW - BX;
vClipRect.Top := (R.Top - sgPaintBox.PictureRect.Top)* vCoeffH - BY;
vClipRect.Right := vClipRect.Left + (R.Right - R.Left) * vCoeffW;
vClipRect.Bottom := vClipRect.Top + (R.Bottom - R.Top) * vCoeffH;
vNewImg.SetClippingRect(@vClipRect);
<b>end</b>;
<b>end</b>;
<b>begin
if</b> FImg = <b>nil then</b>
Exit;
vDrBox.Left := FImg.CurrentLayout.Box.Left + (FImg.CurrentLayout.Box.Right - FImg.CurrentLayout.Box.Left) / 4;
vDrBox.Right := FImg.CurrentLayout.Box.Right - (FImg.CurrentLayout.Box.Right - FImg.CurrentLayout.Box.Left) / 4;
vDrBox.Top := FImg.CurrentLayout.Box.Top - (FImg.CurrentLayout.Box.Top - FImg.CurrentLayout.Box.Bottom) / 4;
vDrBox.Bottom := FImg.CurrentLayout.Box.Bottom + (FImg.CurrentLayout.Box.Top - FImg.CurrentLayout.Box.Bottom) / 4;
FImg.DrawingBox := vDrBox;
vGraphic := GetActualGraphic;
<b>with</b> Printer <b>do
begin</b>
W := Printer.PageWidth / vGraphic.Width;
H := Printer.PageHeight / vGraphic.Height;
<b>if</b> W > H <b>then</b> W := H;
PW := Round(W * vGraphic.Width);
PH := Round(W * vGraphic.Height);
BeginDoc;
Canvas.StretchDraw(Bounds((PageWidth-PW) <b>div</b> <font color="blue">2</font id="blue">, (PageHeight-PH) <b>div</b> <font color="blue">2</font id="blue">, PW, PH), vGraphic);
EndDoc;
<b>end</b>;
sgPaintBox.Repaint;
<b>end</b>;
<b>end</b>.
AutoCAD views drawings basing on global coordinates of the drawing itself. Is a drawing in millimeters or in inches it matters when AutoCAD prepares it for printing.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com