"Rebuild" can't run in loop

Hi,there

I am a newbee,I found a bug in rhinocommon maybe.
I just want to use “rebuild” command to reduce the number of points in 12 polylines.
when it runs,only the First polyline can be reduced.
the key codes are just like below.

for i=0 to 12
    docFile.Objects.Select(objidArray(i).Attributes.ObjectId)    'get the curve
    RhinoApp.RunScript("_-Rebuild p 200 _Enter", False) 
next

Is that a bug?Thank you for your help!

Kalvin

Although this may not be the cause of your problem, you still have a index problem in the code. You iterate 13 polylines although you say that they are only twelve (0…12 = 13 since the counter starts from zero)

// Rolf

Ah, Yes ,that’s a mistake,thanks! :wink:

Hi @hearts_j,

Since you are using Python and RhinoCommon, other approaches including calling call either rhinoscriptsyntax.RebuildCurve or Curve.Rebuild.

– Dale

As you said before,the rebuild command can’t handle curves that exceed 1000 points.
So I have to use the RhinoApp.RunScript.

Hi @hearts_j,

Just curious, why would any curve need over 1000 control points?

– Dale

Hi @dale,

I am using Rhino to slice the STL file and try to get the contours.
A complex STL model contains mass of meshes.

Kalvin

Hi @hearts_j,

Yes, contouring a large mesh can create polyline with lots of points. What is the end result of these polylines. That is, what are you going to do with the results? And again, we are talking about Rebuild. So I’m assuming you want to rebuild these contour curves with over 1000 points? How many points to the input curves have?

– Dale

Hi @dale,

Some polylines I got exceed 20000 points.I just want to reduce the points of the polylines to make the curves smooth.
After testing ,I think 200-500 points would be good for the result.
I use the “rebuild” or “simplyfycrv” command to do that.

Kalvin

Have you tried FitCrv or Rebuild?

Rebuild provides you with a preview of the to-bee curve so you can see what you will end up with at a certain number of control points, while FitCrv gives you the opportunity to preserve the original curve within a certain tolerance.

// Rolf

Hi,Ril

Yes ,I just followed your advise,It works.Thanks!
Because I have other things to do ,so I used curve.topolyline in the end.

Kalvin