The ActiveX Object Model gives access to AutoCAD Land Desktop horizontal alignments. An Alignment can contain tangents (AlignTangent), curves (AlignCurve) and spirals (AlignSpiral). An Alignment can be set to current. It supports the locking mechanism from AutoCAD Land Desktop. In addition, station equations are supported for each Alignment.
This section describes the fundamentals you need to know when developing an application with Alignments. It provides information on creating, using, and saving Alignments.
Creating an Alignment
If an Alignment is added successfully to the Alignments collection, there are two results: a) the new Alignment is made Current and b) the new Alignment will have a write lock on it. The new Alignment is also saved immediately. AutoSave is ignored when an Alignment is created.
"Current" Alignment and Locks
AutoCAD Land Desktop has the notion of a "current" alignment. Historically, this has been used in the application to relieve the user from having to select an alignment for every command. Also, when an alignment was set to current, locks were created on that alignment. If there was a previous alignment, the locks were freed.
The ActiveX Object Model supports the “Current” Alignment concept. An Alignment can be made Current and locks will be generated at that time. Also, that Current Alignment in ActiveX Object Model will also be the current alignment in AutoCAD Land Desktop. Through the ActiveX Object Model, you can stay in sync with the menus.
When the Alignments collection is created, all of the Alignment names are loaded into memory. At that time, each Alignment is given a kReadLock. No physical lock is created on disk. This lock exists only in the ActiveX Object Model. If the Alignment in the collection is the Current Alignment, then the ActiveX Object Model will retrieve whatever lock currently exists on disk. It could be either a kReadLock or a kWriteLock.
When you make an Alignment current, several things will happen. If there was a previous Current Alignment, that will be unlocked. Next, the new Current Alignment will be set in both the ActiveX Object Model and AutoCAD Land Desktop. Finally, a lock will be generated on that Alignment in the ActiveX Object Model and on disk. This lock can be seen by any users currently in that project. The lock can be either a kReadLock or a kWriteLock. The type of lock depends on weather that Alignment was locked by another user.
As a rule, both the ActiveX Object Model and AutoCAD Land Desktop will always try to retrieve a kWriteLock when accessing an object. This applies to Alignments and Surfaces. If someone else has a write lock on that object, then a read lock will be added to that object.
Before any edits are made on an Alignment, the Alignment must be made Current. Also, that Alignment must have a kWriteLock for any changes to be made.
You can add a new alignment to the collection and later define the underlying geometry. Be advised that if you save an alignment without adding any tangents, curves or spirals, you will not be able to edit the geometry using the alignment editor.
Any changes made to an Alignment are automatically saved. When the Alignment is saved all entities and the general Alignment data (starting station, description) are written out. This can impact performance if many changes are made to the Alignment. Remember that every change made results in writing the entire Alignment.
To help with the performance issues, AutoSave was created. If Alignments.AutoSave is True, then every change made to an alignment results in a write operation. If Alignments.AutoSave is False, then no write operations are performed. It is the responsibility of the programmer to call Alignment.Save for the write operation.
AutoSave is at the Alignments collection level. When the AutoSave value is set, all alignments in the collection are updated.