Author Topic: Question: samples\entity\hilight_dg of SDK2009  (Read 3221 times)

0 Members and 1 Guest are viewing this topic.

ahlzl

  • Guest
Question: samples\entity\hilight_dg of SDK2009
« on: June 14, 2008, 05:41:02 AM »
if visualstyle is "2dWireframe" ,OK!
but isn't, Select edge might fail!

MickD

  • Gator
  • Posts: 3492
  • (x-in)->[process]->(y-out)
Re: Question: samples\entity\hilight_dg of SDK2009
« Reply #1 on: June 14, 2008, 09:14:29 PM »
Do you have a little more information for us ahlzl?

If I get want you mean, when 'picking' objects on the screen you are actually picking pixels which are traced back to their owners that draw them such as a line, edge or face. If it's not 2d wire frame (all lines/edges) it becomes very hard to determine an edge when the whole face is rendered as the edge is also rendered, if that makes sense.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

"First, solve the problem. Then, write the code." — John Johnson

ahlzl

  • Guest
Re: Question: samples\entity\hilight_dg of SDK2009
« Reply #2 on: June 14, 2008, 10:08:33 PM »
thank you, MickD .
but use AutoCAD command ——"solidedit", Select edge success 100% in any visualstyle !!!
How modify SDK's code?

thanks

MickD

  • Gator
  • Posts: 3492
  • (x-in)->[process]->(y-out)
Re: Question: samples\entity\hilight_dg of SDK2009
« Reply #3 on: June 14, 2008, 11:06:58 PM »
Ok, when using the acad command it highlights the edges yes? This allows you to be able to pick the isolated highlighted edge. In you code you need highlight the object, have a look at 'highlighting' in the help doc's, you may also need to catch the mouse over event or similar to imitate how autocad does this without actually picking an object.
Do you have any code so far we might be able to help you with?
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

"First, solve the problem. Then, write the code." — John Johnson

ahlzl

  • Guest
Re: Question: samples\entity\hilight_dg of SDK2009
« Reply #4 on: June 14, 2008, 11:45:32 PM »
thanks again !

I write C# code, also fail !
Code: [Select]
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

namespace ABC
{
    public class Class1
    {
        [CommandMethod("test")]
        public void MyTest()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                TypedValue value = new TypedValue((int)DxfCode.Start, "3DSOLID");
                TypedValue[] values = { value };
                SelectionFilter sfilter = new SelectionFilter(values);

                PromptSelectionOptions opt = new PromptSelectionOptions();
                opt.SingleOnly = true;
                PromptSelectionResult res = ed.GetSelection(opt, sfilter);

                if (res.Status != PromptStatus.OK)
                {
                    return;
                }
                SelectionSet ss = res.Value;
                ObjectId objId = ss[0].ObjectId;
                Solid3d ent = (Solid3d)trans.GetObject(objId, OpenMode.ForWrite);

                int marker = ss[0].GraphicsSystemMarker;
                Matrix3d xform = Matrix3d.Identity;
                Point3d pickPoint = new Point3d(0, 0, 0);
                FullSubentityPath[] pathes;
                try
                {
                    pathes = ent.GetSubentityPathsAtGraphicsMarker
                        (SubentityType.Edge, marker, pickPoint, xform, 0, null);
                }
                catch (System.Exception e)
                {
                    ed.WriteMessage("\n" + e.Message);
                    return;
                }

                ent.Highlight(pathes[0], false);
                ed.GetString("\nEnter...");
                ent.Unhighlight(pathes[0], false);

                Color myColor = Color.FromColorIndex(ColorMethod.ByColor, 1);
                SubentityId edgeId = pathes[0].SubentId;
                ent.SetSubentityColor(edgeId, myColor);
                trans.Commit();
            }
        }
    }
}

I declare fail, and wait  MickD、 Daniel、 other man  ……

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7096
  • AKA Daniel
Re: Question: samples\entity\hilight_dg of SDK2009
« Reply #5 on: June 15, 2008, 12:44:06 PM »
I tried your routine. It does seem like a bug.  You might post it at the Autodesk Discussion Groups to see if anyone has an alternative method. Sorry I couldn’t be of much help  :oops:
Retired

ahlzl

  • Guest
Re: Question: samples\entity\hilight_dg of SDK2009
« Reply #6 on: June 15, 2008, 07:39:10 PM »
:oops: