Author Topic: Unable to get a value when using SelectWindow method  (Read 4063 times)

0 Members and 1 Guest are viewing this topic.

Proctor

  • Guest
Unable to get a value when using SelectWindow method
« on: May 11, 2009, 02:47:38 PM »
Hello: I'm trying to create a filter that looks at the upper and lower corners of a line just created by using the SelectWindow method in order to then see if there are any overlapping lines that reside close to this newly created one.

If i place this code into a separate command that i call after first running another command that first creates the line, it works perfect; however, i want to place the code into the same
command that creates the line. the problem is that, it get's nothing for the resw.value.

I can include the entire sub, but it's very long and I was first hoping someone might be able to see
something obvious that I'm doing w/ this portion of it - if not, I'll work to shorten my routine:

<code>

btr.AppendEntity(curLine)
tr.AddNewlyCreatedDBObject(curLine, True)

Dim resW As PromptSelectionResult = doc.Editor.SelectWindow(curLine.GeometricExtents.MinPoint, curLine.GeometricExtents.MaxPoint)

If Not IsNothing(resW.Value) Then
            'won't go in here
   Debug.print("went here")
end if
</code>


it seems it wants me to commit and also dispose of the transaction before it will work. i say that be
cause i tried to commit the transation but that didn't help. it's only after the End Using statment that i can then get a value.

thanks for your help,
Proctor

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Unable to get a value when using SelectWindow method
« Reply #1 on: May 11, 2009, 05:32:31 PM »
Yes, the transaction has to be completed before you can pick an entity like that, until the tranaction is complete it will not become a db resident. That's the idea behind the transaction, if it fails the db is restored to its state before the beginning of the tranasaction.

Another thing to ponder, if the line ep/sp is 'on' the boundary of the 'select' window it may think it isn't completely within the window(?) whereas a crossing window would pick it up.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Proctor

  • Guest
Re: Unable to get a value when using SelectWindow method
« Reply #2 on: May 11, 2009, 05:47:46 PM »
MickD: I can't tell you what a relief it is to have someone explain this to me. I wasn't sure if it was a
cad bug...or something I was doing wrong. I was spending way to much time on it....thank you very much for taking the time to let me know.

It seems that i will have to complete drawing my lines and the transaction and after look for overlapping lines.

Could you please tell me more about crossing window? is this another selection filter? Before attempting to use the selectWindow method, i was looping through a collection of lines drawn - and this was taking way to long to run.

thanks again for your help.
Proctor

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Unable to get a value when using SelectWindow method
« Reply #3 on: May 11, 2009, 06:13:05 PM »
It's the same as with normal use, you would use a select window to select only the object within the window and a crossing window to select object bot within and crossing the window box edges.

I'm not sure there is a selectCrossing method, either way they both iterate through the drawing to see which ones cross or are within the window the same as you are with using a collection. The speed difference may be due to the clr but it may also be your approach/algorithm.

If you are comparing bounding boxes of lines for intersections that will take too long, use the geometry lib or the line.IntersectsWith methods which will be run natively. I'm not sure that's the name of the method but the point is to use as high a level method as possible, something where you pass it one or both lines and checks for an intersection, trying to calc it in .net will be slower than the optimised native code as every time you get a member variable you have to deal with mashaling wrap/unwrappping etc.
hth
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Unable to get a value when using SelectWindow method
« Reply #4 on: May 11, 2009, 06:15:26 PM »
If speed is a real issue still, you could write a managed arx which you just pass an objectid collection to which does all the grunt work in native code...just a thought.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Proctor

  • Guest
Re: Unable to get a value when using SelectWindow method
« Reply #5 on: May 11, 2009, 06:34:00 PM »
MickD:

yeah, the issue is about speed. When i was looping through the collection of lines, it took
a long time because for each object the user selects, there could be hundreds of lines to itterate through for each line to see if it overlaps.

i wasn't aware that the selectWindow method still had to loop through each drawing in the db, but that makes sense. maybe it's not the solution therefore.

An overlapping line could be one that intersects - but it could also be one that's parallel or even directly on top. It's any line that's not connected to the line and runs closely along side of it. Because of this, i don't think i could use the IntersectsWith method.

I wish I was at a level where I felt confident writing a managed arx because that sounds like a great idea, but I've never done anything like that and I don't know how to go about it. do you know any documentation on it so I can learn?

Thanks again,

Proctor

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Unable to get a value when using SelectWindow method
« Reply #6 on: May 11, 2009, 07:05:41 PM »
There's not a great deal out there, if you know your geometry you should be able to find the methods you need as the arx geo lib is very good. For parallel lines there is a collinearTo method or similar, for whatever you need there is a method to help ;)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Proctor

  • Guest
