Create Data Reference entity at host drawing according to index of entity in data shortcut project.
Namespace: Autodesk.Civil.DataShortcuts
Assembly: AeccDataShortcutMgd (in AeccDataShortcutMgd.dll) Version: 13.8.0.280
Syntax
C#
public ObjectIdCollection CreateReference( int index, Database hostDrawing )
VB
Public Function CreateReference ( index As Integer, hostDrawing As Database ) As ObjectIdCollection
C++
public: ObjectIdCollection^ CreateReference( int index, Database^ hostDrawing )
Parameters
- index Int32
- Data shortcut object index in current working project.
- hostDrawing Database
- Host Database. The reference entity will be created in this database.
Return Value
ObjectIdCollectionThe Data Reference entity and sub-entity IDs.
Exceptions
Exception | Condition |
---|---|
System::ArgumentNullException, System::ArgumentException |
Example
API user can call this method to create reference in the hostDrawing by the index of the data shortcut in a working project.1string hostDwgName = @"C:\Drawing1.dwg"; 2Database hostDb = new Database(false, true); 3hostDb.ReadDwgFile(hostDwgName, FileOpenMode.OpenForReadAndAllShare, false, null); 4 5string sourceDwgName = @"C:\WorkingFolder\ProjectFolder\Alignment.2.dwg"; 6string objectName = "Road A-Left-6.000"; 7DataShortcuts.SetWorkingFolder(@"C:\WorkingFolder"); 8DataShortcuts.SetCurrentProjectFolder("ProjectFolder"); 9DataShortcuts.Validate(); 10bool isValidCreation = false; 11var dsManager = DataShortcuts.CreateDataShortcutManager(ref isValidCreation); 12int index = -1; 13for (int i = 0; i < dsManager.GetPublishedItemsCount(); ++i) 14{ 15 var item = dsManager.GetPublishedItemAt(i); 16 if (sourceDwgName.Equals(Path.Combine(item.SourceLocation, item.SourceFileName)) 17 && item.Name == objectName 18 && item.DSEntityType == DSEntityType.AlignmentOffset) 19 { 20 index = i; 21 break; 22 } 23} 24 25ObjectIdCollection^ objectIds = dsManager.CreateReference(index, hostDb);