Author Topic: Return point, with CommandFlags.Transparent  (Read 2686 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Return point, with CommandFlags.Transparent
« 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
Code: [Select]
[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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

SomeCallMeDave

  • Guest
Re: Return point, with CommandFlags.Transparent
« Reply #1 on: December 18, 2007, 08:00:00 PM »
I'm sure someone will come along with a MUCH better answer, but this seems to work

Code: [Select]
        [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  :)

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Return point, with CommandFlags.Transparent
« Reply #2 on: December 18, 2007, 08:12:37 PM »
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 :-)

SomeCallMeDave

  • Guest
Re: Return point, with CommandFlags.Transparent
« Reply #3 on: December 18, 2007, 08:18:47 PM »
Cool, it works.

Thanks Jeff  :)

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Return point, with CommandFlags.Transparent
« Reply #4 on: December 18, 2007, 08:23:44 PM »
FWIW, in one of the few posts I could find regarding this, Tony T. suggested using the lispFunction in lieu of the Transparent flag.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Return point, with CommandFlags.Transparent
« Reply #5 on: December 18, 2007, 08:40:13 PM »
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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

sinc

  • Guest
Re: Return point, with CommandFlags.Transparent
« Reply #6 on: May 19, 2009, 08:24:37 PM »
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:

Code: [Select]
        [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.