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

Help: Strange super slow scripting of make 2D python bug

$
0
0

Hi @pascal and @Helvetosaur

I am working on some 2D tools (this is a small part that cleans up the data) and encountered a strange bug.

Making 2D of this tree takes in top view takes 4 seconds, and sorting the lines and deleting the short and joining the long lines takes an instant. BUT doing it together takes a loooong time… why?

Try this:

  • Make 2D of the tree and run this script.

  • Then remove the # and then select the block and run it again. See how slow it is? I have not been able to figure out why make2D in python causes this odd slow down.

import rhinoscriptsyntax as rs

#rs.Command("_-Make2D Layout=CPlane Properties=ByOutputLayers CreateHiddenLines=No ShowTangents=No CreateSceneSilhouette=No CreateClippingPlaneIntersections=No ShowViewRectangle=No GroupOutput=No Enter", False)

lines = rs.SelectedObjects()
shortLines = []
longLines = []
for line in lines:
    if rs.CurveLength(line)<0.1:
        shortLines.append(line)
    else:
        longLines.append(line)
rs.DeleteObjects(shortLines)
if len(longLines)>0:
    result = rs.JoinCurves(longLines, delete_input=False)
    rs.SelectObjects(result)

Tree.3dm (1.0 MB)

3 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles