Beruflich Dokumente
Kultur Dokumente
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
Per-document data in ObjectARX | Main | Per-document data in AutoCAD
.NET applications - Part 2
October 12, 2006
Per-document data in AutoCAD .NET applications - Part 1
The last few posts have focused on the history of MDI in AutoCAD and how to
store per-document data in ObjectARX applications. Now lets take a look at what
can be done for AutoCAD .NET applications...
There are two main approaches for storing per-document data in managed
applications loaded into AutoCAD Ill take a look at the first in this entry and
tackle the second technique next time.
Define commands as instance members of a class
In managed applications you can declare instance or static methods. Static
methods are those specified as static in C#or Shared in VB.NET. Methods that
are not shared/static are known as instance methods.
Static methods are global they do not use data that is specific to an instance
of the class they belong to. Its common to call static methods directly from the
class namespace (MyClass.myMethod()) rather than from specific instance of the
class (myObject.myMethod()). To declare a method as static, you use the static
keyword in C#and the Shared keyword in VB.NET.
Predictably enough, MSDN contains some good information on static classes and
static class members.
Instance methods can be considered local in scope they work on a specific
instance of a class. A method not declared as static/Shared will be an instance
method by default.
So what does this mean for us, as implementers of AutoCAD commands in .NET?
Heres what the documentation says:
"For an instance command method, the method's enclosing type is
instantiated separately for each open document. This means that
each document gets a private copy of the command's instance data.
Thus there is no danger of overwriting document-specific data when
the user switches documents. If an instance method needs to share
data globally, it can do so by declaring static or Shared member
variables."
So to get the benefits of per-document data in a .NET application, you simply
need to declare the relevant command(s) as instance (non-static). Heres some
sample C#code defining two separate commands: one is declared as static
(accessing static data and even contained within a static class) while the other is
an instance method:
usi ng Aut odesk. Aut oCAD. Appl i cat i onSer vi ces;
usi ng Aut odesk. Aut oCAD. Runt i me;
usi ng Aut odesk. Aut oCAD. Edi t or I nput ;
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
Accessing the active
space or layout in an
AutoCAD drawing using
.NET
Loading blocked and
network-hosted
assemblies with .NET 4
My AU 2008
Using AutoCAD to debug
external ray-tracing
routines
Exposing AutoCAD's
Properties Palette
functionality to .NET - Part
1
At AU 2010
AU 2010 Handout:
Integrate F#into Your C#
or VB.NET Application for
an 8x Performance Boost
AU 2008 class schedule
published
Returning data from .NET
to J avaScript inside
AutoCAD
Kinect for Xbox One
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
Spanish