Forgot password?

Create an account!

Forum

« back

RhinoScript – Circle Scaling

Messages

Please log in to write a message.

  • 4. ledisnomad (Jul 01, 2011 15.10):

    So, I think you're making it more complicated than necessary again. You don't have to create the surfaces to find the area. And then in this case, there is a great method to find the area of all the curves in an array: CurveArea. I searched "area" in the Monkey script editor to find all the methods that calculate area, then worked backwards from there. This one made the most sense. Hope this helps!

           Dim arrCircles: arrCircles = Rhino.GetObjects("Get circles",4)
            If IsNull(arrCircles) Then Exit Sub

            Dim arrTrimCircles : arrTrimCircles = Rhino.CurveBooleanUnion(arrCircles)
            If IsArray(arrTrimCircles) Then
                    Rhino.DeleteObjects(arrCircles)
            End If

            Dim arrArea : arrArea = Rhino.CurveArea(arrTrimCircles)

            Call Rhino.Print("The area is " & CStr(arrArea(0))
  • 3. KSchillaci (Jul 01, 2011 04.48):

    Ledisnomad,

    Understandable no rush, I have my hands full as well. Thanks for the help I guess I was over-structuring it. I have another question however. I was to get the total area of surfaces I created from closed planar curves and becuase it is returning an array I think it is only giving me one of the areas because the value is too small. Also i know Cstr() only works with a single string not an array.
    How can I format to get all of the areas added into one number?

            Dim Circles: Circles = Rhino.GetObjects("Get circles",4)
            Dim arrTrimCircles : arrTrimCircles = Rhino.CurveBooleanUnion(Circles)
            Dim h
            If IsArray(arrTrimCircles) Then
                    Rhino.DeleteObjects(Circles)
            End If
            Dim strSurface : strSurface = Rhino.AddPlanarSrf(arrTrimCircles)
            Dim srfArea, g, addsrfArea
            For g = 0 To Ubound(strSurface)
                    srfArea = Rhino.SurfaceArea(strSurface(g))
            Next
            Call Rhino.Print("The Surface Area Is: " & CStr(srfArea(0)))
           

  • 2. ledisnomad (Jun 30, 2011 23.42):

    Hey, KSchillaci.

    I haven't forgotten about sharing those scripts with you, just have been too busy. As for your current problem, I think you are working too hard. This might not be quite right, but I think it accomplishes what you want in your last For loop:

    For j = 0 To Ubound(arrOrigin)

            'Find height of arrOrigin(j), which is just the z coordinate
            height = arrOrigin(j)(2)
           
            'Create circle at arrOrigin(j) with a radius based on height
            newPlane = Rhino.PlaneFromFrame(arrOrigin(j), Array(1,0,0) ,Array(0,1,0))
            strCircle = Rhino.AddCircle(newPlane, height*RadiusOne)
           
    Next
  • 1. KSchillaci (Jun 30, 2011 21.58):

    I am trying to Move then Scale Circles based on the Height of the Point. The higher the point the larger the scaled circle becomes. I cant seem to get the loop to run correctly.

    the code looks like this

    Option Explicit
    'Script written by <Kyle Schillaci>
    'Script copyrighted by <Kyle Schillaci>
    'Script version Thursday, 16 June 2011 11:31:11

    Call Main()
    Sub Main()
            'Insert Data Plot constraints as Polygon/Curve
            Dim Surface
            Dim PlotConstraints : PlotConstraints=Rhino.GetObjects("select polygon for Plot Constraints ",4)
            If isNull (PlotConstraints) Then Exit Sub
            Surface=Rhino.ObjectsByType(8)
            'Convert Plot to Planar Surface
            Dim PlotSurface,arrCenter
            PlotSurface = Rhino.AddPlanarSrf(PlotConstraints)
            arrCenter = Rhino.SurfaceAreaCentroid(PlotSurface(0))
            If IsArray(arrCenter) Then
                    Rhino.AddPoint arrCenter(0)
            End If
            Rhino.DeleteObject(PlotSurface(0))
           
            Dim strTrailLayer : strTrailLayer = Rhino.GetLayer("Pick Trail Layer")
            Dim VisLayer : VisLayer = Rhino.LayerVisible(strTrailLayer,True)
            Dim x  : x = Rhino.GetInteger("Number of Trails: ")
                   
            Dim arrPoints,i,arrTrails
            ReDim arrPoints(x-1) 'Total Number of Trails
           
            For i = 0 To x-1                'For first value in array to Total number of trails, get objects.
                    arrPoints(i) = Rhino.GetPoints(True, False, "Select Points for Trail " & i)
                    arrTrails = Rhino.addinterpcurve(arrPoints(i))
            Next
            VisLayer = Rhino.LayerVisible(strTrailLayer,False)
           
            Dim strDeadAnts, arrDeadAnts,SelectAnts
            strDeadAnts = Rhino.GetLayer("Choose Dead Ant Layer")
            Dim VisLayerAnts : VisLayerAnts = Rhino.LayerVisible(strDeadAnts,True)
            arrDeadAnts = Rhino.ObjectsByLayer(strDeadAnts,True)
            Call Rhino.Print("Does it Exist?" & UBound(arrDeadAnts))
            'strDeadAnts = A chosen Layer
            Dim arrOrigin, newPlane, RadiusOne,j, RadiusTwo, strCircles, arrScale, k, Center, ScaledCircles, arrDist, strMoveCircles, vecVert
            Dim xyPlane : xyPlane = Rhino.WorldXYPlane()
            Dim strOrigin

            arrOrigin = Rhino.GetPoints(True,False,"Select Dead Ants")
            RadiusOne = Rhino.GetInteger("Circle Radius",1)
           
            For j = 0 To Ubound(arrOrigin)
                    strOrigin = Rhino.Pt2Str(arrOrigin(j))
                    arrPoints(j) = Rhino.PointCoordinates(strOrigin,Array(arrOrigin(j)(0),arrOrigin(j)(1),0))'arrOrigin might not be str
                    vecVert(j) = Rhino.VectorCreate(arrOrigin(j),arrPoints)
                    newPlane = Rhino.MovePlane(xyPlane,arrOrigin(j))
                    strCircles = Rhino.AddCircle(newPlane,RadiusOne)'Returns a String not an Array
                    strMoveCircles = Rhino.MoveObjects(strCircles,arrOrigin(j),vecVert) ' Must declare vecVert
                    Center = Rhino.CircleCenterPoint(strMoveCircles)
                    arrDist = Rhino.Distance(arrOrigin,Center) 'Because they are in the same Location
                    Rhino.Print("And the Distance is " & arrDist)
                   
            Next
           
           
            'Call ExportPointsToExcel(arrDeadAnts)

    End Sub
Recommend

Why are these buttons gray?