A Poor Man’s Line Jig (well, there’s actually no jigging here) – (AutoCAD .net API)

 

What are these guys doing, you ask? I suspect that they are jigging a line. They are probably doing it this way because they didn't read the ObjectARX documentation. Well actually, you don't need to. Just use the poor man's jig.
What are these guys doing, you ask? I suspect that they are jigging a line. They are probably doing it this way because they didn’t read the ObjectARX documentation. Well actually, you don’t need to. Just use the poor man’s jig.

 

I wanted to implement a jig for drawing a Line – but strictly speaking I didn’t want the line itself – I wanted its two points, yet I wanted all the features that come with jigging: snaps, polar tracking, and a nice line leading from the base point to the cursor, which shows you where you were, and where you are going. I was originally going to jig it all myself – and all of this to obtain two coordinates in a manner that would allow the user to see what was actually going on. Jiggig takes a lot of effort. It was only then that I realised I could get the same result, but with a massive short cut:

Here is a poor man’s Line Jig – at the end of it, you’ll have the two points you are after, but without the effort. If required, you can encapsulate all the logic in it’s own class, so that the client doesn’t have to bother too much with the implementation details.

Poor man’s line jig.

 

        [CommandMethod(“GetPoints”)]

public static void GetPoints()

{

Document doc = Application.DocumentManager.MdiActiveDocument;

Database db = doc.Database;

Editor ed = doc.Editor;

 

PromptPointResult pprOrigin = ed.GetPoint(“Click for point.”);

 

if (pprOrigin.Status == PromptStatus.OK)

{

PromptPointOptions promptPointOptions = new PromptPointOptions(“Please get secondPoint”);

promptPointOptions.UseBasePoint = true;

promptPointOptions.BasePoint = pprOrigin.Value; ;

 

PromptPointResult ppr = ed.GetPoint(promptPointOptions);

 

if (ppr.Status == PromptStatus.OK)

{

ed.WriteMessage(“Congrats!”);

}

}

}

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *