Thanks J,
Very nice article, much appreciated.
I think I am getting the idea now, the ienumerator is simply an object that contains whatever the class definition tells
it to. That makes perfect sense because looping is so common, and being able to control what get exposed from a
collection or array or whatever is very useful.
good stuff.
J. Daniel Smith
|>Like many (maybe even most) things in programing, an enumerator is an
|>abstraction: rather than fix that things are always stored in 0-based
|>arrays, and that you can only walk the array from 0 to n-1, you create an
|>abstraction. This lets you store things in linked lists, stacks, binary
|>trees, XML, etc. and still use the same code to process this data. This
|>abstraction also lets you easily process your data in different ways, for
|>example n-1 to 0 for an array or depth-first vs. breadth-first for a tree.
|>
|>Here (http://msdn2.microsoft.com/en-us/vcsharp/bb264519.aspx) is a recent
|>MSDN article that shows some of the ways these abstractions can be so
|>useful.
|>
|>Parts (much) of the AutoCAD .NET API was designed and implemented with .NET
|>1.0, before the introduction of generics in .NET 2.0. As a result, some of
|>the APIs aren't quite as clear as they could be now with generics. For
|>example, if written today, this API might use IEnumerable rather
|>than just IEnumerable.
|>
|> Dan
|>
|>"James Maeding" wrote in message
|>news:5502479@discussion.autodesk.com...
|>Hey Cougar,
|>lookslike you have to call the getenumerator method for that function, like:
|>
|>vPort.FreezeLayersInViewport(IDList.GetEnumerator())
|>
|>This enumerator concept still does not make sense to me.
|>What actual info does the Enumerator object hold?
|>I am guessing its a pointer to an object in a collection, but not quite
|>sure.
|>
|>I took Tony's advice and found an online forum where people were willing to
|>help...whoops, ended up right here 🙂
|>
|>CougerAC <>
|>|>James,
|>|>
|>|>The method you want to use is expecting you to pass a type that implements
|>the IEnumerable interface. Looking at this method, I can also see that it is
|>expecting the collection to contain ObjectIDs. A good collection to use in
|>this situation is Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection. This
|>collection internally implements the IList interface which in turn
|>implements the IEnumerable interface.
|>|>
|>|>If you look at the method declaration for FreezeLayersInViewport, the name
|>of the variable gives away what you should be passing (layerIDs) or the
|>ObjectIDs of the layers you want to freeze in the viewport.
|>|>
|>|>So:
|>|>
|>|>1. declare a variable of type
|>Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection (make sure you NEW
|>this)
|>|>[code]
|>|>Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection IDList =new
|>Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection();
|>|>[/code]
|>|>2. add the object ids of the layers you want to freeze to this
|>|>[code]
|>|>IDList.Add(Layer.ObjectID);
|>|>[/code]
|>|>3. call the FreezeLayersInViewport method passing the collection of Layer
|>ObjectIDs to freeze
|>|>[code]
|>|>viewport.FreezeLayersInViewport(IDList);
|>|>[/code]
|>|>
|>|>Should do it for ya,
|>|>C
|>James Maeding
|>Civil Engineer and Programmer
|>jmaeding - at - hunsaker - dotcom
James Maeding
Civil Engineer and Programmer
jmaeding - at - hunsaker - dotcom