VS:PickObject

From Vectorworks Developer
Revision as of 09:35, 12 August 2013 by Root (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

Description

Function PickObject returns a handle to an object in the document. The function receives a coordinate location, specified by parameter p, and checks this location for the presence of an object. If an object exists at the location, the function returns a handle to the object.
FUNCTION PickObject(
pX,pY  :REAL) : HANDLE;
def vs.PickObject(p):
    return HANDLE

Parameters

p REAL Coordinate location to test for object.

Remarks

Only picks objects on the active class & layer, or on other classes/layers if the class/layer options are set to Show/Snap/Modify (respectively). Essentially, it will only pick an object that you could have picked manually with the Selection Tool. Same goes for the GetPickObjectInfo function.

PickObject & HCenter (when used together?) are less likely to produce incorrect results if you zoom in first.

Example

VectorScript

{ example from unknown author on Vectorlab, Dec 2006 }
PROCEDURE IsolateLayer; {sets selected object's layer to active and greys all others}
VAR
    x, y: REAL;
    h, layHand: HANDLE;
    layName: STRING;
BEGIN
    GetPt(x, y);
    h := PickObject(x, y);

    IF h <> NIL THEN BEGIN
        SetSelect(h);
        layHand := GetLayer(h);
        layName := GetLName(layHand);
        Layer(layName);
        SetLayerOptions(2);

        SetDSelect(h);
    END;
END;
RUN(IsolateLayer);

Python


def PickPointCallback(pt):
	h = vs.PickObject(pt[0], pt[1])
	if h != None:
		vs.SetSelect(h)
		layHand = vs.GetLayer(h)
		layName = vs.GetLName(layHand)
		vs.Layer(layName)
		vs.SetLayerOptions(2)
		vs.SetDSelect(h)
    
	

def IsolateLayer(): #{sets selected object's layer to active and greys all others}
    vs.GetPt( PickPointCallback )
    
IsolateLayer()

Version

Availability: from All Versions

See Also

VS Functions:

VS:GetPickObjectInfo | VS:ForEachObjectAtPoint

VS Functions:

[[VS:GetPickObjectInfo]]

| [[VS:ForEachObjectAtPoint]]
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox