Sie sind auf Seite 1von 4

Some background to AutoCAD's MDI implementation and per-document data - Through the Interface

http://through-the-interface.typepad.com/through_the_interface/2006/10/some_background.html[21/01/2014 16:49:16]
Translate this page Spanish
Microsoft

Translator
K E A N W A L M S L E Y

About the Author
Kean on Google+
J A N U A R Y 2 0 1 4
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
P O S T I N D E X
R E V E R S E I N D E X
Working with specific AutoCAD object types in .NET | Main | Per-document
data in ObjectARX
October 04, 2006
Some background to AutoCAD's MDI implementation and
per-document data
Thanks once again to all of you who posted your congratulations on Zephyrs
birth. Im now getting back into the swing of things after my paternity leave, and I
hope this is me restarting regular posts to this blog. Im actually feeling quite
energized (although its probably nervous energy from sleep-deprivation :-) and
have a number of topics Id like to discuss over the coming weeks.
First up is per-document data. Before talking about how best to segment data on
a per-document basis, its definitely worth talking about some of the history of this
area with respect to the various API technologies but also AutoCAD and why
this is even an issue.
So where to start? The logical place is back in the AutoCAD 2000 timeframe.
One of the big features of AutoCAD 2000 (codenamed Tahoe) was the Multiple
Design Interface (a.k.a. the Multiple Document Interface or MDI). This was a big
deal until then AutoCAD had only been an SDI (Single Document Interface)
application - and architecturally a lot needed to happen to enable MDI.
Aside from architectural changes in the product, big decisions were made about
the various APIs available in AutoCAD at the time particularly around what
needed to happen for them to function in an MDI environment.
A little about AutoCADs architecture AutoCAD started out as a single-threaded
application. During the R14 timeframe (and perhaps even during R13), it was built
with multithreaded C-runtime and MFC libraries, but it was essentially single-
threaded in its behaviour. Once that groundwork was laid, it was then possible to
take AutoCAD to the next level, and implement an MDI environment.
We did so by adopting the use of fibers, which MSDN describes as:
A fiber is a unit of execution that must be manually scheduled by
the application. Fibers run in the context of the threads that
schedule them. Each thread can schedule multiple fibers. In general,
fibers do not provide advantages over a well-designed multithreaded
application. However, using fibers can make it easier to port
applications that were designed to schedule their own threads.
Each document inside AutoCAD has its own fiber, and these are switched
programmatically when users switch between drawings. Theres also a session
fiber to take care of global constructs such as the Windows message-loop. Youll
often here about ObjectARX or .NET applications choosing to work in the
application context (a.k.a. the session context or the session fiber), or in an
individual document context.
The only API technology inside AutoCAD that is inherently document-centric is
LISP: the decision was made specifically during the development of Tahoe to
1 0 R A N D O M
P O S T S
F E E D / S H A R E
Subscribe via RSS
ShareThis
676 Like
S E A R C H

Impressions of Tel Aviv
A guide-line for Visual
Studio
ADN DevCast Episode 3
AU Handouts: AutoCAD
.NET - Developing for
AutoCAD Using F#- Part
1
Getting the full path of the
active drawing in
AutoCAD using .NET
The end of a very
interesting week
DevLabs in Beijing,
Bangalore Las Vegas(?)
Handling COM calls
rejected by AutoCAD from
an external .NET
application
Linking Circles, Part 3:
Automatic linking on circle
creation
An automatic numbering
system for AutoCAD
blocks using .NET - Part 1
C A T E G O R I E S
3D printing 3ds Max
AJ AX Android Annotation
scaling Arduino
ASP.NET Async AU
Augmented Reality
AutoCAD
AutoCAD
.NET AutoCAD OEM
Autodesk Autodesk
Exchange AutoLISP /
Spanish

Some background to AutoCAD's MDI implementation and per-document data - Through the Interface
http://through-the-interface.typepad.com/through_the_interface/2006/10/some_background.html[21/01/2014 16:49:16]
A U T O D E S K B L O G S
AutoCAD Insider
Between the Lines
It's Alive in the Lab
Mod the Machine
The Building Coder
It's All J ust Ones and Zeros
Dances with Elephants
AutoCAD DevBlog
Cloud and Mobile DevBlog
AEC DevBlog
Manufacturing DevBlog
Infrastructure Modeling DevBlog
Around the Corner
More on autodesk.com...
Comments
have each document maintain its own LISP environment (this is part of the
information that gets switched as the user changes between documents and
therefore fibers get switched). This was done for various reasons, but primarily to
help maintain compatibility: until then all LISP applications had been document-
centric, and if we had chosen a different path we would have forced many
customers and developers to migrate their LISP code. So when you load LISP
code or set LISP variables in AutoCAD they relate to a specific document.
Communication between documents was facilitated with the introduction of
something called the blackboard a global area allowing variables to be shared
between document namespaces.
All other APIs VB(A), ObjectARX and now our managed API exist by default
in the session context, which means that variables you declare globally in your
application are shared across documents. That said, when you register a
command in ObjectARX or .NET, the default flags that are passed to register the
command actually do so in the context of a particular document. This means you
dont need to worry about locking the document youre in, for instance, but it also
means for .NET applications that the variables you declare will be instantiated per
document. More on this in the next entry (or the one after), when Ill talk about the
options for storing per-document data in .NET applications.
You do have the option of registering commands as relevant to the session
context, which is useful if they dont work on a particular drawing (and should
work in zero-document mode, for instance, like the HELP command) or if they
work across documents (at which point each document will need explicit locking
before being accessed or manipulated).
In the next post (which will hopefully be this week) Ill talk about the specific
techniques ObjectARX applications needed to use to support MDI with particular
focus on the storage and use of per-document data. Ill then go and do the same
for .NET.
You might also like:
Per-document data in ObjectARX
Per-document data in AutoCAD .NET applications - Part 1
Per-document data in AutoCAD .NET applications - Part 2
Reflecting on AutoCAD .NET
Linkwithin
Posted at 06:34 PM in AutoCAD, Documents | Permalink
TrackBack
TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83452464869e200d8351dbf7c69e2
Listed below are links to weblogs that reference Some background to AutoCAD's
MDI implementation and per-document data:
Reply February 27, 2007 at 06:05 PM
The MDI was big advance in AutoCAD development.
However a lot of LISP that was created as intelligent
batch program were basically cripple. When a LISP file
opens a drawing that is as far as it goes unless to teach
it to write and run a script in which an external text file
has been created and managed.
t luke said...
Visual LISP Azure Batch
processing Blocks Books
Civil 3D Commands
Concurrent programming
Conferences Core
Console Custom objects
Database Debugging
Design DesignScript
DevCasts DevTV
Dimensions Documents
Draw order Drawing
structure DWF Dynamic
Dynamic Blocks Excel
F# Facebook Fields
Fractals Freewheel
Games Geometry
Graphics system
Hatches HTML
Installation Instructables
Interviews Inventor iOS
IronPython IronRuby
J ava J avaScript J igs
J SON Kinect Leap
Motion LINQ Mac
Mobile Morgan Netduino
Notification / Events
Object properties
ObjectARX Overrules
Personal Plotting Plugin
of the Month Point
clouds Purge Python
Raspberry Pi RealDWG
Reality capture REST
Retro computing Revit
Robotics Ruby Runtime
SaaS Security
Selection Social media
Solid modeling Tables
Tinkercad Training
Transactions Translation
Travel Unity3D User
interface Visual Basic &
VBA Visual Studio
Web/Tech Weblogs
WinRT WPF XML
R E C E N T
P O S T S
Previewing geometry as it
streams into AutoCAD
using .NET
Leaving Israel
Impressions of Tel Aviv
Forcing AutoCAD object
snapping using .NET
Update on purging DGN
linestyles from AutoCAD
drawings using .NET
AU 2013 classes available
on-demand
Attack of the robots
Happy 2014
Merry Christmas!
Moving text in an
AutoCAD block using
.NET Part 3
R E C E N T
C O M M E N T S
Kean Walmsley on Taking
Some background to AutoCAD's MDI implementation and per-document data - Through the Interface
http://through-the-interface.typepad.com/through_the_interface/2006/10/some_background.html[21/01/2014 16:49:16]
Comment below or sign in with Typepad Facebook Twitter Google+
and more...
(You can use HTML tags like <b> <i> and <ul> to style your text. URLs
automatically linked.)
Email address is not displayed with comment.

Reply February 27, 2007 at 06:19 PM
Yes, LISP isn't the best way to batch up operations in
an MDI environment: the decision was made during
development of AutoCAD 2000 to have each document
maintain its own namespace. This was by far the best
way to maintain compatibility with existing LISP code,
but made it hard to work across documents.
Suddenly COM (VB) became the interface (language) of
choice for this (or a tool such ScriptPro, in combination
with a LISP-defined command).
Kean said...
Reply November 23, 2010 at 01:54 PM
How to change the name of entity from Circle to Pipe?
if in .Net is not possible what is dbx solution when we
inherit from AcDbPolyline changing name from Polyline
to MyPolyline?
Mohammad Afghari said...
Reply November 23, 2010 at 03:09 PM
It maybe possible to overrule the COM
interface GUID, but I haven't done this myself.
Kean
Kean Walmsley said in reply to Mohammad Afghari...
a screenshot of a user-
selected portion of a
drawing using .NET
Dominik Hepp on Taking
a screenshot of a user-
selected portion of a
drawing using .NET
Kean Walmsley on First
impressions of Kinect for
Windows 2.0 pre-release
Andrew on First
impressions of Kinect for
Windows 2.0 pre-release
Kean Walmsley on
Adding to AutoCADs
Application Menu and
Quick Access Toolbar
using .NET
Dharmarajan on Adding to
AutoCADs Application
Menu and Quick Access
Toolbar using .NET
Kean Walmsley on
Updating a specific
attribute inside an
AutoCAD drawing using
.NET
Kean Walmsley on
AutoCAD DGN Hotfix now
available
Greg Robinson on
Gathering points defining
3D AutoCAD geometry
using .NET
Kean Walmsley on
AutoCAD 2014 for
developers
A R C H I V E S
J anuary 2014 (8)
December 2013 (9)
November 2013 (13)
October 2013 (13)
September 2013 (13)
August 2013 (14)
J uly 2013 (14)
J une 2013 (12)
May 2013 (14)
April 2013 (13)
March 2013 (12)
February 2013 (12)
J anuary 2013 (15)
December 2012 (12)
November 2012 (13)
October 2012 (14)
September 2012 (12)
August 2012 (13)
J uly 2012 (9)
Name
Email Address
Web Site URL
Post Preview
Some background to AutoCAD's MDI implementation and per-document data - Through the Interface
http://through-the-interface.typepad.com/through_the_interface/2006/10/some_background.html[21/01/2014 16:49:16]
J une 2012 (13)
More...

Das könnte Ihnen auch gefallen