Jump to content

Get Handle to closest Object

Recommended Posts

Starting with the location of one selected CustomObject I want to get a handle to another CustomObject which is close to this object and do something with that object. Imagine to a for instance a Pipe System where I bring to objects close to each other (via underlying grid). After they are positioned this way they should interact with their neighbour (change some RecordFields).

I thought GetClosestPt() would be the right approach but when I tested the example from the function refence I didn't get any reaction when I clicked (=GetPt()) near a simple rect. Also the Debugger shows that no objhandle is identified.

1) Does anybody know how to use this function correctly?

PROCEDURE GetClosestPtExample;


obj :HANDLE;

ptX, ptY :REAL;

index :INTEGER;

containedObj :LONGINT;



GetPt(ptX, ptY);

GetClosestPt(obj, ptX, ptY, index, containedObj);

SetPenFore(obj, 65535, 0, 0);



2) If this function doesn't work. Has anybody an alternative solution for my problem?

Link to comment

Try sending the parent object to the back first then select closest point. I have also been trying something similar to this but it gets tricky when both PIO's use the same code - therefore when one finds it's child object the child object becomes the parent and thus finds the original parent (confusing i know) what needs to be done in this case is somehow setting a flag on each object (like an invisible field) to say that it's been done. Please let me know if this helps, it might help my tool along.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...