VS:GetHole

From Vectorworks Developer
Revision as of 14:32, 12 August 2013 by Root (talk | contribs) (1 revision)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

.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

#Labels each vertex of a selected polyline's holes with their hole index and vertex index
def labelHoleVertices():
    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)
                vs.Moveto(pnt)
                vs.CreateText(str(inIndex) + "." + str(vertexNum))
labelHoleVertices()

Version

Availability: from VectorWorks9.0

See Also

VS Functions:

VS:GetNumHoles

VS Functions: [[VS:GetNumHoles]]