TheSwamp
Code Red => .NET => Topic started by: T.Willey on December 18, 2007, 03:05:27 PM
-
I don't know, and I haven't been able to find out, how to return a point so that it can be used in a command. How would I do that with a code like this
[CommandMethod("TestBi",CommandFlags.Transparent)]
public Point3d MyTestBi() {
Document Doc = acadApp.DocumentManager.MdiActiveDocument;
Editor Ed = Doc.Editor;
PromptPointResult ppr01 = Ed.GetPoint("Select first point: ");
PromptPointOptions ppo02 = new PromptPointOptions("Select second point: ");
ppo02.BasePoint = ppr01.Value;
PromptPointResult ppr02 = Ed.GetPoint(ppo02);
return new Point3d(
((ppr01.Value.X + ppr02.Value.X) / 2),
((ppr01.Value.Y + ppr02.Value.Y) / 2),
((ppr01.Value.Z + ppr02.Value.Z) / 2)
);
}
Thanks in advance.
-
I'm sure someone will come along with a MUCH better answer, but this seems to work
[LispFunction("TestBi")]
static public ResultBuffer TestBuf(ResultBuffer args)
{
ResultBuffer retBuf = new ResultBuffer();
Document Doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor Ed = Doc.Editor;
PromptPointResult ppr01 = Ed.GetPoint("Select first point: ");
PromptPointOptions ppo02 = new PromptPointOptions("Select second point: ");
ppo02.BasePoint = ppr01.Value;
PromptPointResult ppr02 = Ed.GetPoint(ppo02);
Point3d newPt = new Point3d(
((ppr01.Value.X + ppr02.Value.X) / 2),
((ppr01.Value.Y + ppr02.Value.Y) / 2),
((ppr01.Value.Z + ppr02.Value.Z) / 2)
);
retBuf.Add(new TypedValue((int)LispDataType.Point3d, newPt));
return retBuf;
}
Rather than entering 'Testbi like a transparent command, one enters (testbi) like a LISP function. I haven't played with transparent functions at all, but they are now on my list :)
-
Rather than entering 'Testbi like a transparent command, one enters (testbi) like a LISP function. I haven't played with transparent functions at all, but they are now on my list :)
change
[lispFunction("TestBi")]
to
[lispFunction("C:TestBi")]
and it can then be used like a transparent command :-)
-
Cool, it works.
Thanks Jeff :)
-
FWIW, in one of the few posts I could find regarding this, Tony T. suggested using the lispFunction in lieu of the Transparent flag.
-
I have lisp functions already that do this, but I wanted something that can be used in the middle of a lisp, so that is why I'm trying to go this route. I saw one by Tony T. on the Adesk Ng, but was hoping to get this style working. I will see if I can get something tomorrow at work.
Thanks for trying.
-
Anyone know how to return TWO points in this manner?
For example, if the LINE command is running, and I run my transparent command, I would like the transparent command to return the next TWO points for the LINE command.
I tried something like this:
[LispFunction("C:TEST")]
public static ResultBuffer TestCommand(ResultBuffer args)
{
return new ResultBuffer(
new TypedValue((int)LispDataType.Point2d, new Point2d(500,500)),
new TypedValue((int)LispDataType.Point2d, new Point2d(1000,1000))
);
}
I was hoping that I could then start the line command, and type 'TEST at the prompt, and I would get a line drawn from (500,500) to (1000,1000), and I would be left at the prompt for me to pick the next point for the LINE command.
Instead, I start the LINE command and type 'TEST, and it's as if I picked only the point (500,500).
What seems to be happening is that the 'TEST transparent function is returning a list containing two points. Then the LINE command is using the first point in the list, and ignoring the second point.