VS:ConvertToArcPolyline: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
(add comment: this doesn't preserve existing rad and arc vertexes, the bloody thing!)
(add examples, comment, fails on rad vertex)
Line 36: Line 36:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark>
([[User:CBM-c-|_c_]], 2022.02.02) Applied to polylines with mixed vertex types, this won't preserve existing arc vertexes: it only turns into arc beziers and cubic vertexes. Radius and arc vertexes will turn into corner!
([[User:CBM-c-|_c_]], 2022.02.02) This routine must be updated, it still doesn't recognise Radius vertexes (introduced after this routine). As of VW 2022 it behaves on vertexes:
* corner: preserved
* arc: preserved only on dFuzz = 0, otherwise it turns into corner
* radius: ignored, turn into corner
* cubic: turn into arc
* bezier: turn into arc
</remark>
</remark>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample></sample>
<sample>
==== VectorScript ====
<code lang="pas">
PROCEDURE Test;
VAR
polyObj, newPolyObj : HANDLE;
BEGIN
    { select a polyline }
    polyObj := FSActLayer;
    IF polyObj <> NIL THEN BEGIN
        newPolyObj := ConvertToArcPolyline(polyObj, 0);
        SetDSelect(polyObj);
    END;
END;
Run(Test);
</code>
 
==== Python ====
<code lang="py">
# select a polyline
polyObj = vs.FSActLayer()
if polyObj != vs.Handle( 0 ):
newPolyObj = vs.ConvertToArcPolyline(polyObj, 0)
vs.SetDSelect(polyObj)
</code></sample>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------

Revision as of 03:46, 3 February 2022

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

Description

Convert, within a tolerance, the input polyline into an polyline that uses arcs for the curves.

FUNCTION ConvertToArcPolyline(
hPolygon :HANDLE;
dFuzz :REAL) : HANDLE;
def vs.ConvertToArcPolyline(hPolygon, dFuzz):
    return HANDLE

Parameters

hPolygon HANDLE
dFuzz REAL

Remarks

(_c_, 2022.02.02) This routine must be updated, it still doesn't recognise Radius vertexes (introduced after this routine). As of VW 2022 it behaves on vertexes:

  • corner: preserved
  • arc: preserved only on dFuzz = 0, otherwise it turns into corner
  • radius: ignored, turn into corner
  • cubic: turn into arc
  • bezier: turn into arc

Example

VectorScript

PROCEDURE Test;
VAR
	polyObj, newPolyObj : HANDLE;
	
BEGIN
    { select a polyline }
    polyObj := FSActLayer;
    IF polyObj <> NIL THEN BEGIN
        newPolyObj := ConvertToArcPolyline(polyObj, 0);
        SetDSelect(polyObj);
    END;
END;
Run(Test);

Python

# select a polyline
polyObj = vs.FSActLayer()
if polyObj != vs.Handle( 0 ):
	newPolyObj = vs.ConvertToArcPolyline(polyObj, 0)
	vs.SetDSelect(polyObj)

Version

Availability: from Vectorworks 2014