Khởi tạo trắc ngang trong Civil3D với ứng dụng API

Yuri Boyka October 28, 2015 0

Các trắc ngang trong SampleLineGroup được nhặt ra từ các SectionSources với tên gọi trong C# là GetSectionSources(). Mà các tập hợp này bao gồm các Objectids.

Một ví dụ sau giúp người dùng chọn Alignment, sau đó tạo ra 1 SampleLineGroup mới. Từ SampleLineGroup này tạo ra các trắc ngang chứa TIN Surface:

// Chọn Alignment, vào khởi tạo 1 SampleLineGroup mới
ObjectId alignmentId = promptForEntity("\n- Chọn Alignment:", typeof(Alignment));
Alignment alignment = ts.GetObject(alignmentId, OpenMode.ForWrite) as Alignment;
ObjectId sampleLineGroupId = SampleLineGroup.Create("New Group", alignmentId);
SampleLineGroup sampleLineGroup = ts.GetObject(sampleLineGroupId, OpenMode.ForWrite) as SampleLineGroup;

// Khởi tạo 1 cọc mới tại vị trí đầu tuyến.
ObjectId sampleLineId = SampleLine.Create("sample line 1", sampleLineGroupId, alignment.StartingStation);

// Nhặt ra các SectionSources 
SectionSourceCollection sectionSources = sampleLineGroup.GetSectionSources();
_editor.WriteMessage("Number of section sources: {0}\n", sectionSources.Count);

ObjectId surfaceId = ObjectId.Null;
foreach (SectionSource sectionSource in sectionSources)
{
    _editor.WriteMessage("Section source is sampled: {0} update mode: {1} type: {2}\n", sectionSource.IsSampled, sectionSource.UpdateMode, sectionSource.SourceType);
    // Kiểm tra có phải là TIN Surface hay không:
    if (sectionSource.SourceType == SectionSourceType.TinSurface)
    {
        surfaceId = sectionSource.SourceId;
        TinSurface sourceSurface = ts.GetObject(sectionSource.SourceId, OpenMode.ForRead) as TinSurface;
        _editor.WriteMessage("Adding TIN surface {0} to Section Sources for SampleLineGroup\n", sourceSurface.Name);
        sectionSource.IsSampled = true;
    }
}

Leave A Response »

You must be logged in to post a comment.