Author Topic: Use WPF dialog button to draw a line  (Read 8652 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Use WPF dialog button to draw a line
« Reply #30 on: May 21, 2015, 12:58:24 AM »
Thank you MickD for your reply .

After picking the first point the rubber band goes to 0,0,0 and did not start from first point  :-( can you check this out again please ?

I have no idea why, it should work if you picked pt1 in the first part of the method, that point is set as the base point for the rubber band. Does your code look like this?
Code - C#: [Select]
  1. internal static void DrawLine()
  2.         {
  3.             Document doc = AcAp.DocumentManager.MdiActiveDocument;
  4.             Database db = doc.Database;
  5.  
  6.             PromptPointOptions p1 = new PromptPointOptions("Specify base point :");
  7.             PromptPointResult rep1;
  8.             rep1 = doc.Editor.GetPoint(p1);
  9.             Point3d pt1 = rep1.Value; // ******* this point gets used as the base point in the next part
  10.             if (rep1.Status == PromptStatus.Cancel) return;
  11.  
  12.             PromptPointOptions p2 = new PromptPointOptions("Next point :");
  13.             p2.UseBasePoint = true; // ******* yes, I want to use a rubber band
  14.             p2.BasePoint = pt1; // ******* use this point as the base point for the rubber band line
  15.             PromptPointResult rep2;
  16.             rep2 = doc.Editor.GetPoint(p2);
  17.             Point3d pt2 = rep2.Value;
  18.             if (rep2.Status == PromptStatus.Cancel) return;
  19.  
  20.             using (Transaction tr = db.TransactionManager.StartTransaction())
  21.             {
  22.                 var mSpace = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
  23.                 var line = new Line(pt1, pt2);
  24.                 line.ColorIndex = 6;
  25.  
  26.                 mSpace.AppendEntity(line);
  27.                 tr.AddNewlyCreatedDBObject(line, true);
  28.                 tr.Commit();
  29.             }
  30.         }
  31.  
« Last Edit: May 21, 2015, 01:04:40 AM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Coder

  • Swamp Rat
  • Posts: 827
Re: Use WPF dialog button to draw a line
« Reply #31 on: May 21, 2015, 01:08:12 AM »

I have no idea why, it should work if you picked pt1 in the first part of the method, that point is set as the base point for the rubber band. Does your code look like this?

Yes the same . and I replaced your modified codes with my current codes and it gives the same result . :-o

Coder

  • Swamp Rat
  • Posts: 827
Re: Use WPF dialog button to draw a line
« Reply #32 on: May 21, 2015, 01:13:03 AM »
Sorry I replied before you modified the codes .

Now it works  :-) thank you .

What was the problem in the first codes according to this last modified codes ?

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Use WPF dialog button to draw a line
« Reply #33 on: May 21, 2015, 01:16:58 AM »
Without looking at your code I have no idea and if you have a look they are exactly the same lines of code I posted earlier, I just put them in the method listed in the post above.

You really need to study what you did and work it out, it was probably something simple, it always is. If you don't find the problem you'll never know :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Coder

  • Swamp Rat
  • Posts: 827
Re: Use WPF dialog button to draw a line
« Reply #34 on: May 21, 2015, 09:22:44 AM »
Thank you MickD for your help and advice .