VS:GetHole: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 117: | Line 117: | ||
hasHole, outNumHoles = vs.GetNumHoles(inPolyline) | hasHole, outNumHoles = vs.GetNumHoles(inPolyline) | ||
if hasHole: | if hasHole: | ||
for inIndex in range(1,outNumHoles): | for inIndex in range(1,outNumHoles+1): | ||
hasOutHole, outHole = vs.GetHole(inPolyline, inIndex) | hasOutHole, outHole = vs.GetHole(inPolyline, inIndex) | ||
if hasOutHole: | if hasOutHole: | ||
for vertexNum in range(1, vs.GetVertNum(outHole)): | for vertexNum in range(1, vs.GetVertNum(outHole)+1): | ||
pnt, vertexType, arcRadius = vs.GetPolylineVertex(outHole, vertexNum) | |||
vs.MoveTo(pnt) | |||
vs.CreateText(str(inIndex) + "." + str(vertexNum)) | |||
labelHoleVertices() | labelHoleVertices() | ||
</code> | </code> |
Revision as of 19:09, 8 February 2023
.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+1): hasOutHole, outHole = vs.GetHole(inPolyline, inIndex) if hasOutHole: for vertexNum in range(1, vs.GetVertNum(outHole)+1): 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 Functions:
[[VS:GetNumHoles]]