Hi,
In my workflow I quiet often have to change structure height when working.
Changing it with usual civil 3D process requires lots of clicks. So I was thinking of writing a command that I can sugarcoat later with wpf to make it easier.
But for now, the code I got is pretty basic and just a prototype.
[CommandMethod("ChangeRimToSumpHeight")] public void ChangeRimToSumpHeight() { CivilDocument doc = CivilApplication.ActiveDocument; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { ObjectId oNetworkId = doc.GetPipeNetworkIds()[0]; Network oNetwork = ts.GetObject(oNetworkId, OpenMode.ForWrite) as Network; ObjectId StructureId = oNetwork.GetStructureIds()[0]; Structure oStructure = ts.GetObject(StructureId, OpenMode.ForWrite) as Structure; PartDataField[] oDataFields = oStructure.PartData.GetAllDataFields(); ed.WriteMessage("Additional info for structure: {0}\n", oStructure.Name); double val = 1950; foreach (PartDataField oPartDataField in oDataFields) { if (oPartDataField.Name == "SRS") { ed.WriteMessage("Name: {0}, Units: {1}, ContextString: {2}, Description: {3}, DataType: {4}, Value: {5}\n", oPartDataField.Name, oPartDataField.Units, oPartDataField.ContextString, oPartDataField.Description, oPartDataField.DataType, oPartDataField.Value); oPartDataField.Value = val; } } ts.Commit(); } }
I understand PartDataField.Value is a 'get' and 'set'. But for some reason I cann't 'set' the value.
So, the code runs but the height does not change. Any thoughts? thanks.
Solved! Go to Solution.
Solved by tyronebk. Go to Solution.
Setting the RimToSumpHeight is actually simpler than what you are showing. Just set the structure's RimToSumpHeight property to the needed value.
oStructure.RimToSumpHeight = 1.95;
That said, you might have more control over the end result if you set the rim and/or sump values to the needed elevations:
oStructure.SumpElevation = oStructure.RimElevation - 1.95;
You may need to adjust the AutomaticRimSurfaceAdjustment and ControlSumpBy properties before changing values depending on your requirements.
Can't find what you're looking for? Ask the community or share your knowledge.