Mình xin chia sẻ 1 đoạn code tạo 1 tuyến đường mới từ 1 Polyline có sẵn trong Civil3D với ứng dụng API:
using(Transaction tr = db.TransactionManager.StartTransaction())
{
PromptEntityOptions _ent = new PromptEntityOptions(“\n- Chọn Polyline:”);
_ent.SetRejectMessage(“\n- Phải chọn Polyline:”);
_ent.AddAllowedClass(typeof(Polyline), false);
PromptEntityResult _ents = ed.GetEntity(_ent);
if (_ents.Status != PromptStatus.OK) return;
PolylineOptions _plop = new PolylineOptions();
_plop.AddCurvesBetweenTangents = true;
_plop.EraseExistingEntities = true;
_plop.PlineId = _ents.ObjectId;
// Thiết lập tên, nhãn, kiểu hiển thị trong Civil3D
ObjectId _alignment = Alignment.Create(_civil, _plop, “MyAlignment”, “”, “C-ROAD”, “Proposed”,”All Labels”);
// Cập nhập
tr.Commit();
}
F5 hoặc Start để khởi động Civil3D, sau đó vào Civil3D gõ lệnh NETLOAD chọn File .DLL, gõ lệnh TAOTUYENTUPOLYLINE, chọn Polyline:
Chúc các bạn thành công!
tôi đã sử dụng đoạn code nhưng khi thực hiện lệnh chọn polyline thì Civil báo lỗi