ObjectARX
-
As discussed in the previous post, AutoCAD is now largely an MDI application, and this can have an impact on the design of applications. Let's talk about the theoretical issue with migrating applications into a multiple-document environment. We used to highlight this nicely, back when we first started talking about MDI in AutoCAD 2000. We demonstrated a simple ObjectARX application that defined an alternative RECTANGLE command. The code used in the demo can still be found in the ObjectARX SDK, under samples\editor\rect. The original command - as defined in the badrectang.cpp file – makes use of static member variables to…
-
Most of the functions to access objects in the AutoCAD drawing return generic objects/entities. The base type for objects stored in the AutoCAD database is "DBObject" – which can be used to access common persistence information such as the handle, etc. – but there is no such thing as a pure DBObject: all DBObjects actually belong to a type that is derived from this base (whether that's a "Line", "Circle", "BlockReference", etc.). The next level up in the hierarchy is "Entity", from where you can access graphical properties such as color, layer, linetype, material, etc. The sample code in this…
-
This entry was contributed by Adam Nagy, a member of DevTech EMEA based in Prague. The question is really a combination of two problems: Selecting a subentity Selecting a nested entity Selecting a subentity First we should clarify what a subentity is: A subentity is a pseudo entity which is a logical part of a real entity. In our sample drawing the solid is the real entity [AcDb3dSolid] and the edge is the pseudo entity (there is no AcDbEdge class). In AutoCAD we rely on IDs called GS (short for graphics system) markers to get to these subentities. The ObjectARX…
-
I had a nice surprise this weekend. Jorge Lopez, an old friend and colleague, had been reading this blog entry and decided to create a Visual Studio AddIn that allows you to see resbufs content expanding automatically while debugging. Jorge and I go back a long way - he used to work in DevTech (before it was called that) in our Americas team, back when I was based in Europe the first time. He later went on to join AutoCAD Engineering, and was one of the key contributors to AutoCAD's COM Automation API (although back then it was called either…
-
Thanks to Alexander Rivilis for this topic (he submitted a comment to my previous post that got me thinking about this addendum). When you're asking AutoCAD to execute commands by submitting them to its command-line, it helps to make sure no command is currently active. The accepted approach is to send two escape characters to the command-line... this is adopted by our menu & toolbar macros that consistently start with ^C^C in MNU and now CUI files. Why two? The first is to cancel the "most active" command, and the second is to drop out of either the dimension mode…
-
It's quite common to want to call commands from one or other of AutoCAD's programming environments. While it's cleanest (from a purist's perspective) to use an API to perform the task you want, the quickest way - and the one which will appeal to the pragmatists (and the lazy) among us is often to call a sequence of commands. And there are, of course, a few places in AutoCAD where APIs have not been exposed, so scripting commands is the only way to achieve what you want. Let's take the simple example of adding a line. Here's what you'd do…
-
While debugging it's sometimes very frustrating to find yourself repeatedly stepping into an irrelevant function. For instance, complex statements pretty commonly include object constructors etc. that you know function perfectly well, but the debugger routinely takes you into them. The Visual Studio IDE has an undocumented (and unsupported) mechanism to help with this. During the VC 6.0 timeframe it was implemented via our old friend the autoexp.dat file (see my previous post on this), in a special section called [ExecutionControl]. Since VC 7.0 this has been moved to the Registry. For VC 7.0 and 7.1, it was in the HKCU…
-
I've been using Visual C++ (and afterwards Visual Studio) since it was 16-bit, back in version 1.52. OK, maybe that's not so long ago, relatively (11 short years), but the point is that in spite of having followed the Visual Studio technology over this period, I've so far been completely unaware of the autoexp.dat file. This feature of the Visual Studio was brought to my attention by Ahsan Ali, a programmer in the Inventor Engineering team who was based over in Bangalore at the same time I was (we had both previously worked in the US - he had come…
-
The work we did to migrate AutoCAD 2007 to use Unicode (rather than MBCS), has impacted many developers around the world. For those that are yet to go through the pain themselves, I thought I'd talk about the resources that are available to ObjectARX developers needing to port their applications to Unicode. Firstly, you should check out the Migration Guide that ships with the ObjectARX 2007 SDK (docs/acad_xmg.chm): There's a whole section called "Upgrading to Unicode", with lots of useful information. A good deal of the material in the guide was compiled during the development phase of AutoCAD 2007, as…
-
One of the really compelling features of .NET is its ability to call "legacy" unmanaged C++ APIs. I say "legacy", but we use this facility regularly to call APIs that are far from being considered defunct (the C++ version of ObjectARX is alive and kicking, believe me! :-). Autodesk understands that our development partners have invested many years in application development, and can't afford to throw that investment away to support the latest & greatest (and sometimes "flavor of the month") programming technology. For example, over the years we've made sure it was possible to create a VB or VBA…