Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Bug in Common? Project curve to plane adds points

$
0
0

Hi guys,
please take a look at this. I am altering curve editpoints and need to make a 2d version of the curve and then locate that versions editpoints, but if I coerce the curve (some curves only!) and project it to a plane and add that curve to the document then the new one has more editpoints. (Straight sections (degree 1) become degree2 as well)

The easiest is just to test this code on this file:
curve project more points.3dm (804.1 KB)

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

curve_id = rs.GetObject("select curve", rs.filter.curve, preselect=True)
if curve_id:
    curve=rs.coercecurve(curve_id)
    plane=rs.WorldXYPlane()
    curve2d = Rhino.Geometry.Curve.ProjectToPlane(curve,plane)
    curve2d_id = sc.doc.Objects.AddCurve(curve2d)
    
    rs.SelectObject(curve2d_id)
    rs.SelectObject(curve_id)
    rs.Command("_EditPtOn")

This is the workaround I made to fix this issue:

    # --- workaround ---
    curveelements = rs.ExplodeCurves(curve_id)
    plane=rs.WorldXYPlane()
    curve2ds = []
    for element in curveelements:
        curve = rs.coercecurve(element)
        curve2ds.append( Rhino.Geometry.Curve.ProjectToPlane(curve,plane))
    curve2d = Rhino.Geometry.Curve.JoinCurves(curve2ds)[0]
    curve2d_id = sc.doc.Objects.AddCurve(curve2d)
    rs.DeleteObjects(curveelements)
    rs.SelectObject(curve2d_id)
    # --- workaround ---

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles