Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Pipe Network Structure height with .net

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
1149 Views, 2 Replies

Change Pipe Network Structure height with .net

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.

2 REPLIES 2
Message 2 of 3
tyronebk
in reply to: Anonymous

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.

Message 3 of 3
Anonymous
in reply to: tyronebk

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report