cart: empty [ Login ]

Set Entity Color

1 
Marcellus Zebra
7/24/2012 9:23 AM
Hi, In certains conditions, I want to change an entity color. So, I set Entity.Color property but the color drawn don't change. How to obtain a single entity refresh? I obtain the result calling CreateDrawables method but this is really expensive and redraw all cad. Is possible to call a speedy method to redraw only selected entitiy? thank's, marc.
Wout
7/24/2012 10:22 AM
Yes, first before creating the initial drawables, call GDIGraphics3D.EnableDrawablesUpdate(). Then you can update individual entity drawables by calling GDIGraphics3D.UpdateDrawables(DxfEntity entity). - Wout
Marcellus Zebra
7/24/2012 12:03 PM
Hi, thanks very mutch for response. This work only if after drawables update I apply a global invalidation, correct? But also this is really expensive. Is possible to invalidate only the single entity? Sorry, but I work with really bigs dwg. Thank's. marc.
Wout
7/24/2012 12:23 PM
Hi, After that you need to call Invalidate() on the windows forms control indeed. There are no other ways possible, because GDI+ does not retain any state. - Wout
Arash
10/25/2013 7:31 AM
Hi Marc, I have a problem with changing the color of an entity. Apparently you have solved this issue. Could you please describe how you solved this issue? FYI, here is ma code:
C# Code:
} else if (e.Button == MouseButtons.Left) { // Select entity at mouse location if mouse didn't move // and show entity in property grid. if (mouseClickLocation == e.Location) { Point2D referencePoint = new Point2D(e.X, e.Y); double distance; IList<RenderedEntityInfo> closestEntities = EntitySelector.GetClosestEntities( this.model, GraphicsConfig.WhiteBackground, projectionTransform * modelViewTransform, referencePoint, out distance ); if (closestEntities.Count > 0) { DxfEntity entity = closestEntities[0].Entity; try { //MessageBox.Show(entity.Handle.ToString()); entity.Color = EntityColor.CreateFromRgb(255, 0, 0); entity.LineWeight = 3; this.model.Entities.Add(entity); this.Model = this.model; this.Invalidate(); //OnEntitySelected(new EntityEventArgs(entity)); } catch (Exception err) { MessageBox.Show(err.Message.ToString()); } } this.Refresh(); }
Thank you so much. Cheers, Arash
1