ScreenSpaceLines3D should implement IDispose so the objects can be deleted properly

Topics: Developer Forum
Apr 15, 2011 at 7:05 PM

Currently, ScreenSpaceLines3D hooks an event handler to CompositionTarget.Rendering. If the lines are removed from the viewport, they're still trying to render themselves via this hook which causes a crash. There have been several questions about this but they seem to have been all unaddressed. I had a similar problem and it took five minutes in the code to subclass off of IDisposable and write in a little Dispose routine which simply unhooked this event handler and fixed the problem. It would be nice if this fix was in the official release rather than it being rewritten by anyone who wants to use lines but also wants to occasionally delete them from the scene. Like I said - a five minute fix.

Sep 23, 2011 at 8:16 PM

Hi! I'm having exactly the same problem, but I've no idea about how to solve it! I don't really get what you mean about "hook" and "unhook". Can you please help me fixing this bug? Every time I clear my Vieport3D to generate a new model an error occurs if there are fewer ScreenSpaceLines objects loaded as children. If the quantity of children objects remains invariable nothing bad happens...

Sep 24, 2011 at 5:45 AM

It's been too long - don't even remember what code I was working on at the time.  I do remember that it was pretty easy and I described it pretty well in the above article.  Just look for a hook to CompositionTarget.Rendering in the code.  Take the ScreenSpaceLines3D class, subclass it from IDisposable, and in the Dispose routine unhook from CompositionTarget.Rendering.  Five minute fix.  Looks like the developers have abandoned this code or surely they would have taken the five minutes to fix something so many people have complained about.

Sep 25, 2011 at 8:41 AM

Hi again and thank you very much for the quick answer! The problem is that I can't open the project 3DTools to modify it. I am working with VB .NET express edition and I am just adding reference to 3DTools.dll. Do you know which platform I should use to modify the code and recompile it? It would be actually easier for everyone if someone would post a recompiled version of the dll with this problem fixed. If you do that many people would be very happy...
Meanwhile I have found a very ugly solution that at leat works. I'm just adding a set of ScreenSpaceLines3D to my viewport with a number of objects that remains invariable (so that i dont have to delete any of them). If I don't one to display one of them I clear the list of points.

Sep 25, 2011 at 3:49 PM

The sources are out there.  I forget where - I assume wherever you downloaded the dll - codeplex? - and like I said, I even forget the project I was working on when I posted this so I can't go back and find the dll (plus, I don't think I made it into a separate dll - just threw the sources in my project).  Find the sources, alter them and you're good to go.

Oct 12, 2011 at 12:50 PM

http://www.codeplex.com/Download?ProjectName=3dtools&DownloadId=17968