Forgot password?

Create an account!

Forum

« back

RhinoScript – Orienting AddCutPlane

Messages

Please log in to write a message.

  • 3. bbrown (Nov 02, 2011 12.25):

    Hi,
    I would like to intersect an object by several groups of planes, whose have different directions.
    I have used the function "CreateCutPlane", but for an unknown reason the direction introduced (arrNormal) is the same in both cases, the horizontal and vertical planes, even if the vector used is different.

    I attach the code.

       Rhino.Print "New layer: " & Rhino.AddLayer("sections", RGB(0, 255, 255))
        Rhino.CurrentLayer("sections")
        Function CreateCutPlane(objsec, p0sec, p1sec, arrNormal90)

    Dim saved, s0, s1, cmd
        arrNormal90 = Rhino.VectorCreate (Array(0,0,0), Array(1,0,0))
        CreateCutPlane = Null
        Rhino.EnableRedraw False
        saved = Rhino.SelectedObjects
        Rhino.UnSelectAllObjects
        Rhino.SelectObjects objs
        s0 = Rhino.Pt2Str(p0sec,,True)
        s1 = Rhino.Pt2Str(p1sec,,True)
        cmd = "_CutPlane " & s0 & s1 & "_Enter"
        Rhino.Command cmd, 0
        CreateCutPlane = Rhino.FirstObject
        Rhino.UnSelectAllObjects
          If IsArray(saved) Then Rhino.SelectObjects(saved)
            Rhino.EnableRedraw True
        End Function
          If IsArray(objs) Then
        For i = 1 To (numsec)
        p0sec = Rhino.GetPoint("Star point")
          If  IsArray(p0sec) Then
            p1sec = Rhino.GetPoint("End point", p0sec)
          If  IsArray(p1sec) Then  
            objsec = CreateCutPlane (objs, p0sec, p1sec, arrNormal90)
          If IsNull(objsec) Then
            Rhino.Print objsec
         End If
         End If
         End If
    Next
         End If  
     
    'Horizontal planes

      Dim objph, p0ph, p1ph, arrNormal100
       Rhino.Print "New layer: " & Rhino.AddLayer("horizontal planes", RGB(255, 0, 255))
       Rhino.CurrentLayer("horizontal planes")
       Function CreateCutPlane(objph, p0ph, p1ph,arrNormal100)

    Dim saved1, s01, s11, cmd1
        arrNormal100 = Rhino.VectorCreate (Array(0,0,0), Array(0,1,0))
        CreateCutPlane = Null
        Rhino.EnableRedraw False
        saved1 = Rhino.SelectedObjects
        Rhino.UnSelectAllObjects
        Rhino.SelectObjects objs
        s01 = Rhino.Pt2Str(p0ph,,True)
        s11 = Rhino.Pt2Str(p1ph,,True)
        cmd1 = "_CutPlane " & s01 & s11 & "_Enter"
        Rhino.Command cmd1, 0
        CreateCutPlane = Rhino.FirstObject
        Rhino.UnSelectAllObjects
          If IsArray(saved1) Then Rhino.SelectObjects(saved1)
            Rhino.EnableRedraw True
        End Function
          If IsArray(objs) Then
        For i = 1 To (numcub)
        p0ph = Rhino.GetPoint("Star point")
          If  IsArray(p0ph) Then
            p1ph = Rhino.GetPoint("End point", p0ph)
          If  IsArray(p1ph) Then  
            objph = CreateCutPlane (objs, p0ph, p1ph,arrNormal100)
          If IsNull(objph) Then
            Rhino.Print objph
         End If
         End If
         End If
    Next
         End If  

    Thanks in advance.

  • 2. Johannes (Apr 26, 2010 13.49):

    i can't figure out what goes wrong... but take a look on the following code. it works fine with your definition of arrNormal.
    the result is the identifier of the cutting plane.

            Dim arrObjects, arrPt0, arrPt1
            Dim arrNormal
           
            arrObjects      = Rhino.getobjects("Select objects for cut plane")
            arrPt0          = Rhino.GetPoint("Start of cut plane")
            arrPt1          = Rhino.GetPoint("End of cut plane", arrPt0)

            arrNormal = Rhino.VectorCreate(Array(0,0,0), Array(5,5,1))
           
            Call Rhino.AddCutPlane (arrObjects, arrPt0, arrPt1, arrNormal)
    Orienting AddCutPlane
  • 1. mrgordon (Apr 26, 2010 13.02):

    I have a set of rectangular prisms and I want to split each one in half by bisecting its longest dimension. My plan was to generate a cutplane for each prism and I have already calculated a StartPoint and an EndPoint along the middle of each object where I want to cut.

    I have been struggling for days with the Rhino.AddCutPlane method because I have been unable to generate arrNormal (the optional fourth argument) correctly. If I call AddCutPlane on each of the prisms with a correct StartPoint and EndPoint, I get different orientations for the cutplanes that are generated even if I use the same value for arrNormal. Could this have something to do with CPlane vs. WorldPlane, a bug in my code, or something else altogether? Any insight on how I can solve this (with or without AddCutPlane) would be much appreciated. I'm ready to give up on using AddCutPlane but I can get it to properly orient the cutplanes about 75% of the time, so it's really frustrating.

    I've tried generating normals using both of the following formats:

    arrNormal = Rhino.VectorCreate(Array(0,0,0), Array(0,0,1)
    arrNormal = Rhino.SurfaceNormal(strSmallestSurface, Rhino.SurfaceClosestPoint(strSmallestSurface, ptOnSmallestSrf))

    MyPlane = Rhino.AddCutPlane(Array(strObject), ptStart, ptEnd, arrNormal)
Recommend

Why are these buttons gray?