This is Chuck Wilbur's Typepad Profile.
Join Typepad and start following Chuck Wilbur's activity
Join Now!
Already a member? Sign In
Chuck Wilbur
Recent Activity
"the text gets prefixed to the extended tooltip" Hmm, maybe my problem is that I don't get any tooltips on my AutoCAD entities ever. I'm not sure why... ROLLOVERTIPS is set to 1 and the box for "Show rollover ToolTips" is checked in Options. If you set ROLLOVERTIPS to 0 do you get a debug assertion on mouseout?
1 reply
I know this is old, but it looked like something I could use for a prototype I'm doing. I dropped it into a new project as-is just to try it out and ran into a couple of problems: 1) When I mouse over a curve all the code runs, but nothing happens on-screen in AutoCAD (Map, 2012). The curveInfo variable gets filled out with text as expected but the call to AppendToolTipText doesn't seem to do anything. 2) When I mouse OUT from a curve I often get a weird blank debug assertion thrown from GetPickedEntities() I wonder if these problems are due to changes between ACAD 2010 and 2012...?
1 reply
@Christopher Allen-Poole, if you've gone to the trouble of typing out the question, self-answering is encouraged on SO, so go ahead and give the community the benefit of your experience. That exact thing happened to me a couple months ago: http://stackoverflow.com/q/8715738/99640 The question wound up so long and involved that it seemed a shame to throw it away, so I posted it and answered it myself.
Toggle Commented Mar 15, 2012 on Rubber Duck Problem Solving at Coding Horror
Nope, that did not fix the problem either.
1 reply
According to http://connect.microsoft.com/VisualStudio/feedback/details/487949/debugging-external-application this was fixed in Studio 2010 SP1, released 3/3/2011. SP1 release download at http://www.microsoft.com/download/en/details.aspx?id=23691 I used option 3 to get one project working a few months ago, but then today none of the options were working for me on a new project, so I'm in the process of downloading the service pack. Will post back here with results in the hope of creating an option 4...
1 reply
Oops, didn't mean to post that from my personal Google login with the goofy dragon avatar. Meant to post from my work-related account...
Oh, so it was Typepad's fault - I also tried to post what you have above as IsPointOnCurveGCP on yesterday's post :)
1 reply
I get this compiler error in Visual Studio 2008, .NET 3.5: error CS1657: Cannot pass 'feature' as a ref or out argument because it is a 'foreach iteration variable' Obviously I can just use a for loop instead, but I'm wondering whether the code sample was compiled in an older Studio version and something changed in the C# language specification, or if there's some other reason the sample as written isn't working for me.
Sorry, blending my class with yours I screwed up - the key piece is that mine doesn't have to inherit from DocumentPlugIn so it doesn't even need a tbp file: public class StaticConnectionDocumentPlugin { public static Application StaticApplication { get { return Application.Active; } } public static Document StaticDocument { get { return StaticApplication != null && StaticApplication.Documents != null ? StaticApplication.Documents.Active : null; } } }
I'm curious. I've been doing this exact same thing with the following simpler class: using System; using Topobase.Forms; namespace SingletonPlugIn { /// /// Provides static access to Topobase context. /// public class StaticConnectionDocumentPlugin : DocumentPlugIn { public static Application StaticApplication { get { return Application.Active; } } public static Document StaticDocument { get { return StaticApplication != null && StaticApplication.Documents != null ? StaticApplication.Documents.Active : null; } } } } Is there some difference or improvement to be had by storing the Document.Application present when OnInitComplete is called? Mine has to do null checks in case StaticApplication is null (in case the current drawing is a plain AutoCAD drawing with no Topobase data, for example), but it looks like yours should be doing the same thing since there's no guarantee that OnInitComplete will be called before StaticDocument.
It's a small thing, but.... // Sampling value to reduce point set on capture internal static short Sampling ... // Sampling value to reduce point set on capture internal static bool Speech Ah, the pain of keeping comments in sync with code ;)
1 reply
Thanks Kean, I got what I'm trying to do working using the "iterate over the entire database" method, but as pointed out that could be problematic for large dwgs... I'll submit to ADN.
1 reply
Are there any known issues with using the EditorInput.SelectCrossingWindow method outside the context of a command? I'm trying to call it from an Overrule WorldDraw override and all I get is an Error status...
1 reply
I came looking for a simple way to create a thumbnail bitmap from a block reference and wound up with something generic enough I thought more people might find it useful. Using BlockView and a little of the render to file stuff at http://through-the-interface.typepad.com/through_the_interface/2007/04/rendering_autoc.html , I got my bitmap created, but I also came up with an architecture that lets you load the control in the designer without crashing Visual Studio. Instead of inheriting a PreviewCtrl class that the designer can't handle, I created a wrapper class in 100 lines of code that takes a plain old Panel object and hooks in the view/model/device and an OnPaint event to redraw the view. The code for the class (which can be dropped into any old ACAD addon project) looks like this: ******************************************** using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.GraphicsSystem; namespace SNS.DesignData.Draw.Forms { public class EntityViewManager : IDisposable { View _view = new View(); Device _device; Model _model; System.Windows.Forms.Panel _control; static Manager GraphicsManager { get { return Application.DocumentManager.MdiActiveDocument.GraphicsManager; } } public EntityViewManager(Entity ent, System.Windows.Forms.Panel control) { _device = GraphicsManager.CreateAutoCADDevice(control.Handle); _device.OnSize(control.Size); _device.BackgroundColor = control.BackColor; _device.Add(_view); _model = GraphicsManager.CreateAutoCADModel(); _view.Add(ent, _model); // TODO: Figure out why line weight is not displayed SetView(_view, ent); // TODO: Figure out why text from overrides is not displayed _view.Update(); _control = control; _control.Paint += control_Paint; } public static Bitmap GetBitmap(Entity ent, Size size, Color backgroundColor) { Bitmap result = new Bitmap(size.Width, size.Height); using (View view = new View()) using (Device device = GraphicsManager.CreateAutoCADOffScreenDevice()) using (Model model = GraphicsManager.CreateAutoCADModel()) { view.Add(ent, model); device.Add(view); device.OnSize(size); device.BackgroundColor = backgroundColor; device.DeviceRenderType = RendererType.FullRender; SetView(view, ent); result = view.RenderToImage(); device.EraseAll(); } return result; } static void SetView(View view, Entity ent) { Extents3d viewExtents = ent.GeometricExtents; Point3d boxCenter = viewExtents.MinPoint + 0.5 * (viewExtents.MaxPoint - viewExtents.MinPoint); Point3d eye = boxCenter + Vector3d.ZAxis; double xMax = Math.Abs(viewExtents.MaxPoint.X - viewExtents.MinPoint.X + 1); double yMax = Math.Abs(viewExtents.MaxPoint.Y - viewExtents.MinPoint.Y + 1); view.SetView(eye, boxCenter, Vector3d.YAxis, xMax, yMax); } void control_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { _view.Invalidate(); _view.Update(); } #region IDisposable Members public void Dispose() { _control.Paint -= control_Paint; _control.Invalidate(); _device.Erase(_view); _view.EraseAll(); _model.Dispose(); _view.Dispose(); _device.Dispose(); } #endregion } } ******************************************** To use this to render an entity in a dialog temporarily I just do a using (var view = new EntityViewManager(ent, controlPreview)), and when I leave the using clause the view is cleared and the placeholder control reverts to normal. ent is any ACAD database object type and controlPreview is the Panel control hosted in your dialog. For a longer-lived preview the dialog will probably need an EntityViewManager member variable, created when the dialog is displayed and disposed when the dialog is closed. I did this in a modeless palette and had to make sure to also dispose of the EntityViewManager upon notification that the current document was closing because by the time the palette was destroyed the current document was gone and the model/view/device couldn't be disposed cleanly. The static GetBitmap method is pretty straightforward, tacked onto this class to make use of the common view/extent/eye setup code. You may notice the two TODOs. If the entity passed in is a Polyline with Lineweight set thick, the control only displays a thin line. I keep expecting to find a ShowLineWeight property on one of the view/model/device objects somewhere, but so far no luck. The more complicated TODO is because I'm also playing with overrules to draw some text and extra lines next to polylines with certain xdata (see http://through-the-interface.typepad.com/through_the_interface/overrules/ ). If I pass one of these lines to the wrapper, the extra lines show up but the text does not. I'm completely stumped on this behavior.
1 reply
I tried to send a detailed response via reply email to TypePad, but that doesn't seem to have worked... Long story short, using BlockView and a little of the render to file stuff at http://through-the-interface.typepad.com/through_the_interface/2007/04/rendering_autoc.html , I got it working (well enough for proof-of-concept demo purposes anyway, which is all I was after).
1 reply
"understanding how AutoCAD places its data on the clipboard would hopefully allow us to load it into a Database and then create a thumbnail from it" I know this is kind of an old post, and you didn't go this route, but do you know of an API that allows creating a bitmap thumbnail from drawing data in some simple fashion like this? Specifically, given a C# BlockReference I'm trying to do some sort of BitBlt operation and get out something I can put in a ListView ImageList... I've gone over the BlockReference and base class methods and searched the documentation for "bitmap" and nothing looks promising.
1 reply
Chuck Wilbur is now following The Typepad Team
Oct 19, 2011