Author Topic: C#, Selection Set, Picked Point  (Read 7277 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
C#, Selection Set, Picked Point
« on: September 21, 2007, 05:19:05 PM »
Using this code:
Code: [Select]
        [CommandMethod("TestMe2")]
        public void test2()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptSelectionOptions selOpt = new PromptSelectionOptions();
            selOpt.MessageForAdding = "\nSelect Polyline: ";
            selOpt.PrepareOptionalDetails = true;
            selOpt.MessageForRemoval = "\nRemove Objects: ";
            PromptSelectionResult res = ed.GetSelection(selOpt);
            if (res.Status != PromptStatus.OK) return;
            SelectionSet mySS = res.Value;
            foreach (SelectedObject ssobj in mySS)
            {
                if (ssobj.SelectionMethod == SelectionMethod.PickPoint)
                {
                    SelectionDetails selDet = ssobj.OptionalDetails;
                }
            }
        }
and setting a breakpoint on the SelectionDetails line, this value is always null. What I'm trying to get at is the PickPoint when a user adds an object to the SS via a Pick. I can see the information I need is a part of the ssobj, but for the life of me I've been unable to find the correct Properties to access it.
Quote
+      ssobj   {(((2127690848),PickPoint,0,),(InfiniteLine,(1104.70934698555,786.126062074793,0),(0,0,1)))}   Autodesk.AutoCAD.EditorInput.SelectedObject {Autodesk.AutoCAD.EditorInput.PickPointSelectedObject}

Anyone care to enlighten me? :-) Thanks!
« Last Edit: September 21, 2007, 05:21:33 PM by Jeff_M »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: C#, Selection Set, Picked Point
« Reply #1 on: September 21, 2007, 05:45:12 PM »
Here is how I got it.
Code: [Select]
        [CommandMethod("TestMe2")]
        public void test2()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptSelectionOptions selOpt = new PromptSelectionOptions();
            selOpt.MessageForAdding = "\nSelect Polyline: ";
            selOpt.PrepareOptionalDetails = true;
            selOpt.MessageForRemoval = "\nRemove Objects: ";
            PromptSelectionResult res = ed.GetSelection(selOpt);
            if (res.Status != PromptStatus.OK) return;
            SelectionSet mySS = res.Value;
            foreach (SelectedObject ssobj in mySS)
            {
                if (ssobj.SelectionMethod == SelectionMethod.PickPoint)
                {
                    //SelectionDetails selDet = ssobj.OptionalDetails;
[color=yellow]                    PickPointSelectedObject ppsd = ssobj as PickPointSelectedObject;
                    PickPointDescriptor ppd = ppsd.PickPoint;
                    ed.WriteMessage(ppd.PointOnLine.ToString());[/color]
                }
            }
        }
Tim

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

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
Re: C#, Selection Set, Picked Point
« Reply #2 on: September 21, 2007, 05:54:14 PM »
Thanks, Tim. Don't know why I didn't try that, seems like I tried just about every other thing. :-/ For my use, this is all I need:
Code: [Select]
            foreach (SelectedObject ssobj in mySS)
            {
                if (ssobj.SelectionMethod == SelectionMethod.PickPoint)
                {
                    PickPointSelectedObject pickPtObj = ssobj as PickPointSelectedObject;
                    Point3d pickPt = pickPtObj.PickPoint.PointOnLine;
                    //do what I need here
                }
            }
Thanks for the enlightenment! :-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: C#, Selection Set, Picked Point
« Reply #3 on: September 21, 2007, 06:02:41 PM »
Thanks for the enlightenment! :-)

You're welcome.  Just trying to even out the stats for all the help you gave me on the Adesk Ng.
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: C#, Selection Set, Picked Point
« Reply #4 on: September 21, 2007, 06:37:54 PM »
Thanks Tim!  That answers a question I had, too.

I also didn't think of trying to cast the object to a PickedPointSelectedObject.  I assume that "PrepareOptionalDetails" part is important, too.

This .NET stuff is getting easier to work with, but it sure seems like there's a lot of these "tricks" involved...  How did you figure this one out?  Does it just take incredibly careful reading of the docs, or did someone tell you how, or was it simply blind perseverance and luck?   :lol:

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
Re: C#, Selection Set, Picked Point
« Reply #5 on: September 21, 2007, 06:59:58 PM »
I assume that "PrepareOptionalDetails" part is important, too.
Nope, tested without it and got the same result. I had added that in in one of my failed attempts to get to the picked point.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: C#, Selection Set, Picked Point
« Reply #6 on: September 21, 2007, 07:06:54 PM »
Thanks Tim!  That answers a question I had, too.

I also didn't think of trying to cast the object to a PickedPointSelectedObject.  I assume that "PrepareOptionalDetails" part is important, too.

This .NET stuff is getting easier to work with, but it sure seems like there's a lot of these "tricks" involved...  How did you figure this one out?  Does it just take incredibly careful reading of the docs, or did someone tell you how, or was it simply blind perseverance and luck?   :lol:
You're welcome.  How I figured out to cast it as a PickedPointSelectedObject was in the pic attached.
Tim

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

Please think about donating if this post helped you.