Change Pipe Network Structure height with .net

Change Pipe Network Structure height with .net

Anonymous
Not applicable
1,626 Views
2 Replies
Message 1 of 3

Change Pipe Network Structure height with .net

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
1,627 Views
2 Replies
Replies (2)
Message 2 of 3

tyronebk
Collaborator
Collaborator
Accepted 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.

0 Likes
Message 3 of 3

Anonymous
Not applicable

Wow. That's awesome and looks much easier. Have not tested it yet but looks good. Thanks for that. 

0 Likes