Share

SubassemblyTargetInfo Class

Encapsulates a subassembly target information object.

Inheritance Hierarchy

SystemObject
  SystemMarshalByRefObject
    DisposableWrapper
      Autodesk.Civil.DatabaseServicesSubassemblyTargetInfo


Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.280

Syntax

C#

public class SubassemblyTargetInfo : DisposableWrapper

VB

Public Class SubassemblyTargetInfo
	Inherits DisposableWrapper

C++

public ref class SubassemblyTargetInfo : public DisposableWrapper

The SubassemblyTargetInfo type exposes the following members.

Properties

 NameDescription
Public propertyAssemblyGroupName Gets the Assembly group name.
Public propertyDisplayName Gets the display name.
Public propertyLogicalName Gets the logical name.
Public propertySubassemblyName Gets the Subassembly name.
Public propertyTargetIds Gets or sets the ObjectIdCollection of targets.
Public propertyTargetToOption Gets the option of how to target.
Public propertyTargetType Gets the target type.
Public propertyUseSameSideTarget Gets or sets whether to use targets on the same side as the subassembly.

Example

 1// Test command SetTargets by using tutorial file "Corridor-5c.dwg".
 2[CommandMethod(ReferenceGuideSample.GoupId, "SetTargets", CommandFlags.Modal)]
 3public void SetTargets()
 4{
 5    using (Transaction tr = startTransaction())
 6    {
 7        // Create feature lines that will be used as target later.
 8        ObjectId oidF1 = CreateFeatureLine("FL1", new Point2dCollection(new Point2d[] { new Point2d(3679, 4453), new Point2d(4046, 4633) }));
 9        ObjectId oidF2 = CreateFeatureLine("FL2", new Point2dCollection(new Point2d[] { new Point2d(4339, 3643), new Point2d(4653, 3780) }));
10
11        // Target info can be gotten by different object level: Baseline Region, Baseline, Corridor.
12        Corridor corridor = _civildoc.CorridorCollection["Corridor - (1)"].GetObject(OpenMode.ForWrite) as Corridor;
13        Baseline baseline = corridor.Baselines["Baseline (1)"];
14        BaselineRegion baselineRegion = baseline.BaselineRegions[0];
15        SubassemblyTargetInfoCollection saTargetInfoCol = baselineRegion.GetTargets();
16
17        // Target info can be set by different object level: Baseline Region, Baseline, Corridor.
18        SubassemblyTargetInfo saTargetInfo = FindSATargetInfo(saTargetInfoCol, "LaneSuperelevationAOR - (Left)", "Width Target", SubassemblyLogicalNameType.Offset);
19        saTargetInfo.TargetIds = new ObjectIdCollection(new ObjectId[] { oidF1, oidF2 });
20        saTargetInfo.TargetToOption = SubassemblyTargetToOption.Nearest;
21        saTargetInfo.UseSameSideTarget = true;
22        baselineRegion.SetTargets(saTargetInfoCol); // Set target back to make corridor out of date
23
24        // Rebuild the corridor after corridor is out of date.
25        corridor.Rebuild();
26
27        tr.Commit();
28    }
29}
30private SubassemblyTargetInfo FindSATargetInfo(SubassemblyTargetInfoCollection saTargetInfoCol, string saName, string targetDisplayName, SubassemblyLogicalNameType targetType)
31{
32    for (int i = 0; i < saTargetInfoCol.Count; ++i)
33    {
34        SubassemblyTargetInfo saInfo = saTargetInfoCol[i];
35        if (saInfo.SubassemblyName == saName && saInfo.DisplayName == targetDisplayName && saInfo.TargetType == targetType)
36        {
37            return saInfo;
38        }
39    }
40    return null;
41}
42
43private ObjectId CreateFeatureLine(string name, Point2dCollection points)
44{
45    Polyline polyline = new Polyline();
46    int index = 0;
47    foreach (Point2d p in points)
48    {
49        polyline.AddVertexAt(index++, p, 0, 0, 0);
50    }
51    ObjectId oidPolyline = AddEntityToDatabase(polyline);
52    return FeatureLine.Create(name, oidPolyline);
53}
54private ObjectId AddEntityToDatabase(Autodesk.AutoCAD.DatabaseServices.Entity obj)
55{
56    ObjectId objId = ObjectId.Null;
57    Database db = HostApplicationServices.WorkingDatabase;
58    using (Transaction trans = db.TransactionManager.StartTransaction())
59    {
60        BlockTable bt = (BlockTable)db.TransactionManager.GetObject(db.BlockTableId, OpenMode.ForRead, false);
61        BlockTableRecord btr = db.TransactionManager.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
62        objId = btr.AppendEntity(obj);
63        trans.AddNewlyCreatedDBObject(obj, true);
64        trans.Commit();
65    }
66    return objId;
67}

See Also

Reference

Was this information helpful?