VS:GetHole

From Vectorworks Developer
Jump to: navigation, search

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

Description

Returns a handle to a polyline defining an opening within the referenced polyline.

The definition polyline can be edited or queried using the standard VectorScript polyline API functions.

FUNCTION GetHole(
inOutsidePolyline  :HANDLE;
inIndex  :INTEGER;
VAR outHole  :HANDLE) : BOOLEAN;
def vs.GetHole(inOutsidePolyline, inIndex):
    return (BOOLEAN, outHole)

Parameters

inOutsidePolyline HANDLE Handle to polyline.
inIndex INTEGER Index number of opening definition polyline.
outHole HANDLE Handle to definition polyline.

Return Value

Returns TRUE if the polyline contains openings, otherwise returns FALSE.

Remarks

It is quite fascinating to observe that the parent of a hole has object type "0". Polyline holes reside in Nirvana, so to say....

One would expect their parent to be the polyline container.

PROCEDURE xxxxx;
VAR
temp_i	: INTEGER;
temp_h	: HANDLE;
prefBoo : BOOLEAN;

BEGIN
prefBoo := GetPref(21); { store preference "Stop Vectorscript on warning" }

{ FSActLayer should be a polyline with holes }
IF GetNumHoles(FSActlayer, temp_i) THEN BEGIN
AlrtDialog(concat('HOLES: ', temp_i));

IF GetHole(FSActlayer, temp_i, temp_h) THEN BEGIN
SetPref(21, TRUE); { activate "Stop Vectorscript on warning" }

AlrtDialog(concat('TYPE: ', getType(temp_h)));
AlrtDialog(concat(''TYPE OF PARENT: ', getType(GetParent(temp_h))));
{ this raises a "Handle is NIL" warning }
END ELSE
SysBeep;

SetPref(21, prefBoo); { restore user's "Stop Vectorscript on warning" }
END;
END;

RUN(xxxxx);

Example

VectorScript

PROCEDURE Example;
VAR
inPolyline  :HANDLE;
outNumHoles :INTEGER;
inIndex     :INTEGER;
outHole     :HANDLE;
vertexNum   :INTEGER;
pX, pY      :REAL;
vertexType  :INTEGER;
arcRadius   :REAL;
BEGIN
inPolyline := FSActLayer;
IF GetNumHoles(inPolyline, outNumHoles) THEN BEGIN
FOR inIndex := 1 TO outNumHoles DO BEGIN
IF GetHole(inPolyline, inIndex, outHole) THEN BEGIN
FOR vertexNum := 1 TO GetVertNum(outHole) DO BEGIN
GetPolylineVertex(outHole, vertexNum, pX, pY, vertexType, arcRadius);
WriteLn('pX: ', pX, ' pY: ', pY);
END;
END;
END;
END;
END;
RUN(Example);

Python

def Example():
	inPolyline = vs.FSActLayer()
	hasHole, outNumHoles = vs.GetNumHoles(inPolyline)
	if hasHole:
		for inIndex in range(1,outNumHoles):
			hasOutHole, outHole = vs.GetHole(inPolyline, inIndex)
			if hasOutHole:
				for vertexNum in range(1, vs.GetVertNum(outHole)):
					pnt, vertexType, arcRadius = vs.GetPolylineVertex(outHole, vertexNum)					
Example()

Version

Availability: from VectorWorks9.0

See Also

VS Functions:

VS:GetNumHoles

VS Functions: [[VS:GetNumHoles]]
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox