Author Topic: Hom to lenghten a pipe  (Read 2651 times)

0 Members and 1 Guest are viewing this topic.

Shibu

  • Guest
Hom to lenghten a pipe
« on: January 08, 2014, 03:48:29 PM »
Hi friends,
I want to lengthen a pipe which i inserted in a drawing by 10 inches from the start point. How can i do that.
Please help
Thank you

ChrisCarlson

  • Guest
Re: Hom to lenghten a pipe
« Reply #1 on: January 08, 2014, 04:29:26 PM »
Going to need more info, is it a 3d solid?

Why is this under the .NET?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Hom to lenghten a pipe
« Reply #2 on: January 08, 2014, 04:31:34 PM »
From a previous post
Quote
This is MEP 2014
Api - .NET
Win – 7-64 Bit

but, yes.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE3

  • Guest
Re: Hom to lenghten a pipe
« Reply #3 on: January 08, 2014, 04:40:47 PM »
in the little I did for mep (2009-2010) the Pipe class have a Length property.
Quote
Pipe pipe = tr.GetObject(id, OpenMode.ForRead, false) as Pipe;
...
if (pipe.Length > 1.0)

HTH

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Hom to lenghten a pipe
« Reply #4 on: January 09, 2014, 08:21:28 AM »
Just change the pipe.StartPoint or the pipe.EndPoint.  Is this a trick question?
Revit 2019, AMEP 2019 64bit Win 10

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Hom to lenghten a pipe
« Reply #5 on: January 09, 2014, 08:38:29 AM »
Here is a quick little example that will add 10" to the end of a pipe.  Please be aware that it will not maintain connection to the next pipe or fitting.
 
Code - C#: [Select]
  1.  
  2. namespace Example_Pipe_Project
  3. {
  4.     public class Class1
  5.     {
  6.         [CommandMethod("PipeLengthenExample", CommandFlags.UsePickSet | CommandFlags.Modal)]
  7.         public static void PipeLengthenExample()
  8.         {
  9.             Pipe pipe = null;
  10.             Editor editor = Application.DocumentManager.MdiActiveDocument.Editor;
  11.             var promptSelectOptions = new PromptSelectionOptions();
  12.             promptSelectOptions.MessageForAdding = "Select a Pipe Object:";
  13.             promptSelectOptions.SingleOnly = true;
  14.             PromptSelectionResult promptSelectionResult = editor.SelectByClass(promptSelectOptions, typeof(Pipe));
  15.             if (promptSelectionResult.Status == PromptStatus.OK && promptSelectionResult.Value.Count == 1)
  16.             {
  17.                 try
  18.                 {
  19.                     using (Transaction transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  20.                     {
  21.                         pipe = (Pipe)transaction.GetObject(promptSelectionResult.Value.GetObjectIds()[0], OpenMode.ForRead, false);
  22.                     }
  23.                     AddToLength(pipe);
  24.                     pipe.Dispose();
  25.                 }
  26.                 catch (System.Exception exception)
  27.                 {
  28.                     editor.WriteMessage(exception.Message);
  29.                 }
  30.             }
  31.             else
  32.             {
  33.                 editor.WriteMessage("\n\nIncorrect type or number of objects selected.");
  34.             }
  35.         }
  36.         private static void AddToLength(Pipe pipe)
  37.         {
  38.             using (Transaction transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  39.             {
  40.                 try
  41.                 {
  42.                     transaction.GetObject(pipe.ObjectId, OpenMode.ForWrite, false);
  43.                     pipe.Length = pipe.Length + 10;
  44.                     transaction.Commit();
  45.                 }
  46.                 catch (System.Exception exception)
  47.                 {
  48.                     Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(exception.Message);
  49.                 }
  50.             }
  51.         }
  52.     }
  53. }
  54.  

 
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Hom to lenghten a pipe
« Reply #6 on: January 09, 2014, 08:43:38 AM »
Just change the pipe.StartPoint or the pipe.EndPoint.  Is this a trick question?

I agree with MexicanCustard that this is probably the route to go but you will have to get the direction of the pipe (from connector 1 to connector 2) and using that direction calculate your new startpoint or endpoint.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

LE3

  • Guest
Re: Hom to lenghten a pipe
« Reply #7 on: January 09, 2014, 12:11:13 PM »
the way I read the OP message description was from my old days in acad production and using the command LENGTHEN but to get the pline length on the command line.....

this is something that happens on my current job doing code nowadays - where there is in many cases ZERO explanations or does not lead to anything, no sketches, no drawings, so it takes more time to decipher the task....

a better description to the problem will lead to better responses - instead of end up wasting time.

my 0.2