How to shift a layer's co-ordinate

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

Moderators: SDS, support, admin

Post Reply
avimms
Posts: 13
Joined: 06 Dec 2005, 09:57
Location: India

How to shift a layer's co-ordinate

Post by avimms » 14 Mar 2007, 09:15

Hi there,

In a DXF file I have no. of layers. I want to change the Z-coordinate of a particular layer, so when the DXF map is viewed in an isometric view, one should be able to see the vertical distance between two layers changed. What I have to do to achieve this? I tried enumerating the entities in a layer and change their Z coordinate using Point property, but it did not work. I tried finding out TsgDXFInsert objects on a layer and change their Z coordinate. Am I doing it correct? Please help.

Regards,
Avinash

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

Post by support » 15 Mar 2007, 11:48

Hello, Avinash.

Layer itself has no Z coordinate. It is necessary to change Z coordinate of every point in the entities.
The following example is based on Viewer demo of the CAD Import VCL package (available at: http://www.cadsofttools.com/download/cadimportvcl.zip). It moves all lines on the <b>'Lines'</b> layer up to Z = 150.

Code: Select all

<b>procedure</b> TForm1.btnMoveZClick(Sender: TObject);
<b>var</b>
  vImg: TsgDXFImage;
  I: Integer;
  vLine: TsgDXFLine;
  vPoint: TFPoint;
<b>begin
  if</b> sgPaintBox.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
    vImg := TsgDXFImage(sgPaintBox.Picture.Graphic)
  <b>else</b>
    Exit;
  <b>for</b> I := <font color="blue">0</font id="blue"> <b>to</b> vImg.Converter.Counts[csEntities] - 1 <b>do
  begin
    if</b> vImg.Converter.Sections[csEntities].Entities[I] <b>is</b> TsgDXFLine <b>then
    begin</b>
      vLine := TsgDXFLine(vImg.Converter.Sections[csEntities].Entities[I]);
      <b>if</b> vLine.Layer.Name = <font color="blue">'Lines'</font id="blue"> <b>then
      begin</b>
        vPoint := vLine.Point;
        vPoint.Z := <font color="blue">150</font id="blue">;
        vLine.Point := vPoint;
        vPoint := vLine.Point1;
        vPoint.Z := <font color="blue">150</font id="blue">;
        vLine.Point1 := vPoint;
        vImg.Converter.Loads(vLine);
      <b>end</b>;
    <b>end</b>;
  <b>end</b>;
  sgPaintBox.Invalidate;
<b>end</b>;
Sergey.

Please post questions to the forum or write to support@cadsofttools.com

Post Reply