Forgot password?

Create an account!

Forum

« back

General – scale with surfaceareacentroid

Messages

Please log in to write a message.

  • 3. ledisnomad (Jun 24, 2011 14.26):

    Oops, first line has defines arrObj then uses arrObjects, sorry.
    Also, this should be followed with

    If IsNull(arrObj) Then Exit Sub

    so if you hit escape you don't get an error message.

  • 2. ledisnomad (Jun 24, 2011 14.21):

    Two things:

    First, I ran your script on one hundred surfaces and it worked just fine, so I think we need more information about your model.

    Second, are you going to use all those arrays for something later in the script? I ask because if you aren't going to use the arrays later, you can simplify your script (which often helps with debugging):

    Call Main()
    Sub Main()
           
            Dim arrObj : arrObjects = Rhino.GetObjects("pick surfaces",8)
           
            Dim i,arrMP,strScaled,intValue
            For i=0 To Ubound(arrObj)
                    intValue = Rnd*100
                    arrMP = Rhino.SurfaceAreaCentroid(arrObj(i))
                    strScaled = Rhino.ScaleObject(arrObj(i), arrMP(0), Array(0.9,0.9,0.9), True)
                    Call Rhino.ObjectColor(strScaled, RGB(intValue, 100, intValue))
                   
            Next

    End Sub
  • 1. beckmann (Jun 23, 2011 23.00):

    hello,

    Ive got a question about scaling surfaces from surfaceareacentroid.
    In my model ive got hundred surfaces and each surface have to be scaled from the centroid with 0.9. When I select the surface the script will run till 20 surfaces and then a error will appear. How can I solve this?
    Besides the error, several surfaces will be deleted?

    Call Main()
    Sub Main()
           
            Dim arrobjects,arrcolor
            arrobjects=rhino.getObjects("pick surfaces",8)
            Dim i,arrmp(),arrscale(),value,cellarray()
           
            For i=0 To Ubound(arrobjects)
                    ReDim Preserve arrscale(i)
                    ReDim Preserve arrMp(i)
                    value= rnd*100
                    arrMP(i) = Rhino.SurfaceareaCentroid(arrobjects(i))
                   
                           
                    arrscale(i)=Rhino.ScaleObject (arrobjects(i), (arrMP(i)(0)), array(0.9,0.9,0.9),True )
                    arrcolor=Rhino.objectColor (arrscale(i), RGB(value,100,value))
                   
                           
            Next

    End Sub
    [\code]


    thank you
    maurice
Recommend

Why are these buttons gray?