I thought that finding the alignmentId, and using the code:
doc.GetAlignmentIds().Remove(delId);
would do it.
I know i have the right alignmentId, it all cheaks out, there must be something I have to do after removing from the ID collection.
I am doing a Tr.Commit(); but that does not seem to be good enough.
full code is: (_returnMsg is a local var for the class containing this method)
public void DelC3DHAlign(string name) { _returnMsg = "Error, No alignments available"; //access Civil 3D CivilDocument doc = CivilApplication.ActiveDocument; try { using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { ObjectId delId = ObjectId.Null; foreach (ObjectId alignId in doc.GetAlignmentIds()) { C3LD.Alignment alg = alignId.GetObject(OpenMode.ForRead) as C3LD.Alignment; if (name.ToUpper() == alg.Name.ToUpper()) delId = alignId; } if (delId != ObjectId.Null) doc.GetAlignmentIds().Remove(delId); tr.Commit(); _returnMsg = "Alignment deleted"; } } catch { _returnMsg = "Error, Alignment not deleted"; } }
thx
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
workie, good call!
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties