TheSwamp

Code Red => .NET => Topic started by: Shibu on January 08, 2014, 03:48:29 PM

Title: Hom to lenghten a pipe
Post by: Shibu 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
Title: Re: Hom to lenghten a pipe
Post by: ChrisCarlson on January 08, 2014, 04:29:26 PM
Going to need more info, is it a 3d solid?

Why is this under the .NET?
Title: Re: Hom to lenghten a pipe
Post by: Kerry 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.
Title: Re: Hom to lenghten a pipe
Post by: LE3 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
Title: Re: Hom to lenghten a pipe
Post by: MexicanCustard on January 09, 2014, 08:21:28 AM
Just change the pipe.StartPoint or the pipe.EndPoint.  Is this a trick question?
Title: Re: Hom to lenghten a pipe
Post by: Keith Brown 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.  

 
Title: Re: Hom to lenghten a pipe
Post by: Keith Brown 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.
Title: Re: Hom to lenghten a pipe
Post by: LE3 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