Follow on from Stevez floorplan question

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

Moderators: SDS, support, admin

Post Reply
AndyStephenson
Posts: 8
Joined: 10 Oct 2006, 12:08
Location: United Kingdom

Follow on from Stevez floorplan question

Post by AndyStephenson » 16 Oct 2006, 12:57

Hi,

Looking at the example from the 28th April, this will colour all entities on the 'www' layer - if I am interpreting it correctly.

How can you select just one of these entities? Is there an attribute for polyline, or circle etc, that can be set to a unique value, and hence, check this value when searching through all of the entities?

If not, is there a layer count limitation in dxf files, if so what is it?

...Andy

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

Post by support » 16 Oct 2006, 17:51

Hello Andy,

Here goes a simple example how to get rectangles from the specified layer and to fill them with a red color:

Code: Select all

<b>uses</b>
  ...DXFImage, DXFConv, SGImage, sgConsts;

<b>type</b>
  TForm1 = <b>class</b>(TForm)
    ...
  <b>private</b>    
    FImg: TsgDXFImage;
    ...
  <b>end</b>;

<b>procedure</b> TForm1.Open1Click(Sender: TObject);
<b>begin
  if not</b> OpenDialog1.Execute <b>then</b> Exit;
  sgImage1.LoadFromFile(OpenDialog1.FileName);
  <b>if</b> sgImage1.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
    FImg := TsgDXFImage(sgImage1.Picture.Graphic)
  <b>else</b>
    FImg := <b>nil</b>;
  sgImage1.Align := alClient;
<b>end</b>;

<b>procedure</b> TForm1.btnSelectAllClick(Sender: TObject);
<b>var</b>
  I: Integer;
  vPolyLine: TsgDXFPolyline;
  vTRect: TRect;
  vColor: TColor;
<b>begin
  if</b> FImg = <b>nil then</b> Exit;   

  vColor := sgImage1.Canvas.Brush.Color;
  sgImage1.Canvas.Brush.Color := clRed;
  <b>for</b> I := 0 <b>to</b> FImg.Converter.Sections[csEntities].Count - 1 <b>do
  begin
    if</b> FImg.Converter.Sections[csEntities].Entities[I] <b>is</b> TsgDXFPolyline <b>then
    begin</b>
      vPolyLine := TsgDXFPolyline(FImg.Converter.Sections[csEntities].Entities[I]);
      <b>if</b> (vPolyLine.Count = 4) <b>and</b> (vPolyLine.Closed = True) <b>and</b>
        (vPolyLine.Layer.Name = 'WWW') <b>then
      begin</b>
        vTRect.TopLeft := FImg.GetPoint(vPolyLine.Points[2]);
        vTRect.BottomRight := FImg.GetPoint(vPolyLine.Points[0]);
        vTRect.BottomRight.X := vTRect.BottomRight.X + 1;
        vTRect.TopLeft.Y := vTRect.TopLeft.Y + 1;
        sgImage1.Canvas.FillRect(vTRect);
      <b>end</b>;
    <b>end</b>;
  <b>end</b>;
  sgImage1.Canvas.Brush.Color :=  vColor;
<b>end</b>
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Is there an attribute for polyline, or circle etc, that can be set to a unique value, and hence, check this value when searching through all of the entities?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
A unique value is the layer name in the example above.

Sergey.

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

AndyStephenson
Posts: 8
Joined: 10 Oct 2006, 12:08
Location: United Kingdom

Post by AndyStephenson » 16 Oct 2006, 23:05

Sergey,

Thanks for the example.

This is why I asked the question about the layer count in a dxf file.

As you say, the unique part of the entity in this example is the layer name, so If I want to add 110 unique entities, then I would need to create an additional 110 layers.

Is there a limit for dxf files that govern the maximim number of layers I can use?

...Andy

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

Post by support » 17 Oct 2006, 09:16

Hello Andy,

There are no layer count limitations in DXF files.

Sergey.

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

Post Reply