BaselineSetTargets Method |
Sets the target information. The pass in updatedTargets should be got from method GetTargets().
Namespace: Autodesk.Civil.DatabaseServicesAssembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.292
Syntaxpublic void SetTargets(
SubassemblyTargetInfoCollection updatedTargets
)
Public Sub SetTargets (
updatedTargets As SubassemblyTargetInfoCollection
)
public:
void SetTargets(
SubassemblyTargetInfoCollection^ updatedTargets
)
Parameters
- updatedTargets SubassemblyTargetInfoCollection
-
ExceptionsException | Condition |
---|
ArgumentException |
Thrown when the pass in updatedTargets is not got from method GetTargets() of this object.
|
Example 1
2[CommandMethod(ReferenceGuideSample.GoupId, "SetTargets", CommandFlags.Modal)]
3public void SetTargets()
4{
5 using (Transaction tr = startTransaction())
6 {
7
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
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
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);
23
24
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