VS:ForEachObjectAtPoint: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
No edit summary
m (fix faulty css)
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
If the callback function returns FALSE, ForEachObjectAtPoint will not process any more objects at the specified point.
If the callback function returns FALSE, ForEachObjectAtPoint will not process any more objects at the specified point.


{| class="wikitable_c"
{| class="wikitable"
|+ Table - ForEachObjectAtPoint Selectors
|+ Table - ForEachObjectAtPoint Selectors
! Option !! Selector !! Description
! Option !! Selector !! Description
Line 90: Line 90:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark>
([[User:Orso.b.schmid|Orso]], 2011 Oct. 06): This function only finds objects within the same parent, so it won't work from inside PIOs for finding something which is on drawing, nor does it work for finding objects on other layers, unregarded their visibility options.  
([[User:CBM-c-|_c_]], 2011 Oct. 06): This function only finds objects within the same parent, so it won't work from inside PIOs for finding something which is on drawing, nor does it work for finding objects on other layers, unregarded their visibility options.  


<b>NOTE</b> This function is very specific and have some problems:
<b>NOTE</b> This function is very specific and have some problems:
Line 105: Line 105:
PROCEDURE Example;
PROCEDURE Example;
VAR
VAR
gx1, gy1 : REAL;
gx1, gy1 : REAL;


FUNCTION DoIt(h1 :HANDLE) :BOOLEAN;
FUNCTION DoIt(h1 :HANDLE) :BOOLEAN;
BEGIN
BEGIN
DSelectAll;
DSelectAll;
SetSelect(h1);
SetSelect(h1);
Redraw;
Redraw;
Wait(1);
Wait(1);
END;
END;


BEGIN
BEGIN
GetPt(gx1, gy1);
GetPt(gx1, gy1);
ForEachObjectAtPoint(DoIt, 0, 0, gx1, gy1, 5);
ForEachObjectAtPoint(DoIt, 0, 0, gx1, gy1, 5);
END;
END;
RUN(Example);</code>
RUN(Example);</code>

Latest revision as of 13:09, 22 January 2021

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Performs an action for each object at the specified point in the drawing. This call was implemented to get past the practical limitations of PickObject, which only finds the topmost object. This call will find all of the objects at a given point.

"actionFunc" should actually be a function, not a procedure as the declaration indicates.

If the callback function returns FALSE, ForEachObjectAtPoint will not process any more objects at the specified point.

Table - ForEachObjectAtPoint Selectors
Option Selector Description
Object Options
All objects 0
Visible Objects only 1
Selected Objects only 2
Unlocked objects only 4
Traversal Options
Traverse Shallow 0
Traverse Groups 1 Traverse inside groups
PROCEDURE ForEachObjectAtPoint(
actionFunc :PROCEDURE;
objOptions :INTEGER;
travOptions :INTEGER;
locX,locY :REAL;
pickRadius :REAL);
def vs.ForEachObjectAtPoint(actionFunc, objOptions, travOptions, loc, pickRadius):
    return None

Parameters

actionFunc PROCEDURE
objOptions INTEGER
travOptions INTEGER
loc REAL
pickRadius REAL

Remarks

(_c_, 2011 Oct. 06): This function only finds objects within the same parent, so it won't work from inside PIOs for finding something which is on drawing, nor does it work for finding objects on other layers, unregarded their visibility options.

NOTE This function is very specific and have some problems:

  • doesn't go inside groups. The callback pointer is being set to NIL when going inside groups;
  • doesn't pick groups;

You can use VS:FindObjAtPt_Create, VS:FindObjAtPt_GetCount, or VS:FindObjAtPt_GetObj instead.

Example

PROCEDURE Example;
VAR
	gx1, gy1 : REAL;

FUNCTION DoIt(h1 :HANDLE) :BOOLEAN;
BEGIN
	DSelectAll;
	SetSelect(h1);
	Redraw;
	Wait(1);
END;

BEGIN
	GetPt(gx1, gy1);
	ForEachObjectAtPoint(DoIt, 0, 0, gx1, gy1, 5);
END;
RUN(Example);

Python:

import vs;

def DoIt(h1):
	vs.AlrtDialog( "we're in", h1 )

def PickPointCallback(pt):
	vs.ForEachObjectAtPoint(DoIt, 0, 0, pt[0], pt[1], 5)

vs.AlrtDialog( "show let you pick a point, and then show a dialog with the object's handle" )
vs.GetPt( PickPointCallback )

Version

Availability: from VectorWorks 13.0

See Also

VS Functions:

VS:PickObject | VS:GetPickObjectInfo | VS:FindObjAtPt_Create | VS:FindObjAtPt_GetCount | VS:FindObjAtPt_GetObj

VS Functions:

[[VS:PickObject]] | [[VS:GetPickObjectInfo]] | [[VS:FindObjAtPt_Create]] | [[VS:FindObjAtPt_GetCount]]

| [[VS:FindObjAtPt_GetObj]]