Drawing a semi transparent red circle

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

Moderators: SDS, support, admin

Post Reply
stevez
Posts: 3
Joined: 25 Apr 2006, 20:52
Location: USA
Contact:

Drawing a semi transparent red circle

Post by stevez » 27 Apr 2006, 00:53

We have a AutoCAD drawing of a factory floor plan and equipment with sensors.
All sensors are depicted as rectangles and are on a separate layers.

We would like to:

1. enumerate through all sensors
2. dynamically label each sensor
3. draw a semi transparent red circle with a 30 ft radius around sensors with error conditions.

Add new entities demo shows how to add an entity, but how would I make it 50% transparent and filled?

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

Post by support » 16 Oct 2006, 17:52

Hello!

Here goes a simple example how to get rectangles from the specified layer and how 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>
<b>end</b>.
Sergey.

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

Post Reply