Forgot password?

Create an account!

Forum

« back

RhinoScript – Copy, rotate and scale proxies to points

Messages

Please log in to write a message.

  • 3. Mikel (Apr 04, 2013 18.24):

    Thanks Hanno, for some reason I thought I would get only the base point using GetMeshVertices, I didn't realise I was getting all the mesh vertex indices!

    Some lovely people have given me advice and I have used GetPointOnMesh instead which returns a single 3D point.

    Thanks for your help

    Mikel

  • 2. Hanno (Apr 03, 2013 12.15):

    Hi Mikel,

    why are you using GetMeshVertices for your start point? This gives you an array of mesh vertex indices, but you need a 3d point.
    And a second thing: CopyObject returns the ID of the copied instance. If you want to do the rotation and scaling on the copy, you have to use the returned ID, not the original.

    Hope that helps!

    Hanno

  • 1. Mikel (Apr 03, 2013 11.24):

    Hi

    I am trying to copy a vray proxy (tree) to points. I have starte writing a script because I want to copy the trees to these points and then rotate randomly and scale randomly (between 60% and 100%) the trees to give a more natural look to the scene I am trying to achieve. The first lines of the script work well to select the proxy and the proxy mesh vertex but it stops at the Rhino.CopyObject line saying: 'Mismatch in parameters. Array required'. I have looked at similar scripts and they seem to work well however I can't get this script to work and I cannot really understand why. I would really appreciate some help with this.

    This is the script I have written so far (I have attached the screenshot):

    Call Main()
    Sub Main()
    Dim strTreeProxy
    Dim arrTreeProxyBase
    Dim arrTreeCentres

    'Select tree proxy'
    strTreeProxy = Rhino.GetObject("Select tree proxy")
    If IsNull(strTreeProxy) Then Exit Sub

    'Select point of tree proxy to copy from'
    arrTreeProxyBase = Rhino.GetMeshVertices(strTreeProxy, "Select point at base of tree proxy")
    If IsNull(arrTreeProxyBase) Then Exit Sub

    'Select the points to copy the tree proxies to'
    arrTreeCentres = Rhino.GetPointCoordinates("Select tree centres", True)
    If IsNull(arrTreeCentres) Then Exit Sub

    Call Rhino.EnableRedraw(False)

    Dim arrTreeCentre

    If IsArray(arrTreeCentres) Then
    For Each arrTreeCentre In arrTreeCentres
    'Copy tree proxies to points'
    Call Rhino.CopyObject(strTreeProxy, arrTreeProxyBase, arrTreeCentre)
    'Rotate tree proxies'
    Call Rhino.RotateObject(strTreeProxy, arrTreeCentre, Rnd() * 360)
    'Scale tree proxies'
    Call Rhino.ScaleObject(strTreeProxy, arrTreeCentre, Array((1.62 + (Rnd() * 1.08)) / 2.7, (1.62 + (Rnd() * 1.08)) / 2.7, (1.8 + (Rnd() * 1.4))) / 3.2)
    Next
    End If

    Call Rhino.EnableRedraw(True)

    End Sub

    Thank you

    Mikel

Recommend

Why are these buttons gray?