How to change all colors
Moderators: SDS, support, admin
How to change all colors
Hello,
I would like to change all the colors of a DWG file to make them "whiter".
But lines that do not use layer color are still in original colors.
Here is what I have done :
Did I miss something ?
PS : You have done a fantastic job with CADImportVCL !
I would like to change all the colors of a DWG file to make them "whiter".
But lines that do not use layer color are still in original colors.
Here is what I have done :
Code: Select all
//Get the colors into table "Couleurs"
<b>For</b> i := 0 <b>to</b> DWG.Converter.Counts[csLayers]-1 <b>do
begin</b>
Couleurs[i] := DWG.Converter.layers[i].Color;
<b>end</b>;
<b>For</b> i := 0 <b>to</b> DWG.Converter.Counts[csEntities]-1 <b>do
begin</b>
Couleurs[i+DWG.Converter.Counts[csLayers]] :=
EntColor(DWG.Converter.Entities[i],<b>nil</b>);
<b>end</b>;
//Transform and set the colors
<b>For</b> i := 0 <b>to</b> DWG.Converter.Counts[cslayers]-1 <b>do
begin</b>
Couleur := Couleurs[i];
Couleur := ColorTransformation(couleur);
DWG.Converter.layers[i].Color := Couleur;
<b>end</b>;
<b>For</b> i := 0 <b>to</b> DWG.Converter.Counts[csEntities]-1 <b>do
begin</b>
Couleur := Couleurs[i+DWG.Converter.Counts[cslayers]];
Couleur := ColorTransformation(couleur);
DWG.Converter.entities[i].SetColor(Couleur);
<b>end</b>;
PS : You have done a fantastic job with CADImportVCL !
Dear Izuba,
Please try the following code. It changes a color of all entities in the file to Blue:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please try the following code. It changes a color of all entities in the file to Blue:
Code: Select all
<b>type</b>
TForm1 = <b>class</b>(TForm)
sgImage1: TsgImage;
...
<b>procedure</b> TForm1.CADImportVCLForum274Click(Sender: TObject);
<b>var</b>
vImg: TsgDWGImage;
I: Integer;
vEnt: TsgDXFEntity;
<b>begin
try</b>
sgImage1.LoadFromFile('c:\test.dwg');
sgImage1.Align := alClient;
<b>except</b>
ShowMessage('Error');
Exit;
<b>end</b>;
vImg := TsgDWGImage(sgImage1.Picture.Graphic);
<b>for</b> I := 0 <b>to</b> vImg.Converter.Counts[csEntities] - 1 <b>do
begin</b>
vEnt := vImg.Converter.Sections[csEntities].Entities[I];
vEnt.SetColor(clBlue);
vImg.Converter.Loads(vEnt);
<b>end</b>;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com
Of course!
Please send it to support@cadsofttools.com
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please send it to support@cadsofttools.com
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Hello again,
Please use the following code:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please use the following code:
Code: Select all
<b>procedure</b> TForm1.CADImport2741Click(Sender: TObject);
<b>var</b>
vImg: TsgDWGImage;
I,J: Integer;
vEnt: TsgDXFEntity;
vBlck: TsgDXFBlock;
<b>begin
try</b>
sgImage1.LoadFromFile('c:\Test.dwg');
sgImage1.Align := alClient;
<b>except</b>
ShowMessage('Error');
Exit;
<b>end</b>;
vImg := TsgDWGImage(sgImage1.Picture.Graphic);
<b>for</b> I := 0 <b>to</b> vImg.Converter.Counts[csEntities] - 1 <b>do
begin</b>
vEnt := vImg.Converter.Sections[csEntities].Entities[I];
vEnt.SetColor(clBlue);
vImg.Converter.Loads(vEnt);
<b>end</b>;
<b>for</b> I := 0 <b>to</b> vImg.Converter.Counts[csBlocks] - 1 <b>do
begin</b>
vBlck := TsgDXFBlock(vImg.Converter.Sections[csBlocks].Entities[I]);
<b>for</b> J := 0 <b>to</b> vBlck.Count -1 <b>do
begin</b>
vBlck.Entities[J].SetColor(clBlue);
<b>if</b> vBlck.Entities[J].ClassType = TsgDXFMText <b>then</b>
<b>begin</b>
TsgDXFMText(vBlck.Entities[J]).SetColor(clBlue);
vImg.Converter.Loads(vBlck.Entities[J]);
<b>end</b>;
<b>end</b>;
<b>end</b>;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com
Hello again, thank's for your quick response.
It works perfectly to set the color with all the dwg I have.
But, now I realize that I do not get the real color for all entities that are in blocks.
Sometimes I have $1F FF FF FF instead of the color.
I have tried that:
and that
It works perfectly to set the color with all the dwg I have.
But, now I realize that I do not get the real color for all entities that are in blocks.
Sometimes I have $1F FF FF FF instead of the color.
I have tried that:
Code: Select all
<b>For</b> i := 0 <b>to</b> DWG.Converter.Counts[csblocks]-1 <b>do
begin</b>
vBlck := TsgDXFBlock(DWG.Converter.Sections[csBlocks].Entities[i]);
<b>For</b> j := 0 <b>to</b> vBlck.Count-1 <b>do
begin</b>
FormDWG.Couleurs[ii] := <b>vBlck.Entities[J].color</b>;
<b>if</b> vBlck.Entities[J].ClassType = TsgDXFMText <b>then
begin</b>
FormDWG.Couleurs[ii] :=
<b>TsgDXFMText(vBlck.Entities[J]).color</b>;
<b>end</b>;
inc(ii);
<b>end</b>;
<b>end</b>;
Code: Select all
<b>For</b> i := 0 <b>to</b> DWG.Converter.Counts[csblocks]-1 <b>do
begin</b>
vBlck := TsgDXFBlock(DWG.Converter.Sections[csBlocks].Entities[i]);
<b>For</b> j := 0 <b>to</b> vBlck.Count-1 <b>do
begin</b>
FormDWG.Couleurs[ii] := <b>EntColor(vBlck.Entities[J])</b>;
<b>if</b> vBlck.Entities[J].ClassType = TsgDXFMText <b>then
begin</b>
FormDWG.Couleurs[ii] := <b>EntColor(
TsgDXFMText(vBlck.Entities[J]))</b>;
<b>end</b>;
inc(ii);
<b>end</b>;
<b>end</b>;
Hello,
Graphic.pas:
clNone = TColor($1FFFFFFF);
sgConsts.pas:
clByLayer = $2FFFFFFF;
clByBlock = $3FFFFFFF;
<b>clNone</b>: entity will be drawn with black color if background color is white and vice versa. Please examine DXFImage.pas on using clNone in CADImportVCL. You can find it in the respective Lib folders of the CADImportVCL package: http://www.cadsofttools.com/download/cadimportvcl.zip
<b>clByLayer</b> - entity's color is specified by Layer color
<b>clByBlock</b> - entity's color is specified by Block color
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Graphic.pas:
clNone = TColor($1FFFFFFF);
sgConsts.pas:
clByLayer = $2FFFFFFF;
clByBlock = $3FFFFFFF;
<b>clNone</b>: entity will be drawn with black color if background color is white and vice versa. Please examine DXFImage.pas on using clNone in CADImportVCL. You can find it in the respective Lib folders of the CADImportVCL package: http://www.cadsofttools.com/download/cadimportvcl.zip
<b>clByLayer</b> - entity's color is specified by Layer color
<b>clByBlock</b> - entity's color is specified by Block color
Sergey.
please post questions to the forum or write to support@cadsofttools.com