AutoCAD .NET
-
Back in a much earlier post we looked at some code to access the pickfirst selection set. I thought I'd now take a look at the more specific case of defining a command that adds entities into the current pickfirst selection set. Here's some C# code I used to do this, with comments describing its behaviour. The most interesting point is that once we get the contents of the existing pickfirst set we then clear it and rehighlight the entities manually, to give the user a graphical clue of the previous contents. using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime;…
-
In the last post we looked at some of the potential uses for the Reflector application. I didn't end up elaborating on the third reason I stated for the Reflector being a compelling tool - that it can be used to help optimize code based on the resultant IL created. For fun I played around with using the Reflector to compare similarly structured code, and thought I'd use this post to share my approach and the results. Firstly, though, I recommend taking a look at this useful primer on MSIL. Now, let's take some nearly identical code, and compare the…
-
Reflection Now we're finally going to spend some time looking at Reflection. As mentioned in a previous post, .NET assemblies include intermediate language instructions plus metadata about types, members and assembly references. It is possible to access this information through Reflection. For another definition of Reflection, here's what MSDN has to say about System.Reflection: The System.Reflection namespace contains types that retrieve information about assemblies, modules, members, parameters, and other entities in managed code by examining their metadata. These types also can be used to manipulate instances of loaded types, for example to hook up events or to invoke methods. To…
-
In the last-post-but-one we took an introductory look at protecting intellectual property in various types of application modules used with AutoCAD. Thanks to everyone for the subsequent discussion – it's great to see such diversity of opinion out there on this subject. Before moving on to Reflection and the Reflector tool, I thought I'd first follow up on this previous post. So… regarding the various comments - here are the points that resonated particularly with me: It's not always important to obfuscate – much standard implementation work doesn't contain trade secrets, for instance, and some software providers (including Microsoft &…
-
My apologies to those expecting more on IP protection in .NET - I ended up deciding to make this interim post regarding a longstanding issue. I'll get right back to the IP question next (I hope :-). Back in a much earlier post we looked at getting the ObjectARX & Managed Wizards working with the Express editions of Visual Studio. While it was successful enough with C++ Express, VB and C# Express proved to be trickier animals - as was clear from the long thread that followed the post. Anyway, Cyrille Fauvel, the principle author of various Visual Studio Wizards…
-
This is an interesting topic – and one that I'm far from being expert in – so it would be great if readers could submit comments with additional information. Intellectual property protection is a major concern for software developers, and issues that are seen today with .NET languages have been troubling AutoCAD developers since the introduction of AutoLISP. So, what are these issues? As a professional software developer, if you ship source-code to your customers there is substantial risk of it being borrowed or stolen for use in other unlicensed situations. This is true if you ship the actual source…
-
Most of this week I've spent catching up after a nice, long break, as well as spending a few days in Prague helping interview potential recruits for our European team. Now it's finally time for me to climb back into the blogging saddle... This first entry of 2007 is based on some code provided by Viru Aithal, a member of our team based in Bangalore. The code demonstrates how to create a leader using an arrowhead other than the current default (the one referred to by the DIMBLK system variable). Here's the C# code: using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices;…
-
OK, I have to admit I feel a bit cheeky making a separate post out of this one, but then I did promise our friends at TheSwamp that I'd post this additional code, once more provided by Sreekar Devatha in response to an ADN support request. The code is basically the same as that in my last post. The only change is that after we reverse the list of containers we don't go and add in the selected entity. Which means that when we get our path it stops at the container of the selected entity, not the entity itself.…
-
I'd like to thank two people for this post: Kerry Brown, an ADN member in Australia and regular contributor to TheSwamp, pointed me to a response he'd received from a member of the DevTech team in India, Sreekar Devatha. So thanks to both Kerry and Sreekar for providing the material for this post. The problem was to highlight the nested entity returned by the Editor.GetNestedEntity() method. Sreekar's solution was to create a sub-entity path through the nested block structure, and use that to highlight the entity in question. To create the sub-entity path he retrieved the containers of the nested…
-
As promised in the last post, here's some old LISP code I used to demo the original circle linking application. I've changed it slightly to not only move the snake in 2D, now the Z-value of the lead object is set to be a fraction of the object's Y-value. This won't actually change what's seen in a standard overhead view... if you want to revert to 2D-only movement of the snake, simply remove "zval" from the two calls to the MOVE command. I should also add that while the snake will move through 3D by default, I didn't change the…