Error in this script

Hi all!

I’m working on the following script. The objective is that it asks you the number of decks of floors in a building. Then it will ask you the height of each deck, and the objective is that it generates a horizontal plane at the height of each floor.
The problema is that is returns me an error when I try to use the “Rhino.addsrfpt” (I’ve also tried with “Rhino.Planefromframe” and others similar). This error tells me that the number of arguments is wrong or the asignation of property is not valid.
Do you know where could be the error? Thank you very much


Dim ncub, i

ncub = Rhino.Realbox("Specify the number of decks", , "Number of decks")
i = 1

If IsNumeric(ncub) And ncub > 0 Then
  While i < (ncub + 1)
    hcub = Rhino.Realbox("Height of the deck " & i & " in meters", , "Deck" & i)
    z = hcub
    If IsNumeric(hcub) And hcub > 0 Then
      p1 = Array(-50, -100, z)
      p2 = Array(-50, 100, z)
      p3 = Array(400, 100, z)
      p4 = Array(400, -100, z)
      Call Rhino.addsrfpt(p1, p2, p3, p4)
    End If
    i = i + 1
End If


The method Rhino.AddSrfPt() expects an array of points. Use this instead:

Call Rhino.AddSrfPt(Array(p1, p2, p3, p4))


Thank you very much clement!! it solved the problema

I have another question, do you know wich command could I use to selectionate objects into a determinate area or domain? I mean, the same operation that we make with the mouse by selectionating objects into a rectangle with the mouse.

Thank you!!

hi @Charly,

you could use Rhino.Command() and script the built in commands for the selection rectangle _SelWindow or _SelCrossing followed by a coordinate eg:

Call Main()
Sub Main()

    Dim cmd
    cmd = "_SelCrossing 0,0 300,300"
    Rhino.Command cmd, False

End Sub

But i do not find this very reliable after testing it now, it seems that Rhino interprets the 2D coordinates as CPlane coordinates and not client or screen coordinates. @pascal is this a bug ?



There are several more ways to do it, depending on what exactly you are trying to do.
What @clement mentioned will work well, if you want World coordinates, just use “w” before the cords (w0,0 w300,300)

Another command to look at would be _SelBoundary - this way you can pick a closed curve to select by.

In RhinoScript, take a look at this method too: Rhino.WindowPick

In all cases, if you need a “screen” rectangle rather than world/cplane window rectangle, you may need to go deeper into transforming screen to world coordinates with Rhino.XformScreenToWorld and Rhino.XformWorldToScreen.



Thanks Jarek. I guess i´ve been messing too much with Python and RhinoCommon and do not remember all these methods :wink: Rhino.WindowPick() works much better after transforming the coordinates from screen to world.


@clement and @Jarek, thank you a lot. Little by Little I’m learning more things, thank you!