Template:GetHolePolyline: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==== VectorScript ==== <code lang="pas"> PROCEDURE Example; VAR inPolyline :HANDLE; outNumHoles :INTEGER; inIndex :INTEGER; outHole :HANDLE; vertexNum :INTEGER; pX,...") |
(Fixed formatting and changed example to be a more useful function that people can just copy and run) |
||
Line 28: | Line 28: | ||
==== Python ==== | ==== Python ==== | ||
<code lang="py"> | <code lang="py"> | ||
def | #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() | |||
</code> | </code> |
Latest revision as of 19:03, 8 February 2023
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()