- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi to all..
I'm using this code posted by @norman.yuan in my applications and it works just perfect.
https://drive-cad-with-code.blogspot.com/2020/04/show-temporary-entityshape-during-user_21.html
I temporarily generate a DbText, which displays a type of count over the selection and places it in the upper left corner of the screen.
I would like to update the text position every time the user uses the PAN by the middle mouse button or Zoom by the MouseWhell.
Thus ensuring that the text maintains the same visual appearance as before.
It turns out that I can't interact with the entity temporarily generated by WordDraw. When trying to change this I cause a fatal error in AutoCAD.
this is the example.
When I use the PAN the entity leaves the screen, and I would like to update its position after the end of the pan. (Middle Button Mouse)
In the WordDraw method that triggers the drawing of the temporary entity, I create a CopyEnt variable, to save the data of this entity... here...
public override bool WorldDraw(Drawable drawable, WorldDraw wd)
{
var ent = drawable as Entity;
if (ent is BlockReference)
{
using (var tempEnt = _createTempEntityFunction(ent.ObjectId))
{
copyEnt = tempEnt; // Copy Of entity to try future change,
wd.Geometry.Draw(tempEnt);
wd.SubEntityTraits.Color = 191;
}
}
else if (ent is AttributeReference)
{
wd.SubEntityTraits.Color = 2;
}
else if (ent is Autodesk.AutoCAD.DatabaseServices.Polyline)
{
using (var tempEnt = _createTempEntityFunction(ent.ObjectId))
{
copyEnt = tempEnt;
wd.Geometry.Draw(tempEnt);
wd.SubEntityTraits.Color = 191;
}
}
else
{
wd.SubEntityTraits.Color = 191;
}
return base.WorldDraw(drawable, wd);
}
And this function captures the mouse Mbutton, to try to interact with Temporary Entity
public static void VhmouseHandlerMidButton(object sender, PreTranslateMessageEventArgs e)
{
// Only look at mouse messages
if (e.Message.message == WM_MBUTTONUP || e.Message.message == WM_MOUSEHWHEEL)
{
if (MySelectionDrawableOverrule.Overruling)
{
DBText acText = (DBText)MySelectionDrawableOverrule.copyEnt;
Point3d pvScreenCenter = (Point3d)Application.GetSystemVariable("VIEWCTR");
Point2d pvScreenSize = (Point2d)Application.GetSystemVariable("SCREENSIZE");
Double pdHeight = (Double)Application.GetSystemVariable("VIEWSIZE");
Double pdWidth = pdHeight * (pvScreenSize.X / pvScreenSize.Y);
Point3d pdText = new Point3d(pvScreenCenter.X - (pdWidth / 2.15), pvScreenCenter.Y + (pdHeight / 2.95), 0);
acText.UpgradeOpen(); // Any interaction to change this entity causes a FATAL ERROR,
acText.Height = pdHeight / 7; // Any interaction to change this entity causes a FATAL ERROR,
acText.Position = pdText; // Any interaction to change this entity causes a FATAL ERROR,
}
}
}
Any idea how to modify the position of this Temporary Entity, or make it always remain in this position on the screen, regardless of the point?
Thank you...
Solved! Go to Solution.