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.4.2516.0

Syntax

C#
public ObjectIdCollection CreateReference(
	int index,
	Database hostDrawing
)
Visual Basic
Public Function CreateReference ( _
	index As Integer, _
	hostDrawing As Database _
) As ObjectIdCollection
Visual C++
public:
ObjectIdCollection^ CreateReference(
	int index, 
	Database^ hostDrawing
)

Parameters

index
Type: System..::..Int32
Data shortcut object index in current working project.
hostDrawing
Type: Database
Host Database. The reference entity will be created in this database.

Return Value

The Data Reference entity and sub-entity IDs.

Examples

API user can call this method to create reference in the hostDrawing by the index of the data shortcut in a working project.
CopyC#
 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);

Exceptions

ExceptionCondition
System::ArgumentNullException, System::ArgumentException

See Also