Re: Unable to get a value when using SelectWindow method
« Reply #7 on: May 12, 2009, 01:41:38 PM »
MickD: you gave me an idea to test if my original overlap algorithm itself was making it take long verses looping through all the lines...and as it turns out, it's the algorithm. I've now decided to go back and revisit this algorithm....

and I have used the geo class before - but I have a question: you mentioned looking at the arx geo lib ...where is this library? it would be great to know what methods are available to me. for example, i did a search off google for .net autocad collinearTo, but was unable to find anything on it.

thanks,
proctor

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: Unable to get a value when using SelectWindow method
« Reply #8 on: May 12, 2009, 05:34:23 PM »
public bool IsColinearTo(LinearEntity3d line, Tolerance tolerance);
 
Declaring Type: Autodesk.AutoCAD.Geometry.LinearEntity3d
Assembly: acdbmgd, Version=17.0.209.0

[Wrapper("AcGeLinearEnt3d")]
public abstract class LinearEntity3d : Curve3d
{
    // Methods
    internal protected LinearEntity3d(IntPtr unmanagedPointer, [MarshalAs(UnmanagedType.U1)] bool autoDelete);
    public void {dtor}();
    public static LinearEntity3d Create(IntPtr unmanagedPointer, [MarshalAs(UnmanagedType.U1)] bool autoDelete);
    internal unsafe AcGeLinearEnt3d* GetImpObj();
    public Line3d GetLine();
    public Plane GetPerpendicularPlane(Point3d intersectionPoint);
    public Point3d[] IntersectWith(LinearEntity3d line);
    public Point3d[] IntersectWith(PlanarEntity plane);
    public Point3d[] IntersectWith(LinearEntity3d line, Tolerance tolerance);
    public Point3d[] IntersectWith(PlanarEntity plane, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsColinearTo(LinearEntity3d line);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsColinearTo(LinearEntity3d line, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(Plane plane);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(Plane plane, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsParallelTo(LinearEntity3d line);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsParallelTo(PlanarEntity plane);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsParallelTo(LinearEntity3d line, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsParallelTo(PlanarEntity plane, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsPerpendicularTo(LinearEntity3d line);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsPerpendicularTo(PlanarEntity plane);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsPerpendicularTo(LinearEntity3d line, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsPerpendicularTo(PlanarEntity plane, Tolerance tolerance);
    public LinearEntity3d Overlap(LinearEntity3d line);
    public LinearEntity3d Overlap(LinearEntity3d line, Tolerance tolerance);
    public Point3d[] ProjectedIntersectWith(LinearEntity3d line, Vector3d projectionDirection);
    public Point3d[] ProjectedIntersectWith(LinearEntity3d line, Vector3d projectionDirection, Tolerance tolerance);

    // Properties
    public Vector3d Direction { get; }
    public Point3d PointOnLine { get; }
}

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Proctor

  • Guest
Re: Unable to get a value when using SelectWindow method
« Reply #9 on: May 12, 2009, 06:01:23 PM »
kdub@wdt: Hello....thanks for your reply. Can you please explain this more to me? I apologise, but I'm confused and would like to understand.
what does [Wrapper("AcGeLinearEnt3d")] mean? i hear people say the word wrapper, but I don't understand.
Also, I see each method has return values (e.g. [return: MarshalAs(UnmanagedType.U1)]. what kind of return values are these?

Thanks again,
Proctor

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Unable to get a value when using SelectWindow method
« Reply #10 on: May 12, 2009, 06:07:02 PM »
What Kerry has there is a reflection dump (Is that it??) which is showing what methods are available for the LinearEntity3d class. the 'wrapper' attribute means it wraps the AcGeLinearEnt3d ObjectARX class which is written in C++.

As a Line derives from this class these methods are available for you to use, have a look through the object browser to see the methods and descriptions of each available.

It's slow going I know but it's the best way to become familiar with this stuff.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Proctor

  • Guest
Re: Unable to get a value when using SelectWindow method
« Reply #11 on: May 12, 2009, 06:15:45 PM »
that makes sense...thanks for explaining. yes too...it's slow going. i'm the only programmer at my work and i
am having to learn myself which is why i value forums like this to help me.

thanks again for your help and support.

Proctor

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: Unable to get a value when using SelectWindow method
« Reply #12 on: May 12, 2009, 06:18:26 PM »

Yes, as Mick mentioned .. the Object Browser from Visual Studio ( or any IDE)  is a good way to become familiar with the Methods and Properties.


Regards
Kerry
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Proctor

  • Guest
Re: Unable to get a value when using SelectWindow method
« Reply #13 on: May 12, 2009, 06:21:53 PM »
thanks for the pointers. I truly appreciate it.