Message 1 of 3
Not applicable
07-18-2019
09:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.