Change Color in Text
Moderators: SDS, support, admin
Change Color in Text
Hello!
I try changing a color in the text in DXF file direct in the Demo Editor from VCL Import CAD Components (only as example)
This code it's work
But in commonpicture it's do not worked
I think that a problem FDNavigator.Picture.Graphic := CurNav; And it's very intrested, that have I a problem with memory - the messege Access violation after
CurNav.free in the and of procedure.
But when make I no free, then have I a message access violation whet I second select making
I try changing a color in the text in DXF file direct in the Demo Editor from VCL Import CAD Components (only as example)
This code it's work
Code: Select all
procedure TfmPreview.FillImage(ASManager: TsgSelectionManager;
ADXFImage: TsgCADImage);
var
I: Integer;
vEnt: TsgDXFEntity;
vDXFImage: TsgCADImage;
begin
FSManager := ASManager;
vDXFImage := TsgCADImage.Create;
for I := 0 to FSManager.SelectedEntities.Count - 1 do
begin
vEnt := TsgDXFEntityClass(TsgDXFEntity(FSManager.SelectedEntities[I]).ClassType).Create;
vEnt.AssignEntity(TsgDXFEntity(FSManager.SelectedEntities[I]));
vDXFImage.Converter.OnCreate(vEnt);
vDXFImage.Converter.Sections[csEntities].AddEntity(vEnt);
vDXFImage.Converter.Loads(vEnt);
if vEnt is TsgDXFText then
begin
showmessage('Das ist ein Text'+IntToStr(vEnt.Color and $FFFFFFFF));
vEnt.SetColor($00120092); // die Farbe soll man gerade in Text-Entyti weckseln
vDXFImage.Converter.loads(vEnt); // und dann bei TsgCADImage dass hat als ein Kind das Entity speichern
showmessage(IntToStr(vEnt.Color and $FFFFFFFF));
end;
end;
vDXFImage.GetExtents;
FDNavigator.Picture.Graphic := vDXFImage;
FDNavigator.Color := vDXFImage.BackgroundColor;
//TsgCADImage(sgImage.Picture.Graphic).IsWithoutBorder := True;// without border
vDXFImage.Free;
FDNavigator.FitToSize;
end;
Code: Select all
var
CurNav : TsgCADImage;
curEnt: TsgDXFEntity; // das Objekt, das werden wir verfarben
begin
CurNav := TsgDXFImage(FDNavigator.Picture.Graphic); // Hier converten wir unser Navigator-Objekt in Visualobjekt, mit dem kцnnen wir arbeiten als Array von Entytis
curEnt := TsgDXFEntityClass(TsgDXFEntity(Fmanager.SelectedEntities[0]).ClassType).Create;
if curEnt is TsgDXFText then
begin
curEnt.SetColor($0088EA92); // die Farbe soll man gerade in Text-Entyti weckseln#
CurNav.Converter.loads(curEnt); // und dann bei TsgCADImage dass hat als ein Kind das Entity speichern
// CurNav.GetExtents;
FDNavigator.Picture.Graphic := CurNav;
// DNavigator.Refresh;
ShowMessage('Der Font vom Text ist getauscht!');
end;
CurNav.free in the and of procedure.
But when make I no free, then have I a message access violation whet I second select making
Re: Change Color in Text
Platform XP and Delphi 2006
Re: Change Color in Text
Hello.
The second snippet doesn't work because you change color of the entity that doesn't belongs to TsgCADImage:This creates new entity that doesn't contained in Convertor. In first snippet you add created entity to Converter. will affect entity's color.
Alexander.
The second snippet doesn't work because you change color of the entity that doesn't belongs to TsgCADImage:
Code: Select all
...
curEnt := TsgDXFEntityClass(TsgDXFEntity(Fmanager.SelectedEntities[0]).ClassType).Create;
if curEnt is TsgDXFText then
begin
curEnt.SetColor($0088EA92);
...
Code: Select all
TsgDXFEntity(Fmanager.SelectedEntities[0]).SetColor($0088EA92);
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support