Author Topic: Civil 3d Pipe Slopes  (Read 2708 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Civil 3d Pipe Slopes
« on: August 21, 2015, 03:58:45 AM »
When I grab slopes from a civil 3d pipe it doesn't include the "-" sign.  The pipe is set at -2% but pipe.slope shows .0200000000

Anyone know a way to get the proper value? I'm trying to check the deflection angles between pipes, the negative is key.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Civil 3d Pipe Slopes
« Reply #1 on: August 21, 2015, 07:01:48 AM »
Usually we just either manually flip or rotate the pipe from the start structure to the end structure. Or you can use the change flow direction from the menu. Select the most upstream structure then then last structure of where you want it to go to.
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3d Pipe Slopes
« Reply #2 on: August 21, 2015, 11:53:53 AM »
Alien, how are you getting/using the Slope? I have code that relies on the sign and it works just fine. Can you show some code?

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Civil 3d Pipe Slopes
« Reply #3 on: August 23, 2015, 04:46:41 AM »
Thanks Jeff.  Here's the code I'm using. I need to see if there's greater than 1 degree vertical deflection in the pipes but if it can't tell if the slope of the pipe is actually going up or down in the profile it's not going to do me any good.

Code - C#: [Select]
  1.  ObjectId part1oid = BeProPrompts.promptForpropart("\nSelect First Pipe:");
  2.                         ObjectId part2oid = BeProPrompts.promptForpropart("\nSelect Second Pipe:");
  3.                         Autodesk.Civil.DatabaseServices.Entity ent1 = MyTrans.GetObject(part1oid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Entity;
  4.                         Autodesk.Civil.DatabaseServices.Entity ent2 = MyTrans.GetObject(part1oid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Entity;
  5.                         Pipe pipe1 = null;
  6.                         Pipe pipe2 = null;
  7.  
  8.                         if (ent1.GetType() == typeof(ProfileViewPart))
  9.                         {
  10.                             ProfileViewPart part = part1oid.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as ProfileViewPart;
  11.                             Autodesk.AutoCAD.DatabaseServices.Entity entity1 = part.ModelPartId.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
  12.                             if (entity1.GetType() == typeof(Pipe))
  13.                             {
  14.                                 pipe1 = (Pipe)entity1;
  15.                             }
  16.                         }
  17.  
  18.                         if (ent2.GetType() == typeof(ProfileViewPart))
  19.                         {
  20.                             ProfileViewPart part2 = part2oid.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as ProfileViewPart;
  21.                             Autodesk.AutoCAD.DatabaseServices.Entity entity2 = part2.ModelPartId.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
  22.                             if (entity2.GetType() == typeof(Pipe))
  23.                             {
  24.                                 pipe2 = (Pipe)entity2;
  25.  
  26.                             }
  27.                         }
  28.  
  29.                         double slope1 = pipe1.Slope;
  30.                         MyEditor.WriteMessage("\n" + slope1.ToString());
  31.                         double slope2 = pipe2.Slope;
  32.                         MyEditor.WriteMessage("\n" + slope2.ToString());

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3d Pipe Slopes
« Reply #4 on: August 23, 2015, 11:19:00 AM »
Weird, I had some code for testing something else with ProfileViewParts that I just slightly modified to get the pipe slopes. Note that I get signed slopes:
Quote from: Civil3D
Command: TESTPVPARTS
Select ProfileView:
Pipe "Pipe - (1)" Slope = -0.013787494012184
Pipe "Pipe - (2)" Slope = 0.05
Pipe "Pipe - (3)" Slope = 0.05
Pipe "Pipe - (4)" Slope = 0.0499999999999996
Pipe "Pipe - (5)" Slope = 0.0699999999999999
Pipe "Pipe - (6)" Slope = 0.00999999999999932
Pipe "Pipe - (7)" Slope = -0.0314089401043887
Pipe "Pipe - (8)" Slope = -0.0291432030576727
Pipe "Pipe - (9)" Slope = 0.00999999999999828
Here is the code:
Code - C#: [Select]
  1.         [CommandMethod("TestPVParts")]
  2.         public void testpvparts()
  3.         {
  4.             Document doc = Application.DocumentManager.MdiActiveDocument;
  5.             Editor ed = doc.Editor;
  6.             Database db = doc.Database;
  7.             PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect ProfileView:");
  8.             entOpts.SetRejectMessage("...not a profileview object, try again!");
  9.             entOpts.AddAllowedClass(typeof(ProfileView), true);
  10.             PromptEntityResult entRes = ed.GetEntity(entOpts);
  11.             if (entRes.Status != PromptStatus.OK)
  12.                 return;
  13.             using (Transaction tr = db.TransactionManager.StartTransaction())
  14.             {
  15.                 ProfileView pv = (ProfileView)entRes.ObjectId.GetObject(OpenMode.ForRead);
  16.                 ObjectId[] pvParts = pv.GetProfileViewPartIds();
  17.                 foreach (ObjectId id in pvParts)
  18.                 {
  19.                     ProfileViewPart pvpart = (ProfileViewPart)id.GetObject(OpenMode.ForRead);
  20.                     Pipe pipe = pvpart.ModelPartId.GetObject(OpenMode.ForRead) as Pipe;
  21.                     if (pipe == null)
  22.                         continue;
  23.                     ed.WriteMessage("\nPipe \"{0}\" Slope = {1}", pipe.Name, pipe.Slope.ToString());
  24.                 }
  25.                 tr.Commit();
  26.             }
  27.         }
  28.  

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Civil 3d Pipe Slopes
« Reply #5 on: August 23, 2015, 11:44:41 PM »
Thanks! Not sure what's going on. Think I'll check all the end-to-start deals and labels to make sure they are correct.

For a second note, is pv.GetProfileViewPartIds() something new to 15/16?

« Last Edit: August 23, 2015, 11:54:32 PM by Alien »

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Civil 3d Pipe Slopes
« Reply #7 on: August 24, 2015, 09:27:08 AM »
Oh, sorry about that! I'd forgotten about creating that extension method. BTW, the Slope property always reports the slope from start to end, regardless of what the flow direction is set to.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Civil 3d Pipe Slopes
« Reply #8 on: August 25, 2015, 02:59:05 AM »
Thanks Jeff! That was it. Had to flip the pipes.  Much appreciated.